From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B814FC35242 for ; Tue, 11 Feb 2020 04:17:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4F4FC20842 for ; Tue, 11 Feb 2020 04:17:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="yjKkZhYQ"; dkim=pass (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="yjKkZhYQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4F4FC20842 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D88826B027A; Mon, 10 Feb 2020 23:17:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D380A6B027B; Mon, 10 Feb 2020 23:17:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C27F96B027C; Mon, 10 Feb 2020 23:17:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0188.hostedemail.com [216.40.44.188]) by kanga.kvack.org (Postfix) with ESMTP id AABAB6B027A for ; Mon, 10 Feb 2020 23:17:50 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 555E62C89 for ; Tue, 11 Feb 2020 04:17:50 +0000 (UTC) X-FDA: 76476537900.28.burn88_614fc68f9fa31 X-HE-Tag: burn88_614fc68f9fa31 X-Filterd-Recvd-Size: 15354 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2052.outbound.protection.outlook.com [40.107.22.52]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Tue, 11 Feb 2020 04:17:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gomcYnT8twcLXBHl72gopydebGgzfBA6OVX1vK5WpP4=; b=yjKkZhYQ2IkrxK04P9ZLkx9sjKzNsQ+AGOe38v8WLL6rM8fgzYbkb20VH25oTXe9+eb9R7MIGWk3Lz1dHMrZYSmGxSTQSyW4gLKt2d6oEh8OZ3Q7vFSKrJiae5fLdLj/zF3p3w/ROw+bARVPuMsy/6/BzmrqAI9CFfswLRUlVro= Received: from VI1PR08CA0120.eurprd08.prod.outlook.com (2603:10a6:800:d4::22) by DB6PR08MB2631.eurprd08.prod.outlook.com (2603:10a6:6:23::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2707.23; Tue, 11 Feb 2020 04:17:45 +0000 Received: from AM5EUR03FT043.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::206) by VI1PR08CA0120.outlook.office365.com (2603:10a6:800:d4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2707.24 via Frontend Transport; Tue, 11 Feb 2020 04:17:45 +0000 Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; kvack.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;kvack.org; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT043.mail.protection.outlook.com (10.152.17.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2665.18 via Frontend Transport; Tue, 11 Feb 2020 04:17:45 +0000 Received: ("Tessian outbound 846b976b3941:v42"); Tue, 11 Feb 2020 04:17:45 +0000 X-CR-MTA-TID: 64aa7808 Received: from 33c38988c965.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 1E450C5E-8D41-4599-8584-5654717A0648.1; Tue, 11 Feb 2020 04:17:40 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 33c38988c965.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 11 Feb 2020 04:17:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jHoi7mh9AoSC6zjftCORba6w1RdA9Oif8cNXRR0dK5JG4/uPE0tsoXXSTeOAhyO2tdZnJw4cViixwylc3AioT+/vxA6lk0dctpXEPLr9+ctEDRm4fqyxiY3IYiewsdmJRXiw/EDDlMWe96Hyo9GRy2YnuYGR4tvcePpwojJAE/ZV3/eET7C0OGBW4HpYx9EbjSNud52bm5jHjBEVo4VFER0Jm8WSpiyCDadz8ZkI1VFgvbTy2F+nez8POY6FbBLgJMoRm0DKSAM7H0x7AA1qyeN6qvh5HxGEhfqTuJMVDfgT4mWnlIOAppTBlNcERFWKWKPH8Hxj6+kqTBslGX7aqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gomcYnT8twcLXBHl72gopydebGgzfBA6OVX1vK5WpP4=; b=TpieKsnkjQpTJbNHZnBpzG0VtYN52xmQhk3Jo4hXdbtEd/kIWyZgOmGEbSDkqAlvCdXzOdTODWRZ+k44Z9hN5aIoyfzqyKLD4s9/2LyS2m2O+PdBvIEw4KIOykoIlIgWoCNfFQ2Q82Hp9tMXVBUsofffhAuDdoGaRGdKVHxvKlPjN/Yg4P/CBAq5oFBZU2toq0w5Ajy26QL20i3zx8FiLcGjnpsxr2wFnCS9Om7FwdFgBniOxQbd6/2t08hXVYSu0u6H8WBNO6xyRrlyTZMtJEJcnhYBF52HJbWZqLpNAMtC94Sy5VpWoW9zEjTzWkRO+vFwBIYSOKbPzCbUKJJXFQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gomcYnT8twcLXBHl72gopydebGgzfBA6OVX1vK5WpP4=; b=yjKkZhYQ2IkrxK04P9ZLkx9sjKzNsQ+AGOe38v8WLL6rM8fgzYbkb20VH25oTXe9+eb9R7MIGWk3Lz1dHMrZYSmGxSTQSyW4gLKt2d6oEh8OZ3Q7vFSKrJiae5fLdLj/zF3p3w/ROw+bARVPuMsy/6/BzmrqAI9CFfswLRUlVro= Received: from VE1PR08MB4639.eurprd08.prod.outlook.com (10.255.112.205) by VE1PR08MB4878.eurprd08.prod.outlook.com (10.255.113.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2707.23; Tue, 11 Feb 2020 04:17:38 +0000 Received: from VE1PR08MB4639.eurprd08.prod.outlook.com ([fe80::c9ee:3f89:c4ac:416]) by VE1PR08MB4639.eurprd08.prod.outlook.com ([fe80::c9ee:3f89:c4ac:416%7]) with mapi id 15.20.2707.030; Tue, 11 Feb 2020 04:17:38 +0000 From: Justin He To: Jeff Moyer CC: Catalin Marinas , Kirill A.Shutemov , "linux-mm@kvack.org" Subject: RE: bug: data corruption introduced by commit 83d116c53058 ("mm: fix double page fault on arm64 if PTE_AF is cleared") Thread-Topic: bug: data corruption introduced by commit 83d116c53058 ("mm: fix double page fault on arm64 if PTE_AF is cleared") Thread-Index: AQHV4GS1VLwrv+Kjo0eGYDc8c61fmKgVYlGQ Date: Tue, 11 Feb 2020 04:17:38 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US, zh-CN Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: c18d623e-7c68-46b1-bf32-cc9fb28dc55b.1 x-checkrecipientchecked: true Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=Justin.He@arm.com; x-originating-ip: [113.29.88.7] x-ms-publictraffictype: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: c300a7c9-2908-450a-6ea7-08d7aea95884 X-MS-TrafficTypeDiagnostic: VE1PR08MB4878:|VE1PR08MB4878:|DB6PR08MB2631: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:2276;OLM:10000; x-forefront-prvs: 0310C78181 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM;SFS:(10009020)(4636009)(136003)(346002)(396003)(366004)(376002)(39860400002)(189003)(199004)(26005)(45080400002)(186003)(7696005)(8936002)(2906002)(6916009)(33656002)(66946007)(66446008)(64756008)(66556008)(66476007)(8676002)(76116006)(81166006)(81156014)(55016002)(4326008)(9686003)(5660300002)(71200400001)(86362001)(52536014)(55236004)(54906003)(53546011)(316002)(6506007)(478600001);DIR:OUT;SFP:1101;SCL:1;SRVR:VE1PR08MB4878;H:VE1PR08MB4639.eurprd08.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: JDgh+xufGgW2ilPrL5yMvmS7K+wAfThQ6Y1ojR3WDP7CskohuRdD51V1mjx/pMmlT3QNUNQCSfpMS8maNTh4IyQFwS/Z/l9+bC7rpNrYu1VlwNmgR+RNwU/a4DqyiG7MCt0fSYCOMusJGdLXu+AsPupr9G98ux6J3bvFyVvhecvqoag+nfp8j3XdLHZ0XpPiFzwvCAGszF47aCOpkTZeeI5phQh64aHy4Hwn0joaCAzfKEv6u6vVLFMua3kchxcSlMxgwxoGNPz7AIPz3tWcy7kfy4NGJ/0sFVi8YwxuP+08zr91YaKsFmzMXYfQV7/2B7Ys+7WVLIjxFNutFnUiyUJ0vag41TEpY1odkYHwo1nizTRq5plrUqp0h9T/B4g4WxeUBOF46R1RVU0tETtFKA4IfHfmcJ5lnABBUx8u1jbUQbDWWdnQ/oW7FcxYIhzE x-ms-exchange-antispam-messagedata: C0hAWxXzv30cBWD5X5pxeu4m5caTYaGU2futCP6X5gVJGs9hxaNmwgbZCqIOT5cekdO0ia5IWpNCowwxNGL9VGqnDWN77v+l5UH2/CDHxeJF3JNmOht2cOutxjV9e4JddSDB1Zn6iKtp1f4bKv2faw== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4878 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Justin.He@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT043.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123;IPV:CAL;SCL:-1;CTRY:IE;EFV:NLI;SFV:NSPM;SFS:(10009020)(4636009)(376002)(346002)(136003)(39860400002)(396003)(189003)(199004)(45080400002)(336012)(5660300002)(53546011)(52536014)(6506007)(86362001)(26826003)(26005)(54906003)(55016002)(9686003)(478600001)(36906005)(8936002)(186003)(33656002)(4326008)(316002)(8676002)(7696005)(356004)(81156014)(70206006)(70586007)(2906002)(6862004)(81166006);DIR:OUT;SFP:1101;SCL:1;SRVR:DB6PR08MB2631;H:64aa7808-outbound-1.mta.getcheckrecipient.com;FPR:;SPF:Pass;LANG:en;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;MX:1;A:1; X-MS-Office365-Filtering-Correlation-Id-Prvs: 707e0733-b7ab-4f6a-7560-08d7aea9543f X-Forefront-PRVS: 0310C78181 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Cn950r0AZyEm+iZrE+T2uxd3hSx4x5Ltu+bRzM3qXEbBP8tTX7+Xa1ySJaFQZCOur30TG+6oNl+yMGFxcy35/ung9uHjOBpfBlF4it7aPBDs107R1lBKBMzZhZj9b4EmddTCWXLo5h3S/e2jgq2fuo4+XbmvJx/aenQxfvwPyLrYj3hC11EZ/aoWUCxT6lUtJ1XeXHxSaVL+KXX/DMXxFJg5wISJWT1GYEFlst83KOb8E4B3WPeFwyz6P9+cvroB4t6HExkyB80Uk2x3O5nd5pC3eLZLtFC7lQOcE4kb/+BgpyjmsYxYURR04tLx3UehhhU7y9MTHJG9+PYAfktRbMrSjMyuORABRh600guS8LcSfitWBfCUokn6O2oxS8ywsmAqnIVP1PC+Rh0QuEM40zhkLEtbCFRgycs8bx4KomUUHWosOTLjSncw1NN1kzHp X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Feb 2020 04:17:45.3394 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c300a7c9-2908-450a-6ea7-08d7aea95884 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR08MB2631 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Hi Jeff > -----Original Message----- > From: Jeff Moyer > Sent: Tuesday, February 11, 2020 6:52 AM > To: Justin He > Cc: Catalin Marinas ; Kirill A.Shutemov > ; linux-mm@kvack.org > Subject: bug: data corruption introduced by commit 83d116c53058 ("mm: fix > double page fault on arm64 if PTE_AF is cleared") > > Hi, > > While running xfstests test generic/437, I noticed that the following > WARN_ON_ONCE inside cow_user_page() was triggered: > > /* > * This really shouldn't fail, because the page is there > * in the page tables. But it might just be unreadable, > * in which case we just give up and fill the result with > * zeroes. > */ > if (__copy_from_user_inatomic(kaddr, uaddr, PAGE_SIZE)) { > /* > * Give a warn in case there can be some obscure > * use-case > */ > WARN_ON_ONCE(1); > clear_page(kaddr); > } > > Just clearing the page, in this case, will result in data corruption. I > think the assumption that the copy fails because the memory is > inaccessible may be wrong. In this instance, it may be the other thread > issuing the madvise call? > > I reverted the commit in question, and the data corruption is gone. > Thanks for the report. But this commit 83d116c53058 doesn't add the new clear_page code path. Besides the pte_mkyoung part, It just refines the codes(no functional change) and add a WARN_ON_ONCE to indicate there is any obscure case before. -- Cheers, Justin (Jia He) > Below is the (ppc64) stack trace (this will reproduce on x86 as well). > I've attached the reproducer, which is a modified version of the > xfs test. You'll need to setup a file system on pmem, and mount it with > -o dax. Then issue "./t_mmap_cow_race /mnt/pmem/foo". > > Any help tracking this down is appreciated. > > Thanks! > Jeff > > [ 3690.894950] run fstests generic/437 at 2020-02-10 13:40:37 > [ 3691.173277] ------------[ cut here ]------------ > [ 3691.173302] WARNING: CPU: 76 PID: 51024 at mm/memory.c:2317 > wp_page_copy+0xc40/0xd50 > [ 3691.173308] Modules linked in: ext4 mbcache jbd2 loop rfkill ib_isert > iscsi_target_mod ib_srpt target_core_mod ib_srp scsi_transport_srp i2c_de= v > rpcrdma sunrpc rdma_ucm ib_iser ib_umad rdma_cm iw_cm libiscsi > scsi_transport_iscsi ib_ipoib ib_cm mlx5_ib ib_uverbs ib_core > dax_pmem_compat device_dax nd_pmem nd_btt dax_pmem_core of_pmem > libnvdimm ses enclosure ipmi_powernv ipmi_devintf sg ibmpowernv xts > ipmi_msghandler opal_prd vmx_crypto leds_powernv powernv_op_panel > uio_pdrv_genirq uio xfs libcrc32c sd_mod t10_pi mlx5_core ipr mpt3sas lib= ata > raid_class tg3 scsi_transport_sas mlxfw dm_mirror dm_region_hash dm_log > dm_mod [last unloaded: scsi_debug] > [ 3691.173363] CPU: 76 PID: 51024 Comm: t_mmap_cow_race Not tainted > 5.5.0+ #4 > [ 3691.173369] NIP: c0000000003df6e0 LR: c0000000003df42c CTR: > 0000000000007f10 > [ 3691.173375] REGS: c000002ec66fb830 TRAP: 0700 Not tainted (5.5.0+) > [ 3691.173379] MSR: 9000000002029033 CR: > 24022244 XER: 20040000 > [ 3691.173388] CFAR: c0000000003df458 IRQMASK: 0 > GPR00: 0000000000000000 c000002ec66fbac0 c000000001746a00 > 0000000000007f10 > GPR04: 00007fff976080f0 0000000000007f10 00000000000080f0 > 0000000000000000 > GPR08: 0000000000000000 c000000000000000 c000002de046a000 > 0000000000000030 > GPR12: 0000000000000040 c000002ffffa9800 0000000014a70278 > 00007fff981f0000 > GPR16: 00007fff98f24410 00007fff98f24420 00007fff97600000 > 0000000014a70270 > GPR20: 0000000010000fc0 c000002fa974ebf0 00007fff97600000 > c0000000017fd9e8 > GPR24: c0000000017fd960 c000000001775e98 c000002eabcc5a00 > c000002fc3b40000 > GPR28: 0000000000000000 c000002fa974ebf0 c00c00000bf0ed00 > c000002ec66fbc10 > [ 3691.173430] NIP [c0000000003df6e0] wp_page_copy+0xc40/0xd50 > [ 3691.173434] LR [c0000000003df42c] wp_page_copy+0x98c/0xd50 > [ 3691.173438] Call Trace: > [ 3691.173442] [c000002ec66fbac0] [c0000000003df42c] > wp_page_copy+0x98c/0xd50 (unreliable) > [ 3691.173448] [c000002ec66fbb80] [c0000000003e3448] > do_wp_page+0xd8/0xad0 > [ 3691.173454] [c000002ec66fbbd0] [c0000000003e6248] > __handle_mm_fault+0x748/0x1b90 > [ 3691.173460] [c000002ec66fbcd0] [c0000000003e77b0] > handle_mm_fault+0x120/0x1f0 > [ 3691.173466] [c000002ec66fbd10] [c000000000086b60] > __do_page_fault+0x240/0xd70 > [ 3691.173473] [c000002ec66fbde0] [c0000000000876c8] > do_page_fault+0x38/0xd0 > [ 3691.173480] [c000002ec66fbe20] [c00000000000a888] > handle_page_fault+0x10/0x30 > [ 3691.173484] Instruction dump: > [ 3691.173488] 38800003 4bfffaf8 60000000 60000000 7f83e378 4800d585 > 60000000 4bfffcb8 > [ 3691.173496] 7f83e378 4bfa72b5 60000000 4bfffc8c <0fe00000> 3d42ffeb > 394acb48 812a0008 > [ 3691.173503] ---[ end trace a8dffbf7f73e8243 ]--- IMPORTANT NOTICE: The contents of this email and any attachments are confid= ential and may also be privileged. If you are not the intended recipient, p= lease notify the sender immediately and do not disclose the contents to any= other person, use it for any purpose, or store or copy the information in = any medium. Thank you.