From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Peter Xu <peterx@redhat.com>, Oscar Salvador <osalvador@suse.de>,
Ackerley Tng <ackerleytng@google.com>,
Breno Leitao <leitao@debian.org>,
Muchun Song <muchun.song@linux.dev>,
Naoya Horiguchi <nao.horiguchi@gmail.com>,
Rik van Riel <riel@surriel.com>,
Roman Gushchin <roman.gushchin@linux.dev>,
Andrew Morton <akpm@linux-foundation.org>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.12.y 1/5] mm/hugetlb: stop using avoid_reserve flag in fork()
Date: Wed, 4 Nov 2026 10:58:27 -0500 [thread overview]
Message-ID: <20261104155731.3920547-1-sashal@kernel.org> (raw)
In-Reply-To: <2026110456-remix-oversold-9ee1@gregkh>
From: Peter Xu <peterx@redhat.com>
[ Upstream commit be8d7314b18ede1c6cdebbb982c9659020e2f1f2 ]
When fork() and stumble on top of a dma-pinned hugetlb private page, CoW
must happen during fork() to guarantee dma coherency.
In this specific path, hugetlb pages need to be allocated for the child
process. Stop using avoid_reserve=1 flag here: it's not required to be
used here, as dest_vma (which is destined to be a MAP_PRIVATE hugetlb vma)
will have no private vma resv map, and that will make sure it won't be
able to use a vma reservation later.
No functional change intended with this change. Said that, it's still
wanted to do this, so as to reduce the usage of avoid_reserve to the only
one user, which is also why this flag was introduced initially in commit
04f2cbe35699 ("hugetlb: guarantee that COW faults for a process that
called mmap(MAP_PRIVATE) on hugetlbfs will succeed"). I don't see whoever
else should set it at all.
Further patch will clean up resv accounting based on this.
Link: https://lkml.kernel.org/r/20250107204002.2683356-3-peterx@redhat.com
Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
Cc: Ackerley Tng <ackerleytng@google.com>
Cc: Breno Leitao <leitao@debian.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>
Cc: Rik van Riel <riel@surriel.com>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Stable-dep-of: 824cc56bf43c ("mm/hugetlb: fix use-after-free of a new anon folio")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
mm/hugetlb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 80f25497b54f2..a1dc40a06eb0a 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -5366,7 +5366,7 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
spin_unlock(src_ptl);
spin_unlock(dst_ptl);
/* Do not use reserve as it's private owned */
- new_folio = alloc_hugetlb_folio(dst_vma, addr, 1);
+ new_folio = alloc_hugetlb_folio(dst_vma, addr, 0);
if (IS_ERR(new_folio)) {
folio_put(pte_folio);
ret = PTR_ERR(new_folio);
--
2.53.0
next prev parent reply other threads:[~2026-11-04 15:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 13:39 FAILED: patch "[PATCH] mm/hugetlb: fix use-after-free of a new anon folio" failed to apply to 6.12-stable tree gregkh
2026-11-04 15:58 ` Sasha Levin [this message]
2026-11-04 15:58 ` [PATCH 6.12.y 2/5] mm/hugetlb: rename avoid_reserve to cow_from_owner Sasha Levin
2026-11-04 15:58 ` [PATCH 6.12.y 3/5] mm,hugetlb: change mechanism to detect a COW on private mapping Sasha Levin
2026-11-04 15:58 ` [PATCH 6.12.y 4/5] mm,hugetlb: sort out folio locking in the faulting path Sasha Levin
2026-11-04 15:58 ` [PATCH 6.12.y 5/5] mm/hugetlb: fix use-after-free of a new anon folio Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261104155731.3920547-1-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=ackerleytng@google.com \
--cc=akpm@linux-foundation.org \
--cc=leitao@debian.org \
--cc=muchun.song@linux.dev \
--cc=nao.horiguchi@gmail.com \
--cc=osalvador@suse.de \
--cc=peterx@redhat.com \
--cc=riel@surriel.com \
--cc=roman.gushchin@linux.dev \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox