From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8CB06606A337 for ; Thu, 3 Dec 2026 12:30:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=f82gml7j Received: by kanga.kvack.org (Postfix) id D90B16B05BE; Thu, 3 Dec 2026 07:29:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D1A336B05BF; Thu, 3 Dec 2026 07:29:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BE3086B05C0; Thu, 3 Dec 2026 07:29:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 8E39F6B05BE for ; Thu, 3 Dec 2026 07:29:46 -0500 (EST) Received: from smtpin04.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 47F97120666 for ; Thu, 3 Dec 2026 12:29:44 +0000 (UTC) X-FDA: 85502603088.04.C28F829 Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf18.hostedemail.com (Postfix) with ESMTP id A4D571C0008 for ; Thu, 3 Dec 2026 12:29:42 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=f82gml7j; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf18.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796300982; b=eflKB2WOYyby/0IRR/KvQ/7YZaturgG6mD36Bt/+9iNk0qyIvUZcVyT2xsWRMl5viVknbF EERwOaNR+EWLe//7iJQ4j/bB0D21htWzHvBAB9hhPHA8VyDy7CoWYYz55M50cIylRxPIYl 29AE337PMFwLjZpN+44rG+EK8EiX6/w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796300982; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=HqNwVWiZkDAVrnqaBS9VWEIzKVeDeWonqGwr6RhlpS4=; b=4W1WYs0BG4Lr8sIRKrCemDWtZFN/HWJRpzoEBkdeqoZ4XJeyUpYfD8wyGosPKfrBeOQ6JO vrpYBkXOJqWPHlcIiCUMzaMEhJVl80snwiE8CYsysWgO9tJYqHMa7D0QDBIkI03dZZDLp4 tHpF7cIHsaktMXoop7lWu4cpT1C/DOU= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=f82gml7j; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf18.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 3BC6560E17; Thu, 3 Dec 2026 12:29:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 137321F000C1; Thu, 3 Dec 2026 12:29:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796300981; bh=HqNwVWiZkDAVrnqaBS9VWEIzKVeDeWonqGwr6RhlpS4=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=f82gml7jXfSaWV2334TG9J75kdzm7/TrlabLo5HKzNFYry281RzDe0GsZ+43Myoo4 d3pptcW5PM5ksiZozuJs0fynUNbLZHYyr1dmOSctH62SsjMIk96e0+K+98fODYwjb1 o+HV/wBA7KgE1e++ilLXSNEhn39UhGoNlzJMomujHmtFqhC9QCEUgh3DbwY8b0/0no taCGBIiABwbdtz+F5n0in1lqihVKB32/lgdeqn4qzKSJgZQ6LVNUZVweONmBShMqyW KKOQUfksN6wOQNpyY1bdDoEjstHXV3YKi1x9BlUtC1KtdRDlAR7BDLLR4sRh3ACVMI P6lC1PqUHHxGQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 30/35] mm/hugetlb: unshare PMDs of a split VMA if allocating its lock fails Reply-To: sashiko-reviews@lists.linux.dev To: =?utf-8?b?RGF2aWQgSGlsZGVuYnJhbmQgKEFybSk=?= , "Muchun Song" , "Oscar Salvador" , "Andrew Morton" , "Hongfu Li" , "Jinmeng Zhou" , "Mina Almasry" , "Davidlohr Bueso" , "Naoya Horiguchi" , "Liam R. Howlett" , "Vlastimil Babka" , "Mike Rapoport" , "Michal Hocko" , "Jonathan Corbet" , "Shuah Khan" , "Randy Dunlap" , "Vivek Kasireddy" , "Mel Gorman" , "Hugh Dickins" , "Baolin Wang" , "Dave Airlie" , "Jason Gunthorpe" , "Andy Whitcroft" , "Roman Gushchin" , "Barry Song" , "Andrea Arcangeli" , "Lorenzo Stoakes" , "Suren Baghdasaryan" , "Shakeel Butt" , "Pedro Falcato" , "Jann Horn" , "Guillaume Morin" , "Yang Shi" , "James Houghton" , "Rik van Riel" , "Harry Yoo" , "Lance Yang" , "Axel Rasmussen" , "Peter Xu" , "Sasha Levin" , "Kiryl Shutsemau" , "Christian Brauner" , =?utf-8?b?U3RldmVuIFJvc3RlZHQgKEdvb2ds?= =?utf-8?b?ZSk=?= , "Hongbo Li" , "Gregory Price" , "Zi Yan" , "Joshua Hahn" , "Rakie Kim" , "Ying Huang" , "Matthew Brost" , "Byungchul Park" , "Alistair Popple" , "Andi Kleen" , "David Rientjes" , "Joern Engel" , "Aneesh Kumar K.V" Cc: linux-mm@kvack.org, "Gerd Hoffmann" , "Johannes Weiner" , "Chris Mason" , "Jiaqi Yan" In-Reply-To: <20261203-hugetlb_fixes_2-v2-30-9bbeabb555d2@kernel.org> References: <20261203-hugetlb_fixes_2-v2-0-9bbeabb555d2@kernel.org> <20261203-hugetlb_fixes_2-v2-30-9bbeabb555d2@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 12:29:38 +0000 X-Rspam-User: X-Rspamd-Queue-Id: A4D571C0008 X-Stat-Signature: kkhodj59hpt8nf4k7h845js9477cq9rr X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Rspamd-Server: rspam02 X-HE-Tag: 1796300982-422082 X-HE-Meta: U2FsdGVkX1+3RBvc49L9GwcvKUjLLQCsgJmiHLoCGKmCZejQFQ9KIuxHQVLv0XX9RxXS/CyAMBhv3iEldq59E3lu45DjQ1wrmOA2RUmDm5V+OxGKJmcM7hgHA5v6ck/0tmPgTcWrHq6FsVgzDvyDs/1x1ZJIO9aQTv2IEt0KVNRJ9eqZt1nRFfSfRMOq1+izMSPQ6s2g1jlnRVIh1QV3Scn4JK2dx9iEWKovvLV2dY4kpx+UETUEkfhOJZqZTP/iLxaCnWWsRsRIKZJ4kb+kcJvWgs0K53apbbsjp4qyWLDnqNjb0u8YlF1mmz+frSUC701xQ9TWAw4uekoVbitLjs5++VgQUFkmPwS0+khAlziwlMpkm70IQDCoPhFbva5Ld0pVNCC2PBA1//OjA17yYfj2Y24ZP9sg+t29mMSBsMIjlHFa3sLjdP2YJDkHeTSj0FvRBcC9QzyMW2DVPBphXVjsHKDnTxZcjvL5Q2V+rasoSQl0MPiwrcYvInwlu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zsmcYKr6wzzGiB0P2EIdvaZiCYQd4ZNIwLrIzOsEV3BNLeKvBVAE371o+QbxNieslYA4dIDZykW661lKLp/ldOjuEBQIK4bldt42uqj3yGywFO3kFsAu9CQZSkMfE9KeUDXJPI/AMOBASwiXTqlRMk6ypvezr1hfp61aEQkEbDpfHfNpooIWoLxzJrZ2Ljqbgrf6QSgrRZSVtC7/DZnHn+yAXdv0Xm+ndr5LlIbcJguJLWue7gDWDmQSY/fYSg+2N1cd28TA0AnbcWM5lNnTUAsLN+0bg9K2DntkdV3NYNZmmKadab8E1QhTSuFYBuzo41tygkxQAsnWpfnrA2o4oSU= Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] mm/hugetlb: hugetlb_split() sleeps in atomic context on ARM/PA-RISC - [Medium] mm/hugetlb: ALIGN() overflow in hugetlb_split() wraps start to 0 on s390 -- commit 75f9184dc32acb09010de15401fba05ecb4fa173 Author: Chris Mason mm/hugetlb: unshare PMDs of a split VMA if allocating its lock fails This commit updates hugetlb_split() to take the newly split VMA, return early when the original VMA has no shareable hugetlb VMA lock, and unshare PMDs across the new VMA if allocating its hugetlb VMA lock failed. > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index e529994ee9f73..1c7259d80615e 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c [ ... ] > @@ -4920,8 +4921,13 @@ void hugetlb_split(struct vm_area_struct *vma, uns= igned long addr) > * walks (except hardware and gup_fast()). > */ > vma_assert_write_locked(vma); > + vma_assert_write_locked(new); > i_mmap_assert_write_locked(vma->vm_file->f_mapping); > =20 > + /* Shared PMDs require a hugetlb VMA lock. */ > + if (!__vma_shareable_lock(vma)) > + return; [Severity: High] Can hugetlb_split() sleep in atomic context on architectures without PMD sharing, such as ARM32 LPAE and PA-RISC? In __split_vma(), vma_prepare() holds flush_dcache_mmap_lock(vp->mapping) across hugetlb_split(). On ARM and PA-RISC this expands to xa_lock_irq(&mapping->i_pages), holding a spinlock with IRQs disabled. Neither architecture enables CONFIG_HUGETLB_PMD_PAGE_TABLE_SHARING, yet __vma_shareable_lock(vma) is still true for VM_MAYSHARE VMAs. Both the existing unaligned-split path and the new !__vma_shareable_lock(new) path then reach hugetlb_unshare_pmds() with xa_lock_irq held. hugetlb_unshare_pmds() calls mmu_notifier_invalidate_range_start() (which calls might_sleep() and sleepable notifiers), hits WARN_ON(arch_irqs_disabled()) in flush_cache_range() on SMP PA-RISC, and takes huge_pte_lock() inside i_pages.xa_lock. Returning early when !IS_ENABLED(CONFIG_HUGETLB_PMD_PAGE_TABLE_SHARING) would avoid this. [ ... ] > @@ -4940,6 +4946,15 @@ void hugetlb_split(struct vm_area_struct *vma, uns= igned long addr) > hugetlb_unshare_pmds(vma, floor, ceil, /* take_locks =3D */ false); > } > } > + > + /* > + * If we failed to allocate the hugetlb VMA lock, unshare everything > + * that the new VMA covers. > + */ > + if (!__vma_shareable_lock(new)) > + hugetlb_unshare_pmds(new, ALIGN(new->vm_start, PUD_SIZE), > + ALIGN_DOWN(new->vm_end, PUD_SIZE), > + /* take_locks =3D */ false); > } [Severity: Medium] Can ALIGN(new->vm_start, PUD_SIZE) overflow to 0 on 64-bit s390? On 64-bit s390, TASK_SIZE_MAX is 0xfffffffffffff000, PUD_SIZE is 2 GiB, and HPAGE_SIZE is 1 MiB. Splitting a shared 1 MiB hugetlb VMA in the top 2 GiB when hugetlb_vma_lock_alloc(new) fails wraps ALIGN(new->vm_start, PUD_SIZE) to 0 while ALIGN_DOWN(new->vm_end, PUD_SIZE) evaluates to 0xffffffff8000000= 0. hugetlb_unshare_pmds() then sees start < end, invalidates MMU notifiers over [0, 0xffffffff80000000), and loops 2^33 - 1 times without cond_resched() under mmap_write_lock and i_mmap_lock_write, causing a soft lockup and RCU stall. If the process also has an unrelated 2 GiB EDAT2 hugetlb mapping in that range, s390 huge_pte_offset() lacks a pud_leaf() check for PMD_SIZE, so huge_pte_lock() misinterprets the data folio's folio->private as ptdesc->ptl and can crash or corrupt folio->private. Guarding hugetlb_split() on CONFIG_HUGETLB_PMD_PAGE_TABLE_SHARING and checking for ALIGN() wraparound (start < new->vm_start) would prevent this. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203-hugetlb_fi= xes_2-v2-0-9bbeabb555d2@kernel.org?part=3D30