From: Andrew Morton <akpm@linux-foundation.org>
To: "David Hildenbrand (Arm)" <david@kernel.org>
Cc: "Kiryl Shutsemau" <kas@kernel.org>,
"Lorenzo Stoakes (ARM)" <ljs@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
"Vlastimil Babka" <vbabka@kernel.org>,
"Mike Rapoport" <rppt@kernel.org>,
"Suren Baghdasaryan" <surenb@google.com>,
"Michal Hocko" <mhocko@suse.com>,
"David Rientjes" <rientjes@google.com>,
"Shakeel Butt" <shakeel.butt@linux.dev>,
"Jann Horn" <jannh@google.com>,
"Pedro Falcato" <pfalcato@suse.de>,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
"Jan Kara" <jack@suse.cz>, "Nhat Pham" <nphamcs@gmail.com>,
"Johannes Weiner" <hannes@cmpxchg.org>, "Zi Yan" <ziy@nvidia.com>,
"Matthew Brost" <matthew.brost@intel.com>,
"Joshua Hahn" <joshua.hahnjy@gmail.com>,
"Byungchul Park" <byungchul@sk.com>,
"Gregory Price" <gourry@gourry.net>,
"Ying Huang" <ying.huang@linux.alibaba.com>,
"Alistair Popple" <apopple@nvidia.com>,
"Usama Arif" <usama.arif@linux.dev>,
"Kairui Song" <kasong@tencent.com>,
"Balbir Singh" <balbirs@nvidia.com>,
"Jérôme Glisse" <jglisse@redhat.com>,
"Yu-cheng Yu" <yu-cheng.yu@intel.com>,
"Dave Hansen" <dave.hansen@linux.intel.com>,
"Dennis Zhou" <dennis@kernel.org>, "Tejun Heo" <tj@kernel.org>,
"Christoph Lameter" <cl@gentwo.org>,
"Peng Fan" <peng.fan@nxp.com>, "Josef Bacik" <jbacik@fb.com>,
"Chris Mason" <mason@kernel.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org,
"Borislav Petkov (AMD)" <bp@alien8.de>,
"Mark Brown" <broonie@kernel.org>,
"Dennis Zhou (Facebook)" <dennisszhou@gmail.com>,
"Rick Edgecombe" <rick.p.edgecombe@intel.com>,
"Josef Bacik" <josef@toxicpanda.com>,
stable@vger.kernel.org
Subject: Re: [PATCH 04/13] mm/migrate_device: allocate THP deferred split heads
Date: Wed, 11 Nov 2026 14:18:48 -0800 [thread overview]
Message-ID: <20261111141848.11762f60e737c97c3a239fe1@linux-foundation.org> (raw)
In-Reply-To: <95682ddd-d200-4827-a009-77ee59d14f86@kernel.org>
On Wed, 11 Nov 2026 20:40:17 +0100 "David Hildenbrand (Arm)" <david@kernel.org> wrote:
> On 11/11/26 20:30, Kiryl Shutsemau wrote:
> > On Wed, Nov 11, 2026 at 06:13:18PM +0000, Lorenzo Stoakes (ARM) wrote:
> >> From: Josef Bacik <josef@toxicpanda.com>
> >>
> >> A THP that device migration maps into an empty PMD can end up on the wrong
> >> deferred split list when it is later queued for a deferred split.
> >>
> >> This occurs if the memcg has no heads yet (resulting in a warning if
> >> CONFIG_DEBUG_VM is set), where deferred_split_folio() will then queue the
> >> folio on the parent's list.
> >>
> >> Once a later THP fault in the same memcg allocates the heads,
> >> __folio_unqueue_deferred_split() and the split path resolve folio_memcg()
> >> to the memcg's own, now existing, list and take its lock. They then
> >> list_del_init() a folio that is linked on the parent's list, racing with
> >> anything holding the parent's lock, and both lists' nr_items counts go
> >> wrong.
> >>
> >> Resolve the issue by calling folio_memcg_alloc_deferred() after the charge
> >> in migrate_vma_insert_huge_pmd_page() and falling back like a failed charge
> >> if that fails, as __do_huge_pmd_anonymous_page() does.
> >>
> >> This was originally discovered by code inspection.
> >>
> >> Fixes: fafaeceb89a5 ("mm: switch deferred split shrinker to list_lru")
> >> Cc: <stable@vger.kernel.org>
> >> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> >> [ ljs: tweak commit message, remove unnecessary comment ]
> >> Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
> >
> > mm-new already has this: "mm/migrate_device: allocate deferred split
> > sublists for new huge folios", same Fixes: tag.
> >
> > Hm?
>
> I assume that's one from Andrew that he created after a security report (where I
> was CCed and the reporter didn't follow up), but he never sent it out officially.
oops, that's supposed to be commented out.
> So let's review this one here. It's supposed to go through my tree either way :)
Patches are identical. So I can say
Tested-by: Andrew Morton <akpm@linux-foundation.org>
Based on Ada's supplied fix and reproducer. The report uses CONFIG_TEST_HMM
and privileged guest setup; ordinary-user reachability through a production
driver has not been established.
Built matching pre-patch and patched 7.4.0-rc1 kernels and ran the same
one-folio HMM migration test in each. The x86-64 KVM guest had 8 GiB RAM,
one virtual NUMA node and four single-threaded vCPUs in one virtual socket.
CONFIG_TEST_HMM, CONFIG_MEMCG, CONFIG_SHRINKER_DEBUG and CONFIG_DEBUG_LIST
were enabled; KASAN was disabled.
Both kernels migrated 512 pages to device memory and one huge folio back.
After a partial unmap, normal THP allocation and freeing the migrated
folio, the pre-patch kernel still reported one deferred-split entry on
the root list. The patched kernel reported no entry. Both one-folio
tests completed without a panic or warning.
In two further bounded pre-patch guest runs, eight migrated folios were
queued on the root deferred-split list. Both runs produced DEBUG_LIST
"list_del corruption" warnings during folio release, with
__folio_unqueue_deferred_split() in the trace. In the second run the
warning occurred during a timed scan/removal trial. Neither run crashed
or hung; no delay or fault injection was needed.
The patched guest did not create misplaced root-list entries, so the
concurrent scan test stopped at its setup check rather than running
identical timed trials. These tests do not establish unprivileged
production-driver reachability or privilege escalation.
next prev parent reply other threads:[~2026-11-11 22:18 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 18:13 [PATCH 00/13] mm: batch of (urgentish?) fixes in oomk, cachestat, dev-migrate, percpu Lorenzo Stoakes (ARM)
2026-11-11 18:13 ` [PATCH 01/13] mm/mmap: free gathered pages before MMF_OOM_SKIP Lorenzo Stoakes (ARM)
2026-11-11 18:13 ` [PATCH 02/13] mm: cachestat: count each page only once Lorenzo Stoakes (ARM)
2026-11-11 18:13 ` [PATCH 03/13] mm: cachestat: restart the walk after each entry Lorenzo Stoakes (ARM)
2026-11-11 18:13 ` [PATCH 04/13] mm/migrate_device: allocate THP deferred split heads Lorenzo Stoakes (ARM)
2026-11-11 19:30 ` Kiryl Shutsemau
2026-11-11 19:40 ` David Hildenbrand (Arm)
2026-11-11 22:18 ` Andrew Morton [this message]
2026-11-11 18:13 ` [PATCH 05/13] mm/migrate_device: don't collect a range twice Lorenzo Stoakes (ARM)
2026-11-11 18:13 ` [PATCH 06/13] mm/migrate_device: don't let go of the fault page Lorenzo Stoakes (ARM)
2026-11-11 18:13 ` [PATCH 07/13] mm/migrate_device: look up fault folio after a split Lorenzo Stoakes (ARM)
2026-11-11 18:13 ` [PATCH 08/13] mm/migrate_device: fix ksmd oops on a migrated KSM page Lorenzo Stoakes (ARM)
2026-11-11 21:54 ` David Hildenbrand (Arm)
2026-11-11 18:13 ` [PATCH 09/13] mm/migrate_device: fix use-after-free of the anon rmap Lorenzo Stoakes (ARM)
2026-11-11 18:13 ` [PATCH 10/13] mm/migrate_device: refuse to migrate shadow stacks Lorenzo Stoakes (ARM)
2026-11-11 21:15 ` Balbir Singh
2026-11-11 18:13 ` [PATCH 11/13] percpu: fix contig hints that are too low Lorenzo Stoakes (ARM)
2026-11-11 18:13 ` [PATCH 12/13] percpu: search the whole reserved chunk Lorenzo Stoakes (ARM)
2026-11-11 18:13 ` [PATCH 13/13] percpu: queue the balance work on an unbound workqueue Lorenzo Stoakes (ARM)
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=20261111141848.11762f60e737c97c3a239fe1@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=balbirs@nvidia.com \
--cc=bp@alien8.de \
--cc=broonie@kernel.org \
--cc=byungchul@sk.com \
--cc=cl@gentwo.org \
--cc=dave.hansen@linux.intel.com \
--cc=david@kernel.org \
--cc=dennis@kernel.org \
--cc=dennisszhou@gmail.com \
--cc=gourry@gourry.net \
--cc=hannes@cmpxchg.org \
--cc=jack@suse.cz \
--cc=jannh@google.com \
--cc=jbacik@fb.com \
--cc=jglisse@redhat.com \
--cc=josef@toxicpanda.com \
--cc=joshua.hahnjy@gmail.com \
--cc=kas@kernel.org \
--cc=kasong@tencent.com \
--cc=liam@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mason@kernel.org \
--cc=matthew.brost@intel.com \
--cc=mhocko@suse.com \
--cc=nphamcs@gmail.com \
--cc=peng.fan@nxp.com \
--cc=pfalcato@suse.de \
--cc=rick.p.edgecombe@intel.com \
--cc=rientjes@google.com \
--cc=rppt@kernel.org \
--cc=shakeel.butt@linux.dev \
--cc=stable@vger.kernel.org \
--cc=surenb@google.com \
--cc=tj@kernel.org \
--cc=usama.arif@linux.dev \
--cc=vbabka@kernel.org \
--cc=willy@infradead.org \
--cc=ying.huang@linux.alibaba.com \
--cc=yu-cheng.yu@intel.com \
--cc=ziy@nvidia.com \
/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
all inboxes | Powered by JetHome®