Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1325841lqd; Thu, 25 Apr 2024 11:58:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXCUY5crqkUkx3GRZG7aEZ5SrANJf7WpyWbzuW1uD5hm2Gvc0Dt0qFCg2oW9W+nUE5WqyQSQ8aHtVcqvCMmkBpZhNjFYq7mIOj2RaDqsQ== X-Google-Smtp-Source: AGHT+IG0sW6u3oCpkdtpnxXylDFhiShvIIezK7D9tgijzyqVW2QQy6vxgc1ILGCCGM8P1eZhXr0n X-Received: by 2002:a05:6a20:2454:b0:1a9:509c:eba6 with SMTP id t20-20020a056a20245400b001a9509ceba6mr974281pzc.25.1714071520966; Thu, 25 Apr 2024 11:58:40 -0700 (PDT) Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id k11-20020a636f0b000000b005f803b18ef5si11063222pgc.513.2024.04.25.11.58.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 11:58:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-159047-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b="mXM/6HzM"; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-159047-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159047-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 93992281D06 for ; Thu, 25 Apr 2024 18:58:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 257BC14F123; Thu, 25 Apr 2024 18:58:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="mXM/6HzM" Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2060.outbound.protection.outlook.com [40.107.93.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3F4539AFD for ; Thu, 25 Apr 2024 18:58:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.60 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714071512; cv=fail; b=icXOE+awXAPnepZldN5yeGMh91HH30qaJ6ykQCPhtxjx3AazAa285rHvsLK+JAfJLsYSzm2WN7VYKUWZfzmOHSKZ34Ll54Jhqanp0byOaqoBy3RQoSpq9RNlvsr7JTtmvYbxLevSwLZu010SA+PClBjtG12MdcDlrWE2IXxJUFY= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714071512; c=relaxed/simple; bh=lyGuvxh2/O9vbDYhgDMA5HWIQs1evuuFY5bGyFRfVD0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=WbEp0ZKrCitufmwgSapurLjpQDcNOs+RRAQ1o1SY1M7GSWlDJBf7OYE/uujsy2ELkTsOKTWHig6tls3se8Ba2PhvTJy6jHslvKLon2PXwbHdVajLsV54+3Uf0IKFzOBKT/KuNmpF768EuesOh6fAMZmCWYEjWiVaazzJK3C7r2o= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=mXM/6HzM; arc=fail smtp.client-ip=40.107.93.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PnByhZNFKLGkrSarlyN3hgnALBjHg0HQIcdlsYD2tf5cvdmzT38AIx6fbGASE/OYmfZCUaJwSbc4Yx0RtOQhB/TvEfr7pcFRoZbKJJ0ZCqn5xFBv76EqjjLfNVjsEWn0oddPiAm2KxM0oGYNcuZBspSpoPTn5sQuj87la3WLCpKabDBceoaKYVW21CBdu0pnb8TtQaJPA6OIr8xzHRdFlWjsX52moPRuQwtvQUKNy68QzKGMxoQxQG4bEF3XjAlYx/DzEXnb8MrFHQlrzwbvaFbACVLLKVNXAoDG5d08wtSoaraXZl0LXc8ca233hXmpZ17sbwapQwO+CeBNS7dPNQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0x2XFK151mWo9qrp4GEulz8MeAfS4YXliqIHtir0JNk=; b=hHV4EjIFmbS7/ShoXYe7z2tX/n26vpcrrVkn0ZWPV8AzIFZ4Gnx7y8ZFfP2BH/H/63Nl+WE3L15grgZ+Kvr3cc5f3HGQJ2T7qJaogFS6gEfo7jju9AfY71gIlNHY3jHkL824ndh9xRIV3Oe90rab/OboMAC31V0612D+kvDvwDfzhIV+l0QQPLqCJNOQDUMhgIGbm+mUQWwAVfAP6SkxjyeVNFSFGCOWVMAxICRzjXw3eQ4DHc2qDTgbF0tUPiby5wtKGZKGJ4Dvreoy0U/tTsfVbFhWGsivDr+nLqOCKmDYjy8NGVRiXvM28iWkXLEF/2R1jUyye1Lz4UvhJcB0oQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0x2XFK151mWo9qrp4GEulz8MeAfS4YXliqIHtir0JNk=; b=mXM/6HzMeW4tWhNTAmmoySxReWcxt0GrAc+i95X/haQ9Nr77MBk8h7Lh3p+S8VEiutQgaWUu5l6+Rvt89gbFp6ZVnqf/uO/O5KPqJqHGVW2lsIjE//+bDArJBYGrcfmFkLwFjZSmGFxySwuNvDydL4DgWhkFfVWL2ZBw7yuaQG+0MS2xZTT8YKspSNeySFQBcvxwMGa8vnBqNhJB3TIh505NYCkPRQbfRt0j5kxaO3JIBjRMN7lnFDqgLQqkMXBT7ZyzoJUwX26cmZC8fcCEOKF6tlmwi7jyRcuz8fWLBty7jsQ7ZUg6JorrUDTnOW1qpN1MdhXT9UaVCtayCedUVg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DS7PR12MB5744.namprd12.prod.outlook.com (2603:10b6:8:73::18) by DS0PR12MB9398.namprd12.prod.outlook.com (2603:10b6:8:1b3::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.22; Thu, 25 Apr 2024 18:58:27 +0000 Received: from DS7PR12MB5744.namprd12.prod.outlook.com ([fe80::dc5c:2cf1:d5f5:9753]) by DS7PR12MB5744.namprd12.prod.outlook.com ([fe80::dc5c:2cf1:d5f5:9753%6]) with mapi id 15.20.7519.021; Thu, 25 Apr 2024 18:58:27 +0000 From: Zi Yan To: Ryan Roberts Cc: Andrew Morton , "Aneesh Kumar K.V" , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Anshuman Khandual , Huacai Chen Subject: Re: [PATCH v1] mm: Fix race between __split_huge_pmd_locked() and GUP-fast Date: Thu, 25 Apr 2024 14:58:24 -0400 X-Mailer: MailMate (1.14r6030) Message-ID: <922F6794-1C32-4862-8A67-90D4F7DBC474@nvidia.com> In-Reply-To: <20240425170704.3379492-1-ryan.roberts@arm.com> References: <20240425170704.3379492-1-ryan.roberts@arm.com> Content-Type: multipart/signed; boundary="=_MailMate_CF454BE4-5E59-4757-A4E1-3A9B44627BE9_="; micalg=pgp-sha512; protocol="application/pgp-signature" X-ClientProxiedBy: MN2PR03CA0023.namprd03.prod.outlook.com (2603:10b6:208:23a::28) To DS7PR12MB5744.namprd12.prod.outlook.com (2603:10b6:8:73::18) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS7PR12MB5744:EE_|DS0PR12MB9398:EE_ X-MS-Office365-Filtering-Correlation-Id: 084df328-181f-4b62-d20f-08dc6559b0bc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|366007|1800799015; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?ioYAtmwI85yyNYbbSjFIiPtJYSKeR+g2zruibJkK4Too35NJX/8IzXVNWmVU?= =?us-ascii?Q?ldeKZBwg8WdBdOOMj5gdfjbSPXzBdugm+v791KueVuvcmRv9ohmy6HUdH+bY?= =?us-ascii?Q?KQj/PlD4YZouCJxIprf7JStHUNW7jiZ8hMT6KFJzprGMO/aT4bTpldgMEMjR?= =?us-ascii?Q?qNNR6LDeVbDnLfwLexsF41ZpAvaDbfFpnIE7Iykr0OI59zODlFyD2VE96ELE?= =?us-ascii?Q?cnVxi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yA/WpP1lLxYsoSg3yrdITX5gORNE?= =?us-ascii?Q?GsgGpzj35h6cEI3vSRov9hRkrAcqQFpCBCNz/UQDFvkM+0wqyT9hkLLFJLCh?= =?us-ascii?Q?liAVLV/Zj/6ljXFJkFXud65TkcsAp6jUAlzRTed0ea9BXlca/cvZgt6vntPh?= =?us-ascii?Q?FafhV7+grAQH9J01Y9XQk9EAI+W1rNoPNROnmIqpug=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR12MB5744.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(366007)(1800799015);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?FaKLsoOeGq9fKiy1I+70Vj20cINsKzoN5Z4RlKIZ9y2cniIJ+Q5OsX9XGaEr?= =?us-ascii?Q?YdUkDfsEfumqHSCr2T8x1eNghtjpi9qI119Zlz0IG8yQTE5FZlEDnFzaH6ZX?= =?us-ascii?Q?tzyMXnNqAsbiWkUsI7Kg6K55Wx7EEZmXaD3nqlGufv8frmreK2mSuq6BGoJj?= =?us-ascii?Q?WQ5YCpmgdYFEI8120LHy2Tpq2GGgCks+/6ywKhup4EpGLWYXASVg2jkLwHdG?= =?us-ascii?Q?Jub8aSDYzvRYbQ/dMzq5Dg1yqBq+JWFh0rHBBAOGB8UyMO/rn353Pg1oPtVX?= =?us-ascii?Q?Oec0KLxsqICv7KOMl7HFbBdTIbyELK0pM/JPpSvliqRiNg/psrN8Lm+fu0JY?= =?us-ascii?Q?fMNfh/hYexhEGKr+sxwy1uDC0cTvSIqbO6Pm5oznXWjXxsjYlEjmtEABp4Yn?= =?us-ascii?Q?8cavLLMIY68uB7sS+AXrLO/wVgxrePXxoK6hDWpmPG8UGOzWwf2PSotX14f4?= =?us-ascii?Q?zD2yDCzdOS6dhIOQfL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-ascii?Q?Y8t561+b9eyjaBDkYzv2+84EJZ1hW0s2wiLRaYwUplfmgm5wfgluKphAjvbd?= =?us-ascii?Q?KUZ06JKMCL8xMkms7PJ/j3SuiVF+3rxwI5FFx96DMFLabEg+h74AJL8Wr0M8?= =?us-ascii?Q?aR/29rwx/Y+WgRBvQ7QEeFJfUHVy+4s0Gt6V/xQ/rZO7+YuxBKF4X9FYiLZO?= =?us-ascii?Q?1V7RL013QpjSKoNRm0w=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 084df328-181f-4b62-d20f-08dc6559b0bc X-MS-Exchange-CrossTenant-AuthSource: DS7PR12MB5744.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2024 18:58:27.3177 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2+BRXiqJAZdqCDJin21rR+hqeOljngrT6Wmk2DLQAZuUBamwYzokXAEpoGnXxW6i X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB9398 --=_MailMate_CF454BE4-5E59-4757-A4E1-3A9B44627BE9_= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable +Anshuman, who changed pmd_present() semantics. See: https://lore.kernel.org/all/1599627183-14453-2-git-send-email-anshuman.kh= andual@arm.com/ and commit b65399f6111b ("arm64/mm: Change THP helpers to comply with generic MM semantics") On 25 Apr 2024, at 13:07, Ryan Roberts wrote: > __split_huge_pmd_locked() can be called for a present THP, devmap or > (non-present) migration entry. It calls pmdp_invalidate() > unconditionally on the pmdp and only determines if it is present or not= > based on the returned old pmd. This is a problem for the migration entr= y > case because pmd_mkinvalid(), called by pmdp_invalidate() must only be > called for a present pmd. > > On arm64 at least, pmd_mkinvalid() will mark the pmd such that any > future call to pmd_present() will return true. And therefore any But pmd_mkinvalid() on x86 does not behave so. Maybe we should fix pmd_mkinvalid() on arm64 by not setting PMD_PRESENT_INVALID when the entry is invalid already. And add a test in mm/debug_vm_pgtable.c. I notice that x86, risc-v, mips behave the same. loongarch also has _PAGE_PRESENT_INVALID bit set during pmd_mkinvalid(), but its pmd_present() makes sure _PAGE_HUEG is set before checks _PAGE_PRESENT_IN= VALID. So it is not a problem for loongarch. Add Huacai to confirm this. Maybe pmd_present() on arm64 can do that too? > lockless pgtable walker could see the migration entry pmd in this state= > and start interpretting the fields as if it were present, leading to > BadThings (TM). GUP-fast appears to be one such lockless pgtable walker= =2E > I suspect the same is possible on other architectures. > > Fix this by only calling pmdp_invalidate() for a present pmd. And for > good measure let's add a warning to the generic implementation of > pmdp_invalidate(). I've manually reviewed all other > pmdp_invalidate[_ad]() call sites and believe all others to be > conformant. > > This is a theoretical bug found during code review. I don't have any > test case to trigger it in practice. > > Fixes: 84c3fc4e9c56 ("mm: thp: check pmd migration entry in common path= ") > Signed-off-by: Ryan Roberts > --- > > Applies on top of v6.9-rc5. Passes all the mm selftests on arm64. > > Thanks, > Ryan > > > mm/huge_memory.c | 5 +++-- > mm/pgtable-generic.c | 2 ++ > 2 files changed, 5 insertions(+), 2 deletions(-) > > diff --git a/mm/huge_memory.c b/mm/huge_memory.c > index 89f58c7603b2..80939ad00718 100644 > --- a/mm/huge_memory.c > +++ b/mm/huge_memory.c > @@ -2513,12 +2513,12 @@ static void __split_huge_pmd_locked(struct vm_a= rea_struct *vma, pmd_t *pmd, > * for this pmd), then we flush the SMP TLB and finally we write the > * non-huge version of the pmd entry with pmd_populate. > */ > - old_pmd =3D pmdp_invalidate(vma, haddr, pmd); > > - pmd_migration =3D is_pmd_migration_entry(old_pmd); > + pmd_migration =3D is_pmd_migration_entry(*pmd); > if (unlikely(pmd_migration)) { > swp_entry_t entry; > > + old_pmd =3D *pmd; > entry =3D pmd_to_swp_entry(old_pmd); > page =3D pfn_swap_entry_to_page(entry); > write =3D is_writable_migration_entry(entry); > @@ -2529,6 +2529,7 @@ static void __split_huge_pmd_locked(struct vm_are= a_struct *vma, pmd_t *pmd, > soft_dirty =3D pmd_swp_soft_dirty(old_pmd); > uffd_wp =3D pmd_swp_uffd_wp(old_pmd); > } else { > + old_pmd =3D pmdp_invalidate(vma, haddr, pmd); > page =3D pmd_page(old_pmd); > folio =3D page_folio(page); > if (pmd_dirty(old_pmd)) { > diff --git a/mm/pgtable-generic.c b/mm/pgtable-generic.c > index 4fcd959dcc4d..74e34ea90656 100644 > --- a/mm/pgtable-generic.c > +++ b/mm/pgtable-generic.c > @@ -198,6 +198,7 @@ pgtable_t pgtable_trans_huge_withdraw(struct mm_str= uct *mm, pmd_t *pmdp) > pmd_t pmdp_invalidate(struct vm_area_struct *vma, unsigned long addres= s, > pmd_t *pmdp) > { > + VM_WARN_ON(!pmd_present(*pmdp)); > pmd_t old =3D pmdp_establish(vma, address, pmdp, pmd_mkinvalid(*pmdp)= ); > flush_pmd_tlb_range(vma, address, address + HPAGE_PMD_SIZE); > return old; > @@ -208,6 +209,7 @@ pmd_t pmdp_invalidate(struct vm_area_struct *vma, u= nsigned long address, > pmd_t pmdp_invalidate_ad(struct vm_area_struct *vma, unsigned long add= ress, > pmd_t *pmdp) > { > + VM_WARN_ON(!pmd_present(*pmdp)); return pmdp_invalidate(vma, addres= s, pmdp); > } > #endif > -- > 2.25.1 -- Best Regards, Yan, Zi --=_MailMate_CF454BE4-5E59-4757-A4E1-3A9B44627BE9_= Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQJDBAEBCgAtFiEE6rR4j8RuQ2XmaZol4n+egRQHKFQFAmYqp9EPHHppeUBudmlk aWEuY29tAAoJEOJ/noEUByhUDp4P/jxTdrH/3DOdmf6Y5bgVzQyskvkbkUdpDKiN HCHL71bGxG/6veSxdzTpB2pkFS8dxHbbZsJyZ9ZNEBtTRnfKcH5++yYaZiqYWQ6P UScgkNighIFNX8lYOAGdtp+n83RFRYiglhDsoLARipr4K4lD/8HLJs4DgBG3p5sa 4OUncWdhH9tFtMz3xdtAxA1BsNHCRSoRNH7VzXbgaSgnABkOcOmD2w5zz+arZpRW V5BBHTDTAQeDf0W0encZ7YeCcC+5zq/eh0fKGhw7piadNlBq9JZGRQWu4WFsdxYp /qVCujjEH31NnPm9LyDVxck2Ayo/kjD45fH38I5qq9jajT30D4bsMxtoo9gNR5/S htJaocFgLwtbtfm9Q5NQ2D5YI920NCJh6rJWtcGY5VAqkVhVtxaae025ubsngS1r D87cWzNriZKvGuNDZ8SOeklxbK5c9WGZpy1q5YTzPi0ybtM7UQYfAU94I46Yo2Vs IOw5ZAJv/8FYVAmzpn57fk/ZIcaw+33atCbOL9w7bEU6a5fnJd+lXpS7LpP7mmK8 mYLuCdz4FqQLTWFDNhiA09QhihYRhwRTCymDbozOgRW+x7cfBi9aCKh/slaK73Lo +doI27PM7vozQwAzdPpOe+ExYazIK1dgvRl+2evsO4YZB1HqZvZXki6hJrOqF/AM 3IZVc0c4 =PGBV -----END PGP SIGNATURE----- --=_MailMate_CF454BE4-5E59-4757-A4E1-3A9B44627BE9_=--