From: "Vlastimil Babka (SUSE)" <vbabka@kernel.org>
To: Zi Yan <ziy@nvidia.com>,
Andrew Morton <akpm@linux-foundation.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>,
Brendan Jackman <jackmanb@google.com>,
Johannes Weiner <hannes@cmpxchg.org>,
David Hildenbrand <david@kernel.org>,
Lorenzo Stoakes <ljs@kernel.org>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
"Liam R. Howlett" <liam@infradead.org>,
Nico Pache <npache@redhat.com>,
Ryan Roberts <ryan.roberts@arm.com>, Dev Jain <dev.jain@arm.com>,
Barry Song <baohua@kernel.org>, Lance Yang <lance.yang@linux.dev>,
Mike Rapoport <rppt@kernel.org>, Dennis Zhou <dennis@kernel.org>,
Tejun Heo <tj@kernel.org>, Christoph Lameter <cl@gentwo.org>,
Alistair Popple <apopple@nvidia.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 4/5] mm/page_alloc: make sure tail_page->private is zero at page free time
Date: Thu, 9 Jul 2026 10:24:03 +0200 [thread overview]
Message-ID: <9fc67666-ac70-4d03-8836-5f8a9f5f1ff6@kernel.org> (raw)
In-Reply-To: <20260703-keep-subpage-private-zero-at-free-v2-4-2970fe777dd6@nvidia.com>
On 7/3/26 15:47, Zi Yan wrote:
> Any code using tail_page->private of a folio, a compound page or a
> high-order page is supposed to reset it after use, otherwise ->private data
> can leak to new page user and cause unexpected issues. Add a bad_page()
> check at page free path for it.
>
> Signed-off-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Nit:
> ---
> mm/page_alloc.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 762d9b6bc792f..723a52dfc80f6 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -1376,15 +1376,22 @@ static __always_inline bool __free_pages_prepare(struct page *page,
> #endif
> }
> for (i = 1; i < (1 << order); i++) {
> + struct page *tail_page = page + i;
> +
> if (compound)
> - bad += free_tail_page_prepare(page, page + i);
> + bad += free_tail_page_prepare(page, tail_page);
> if (is_check_pages_enabled()) {
> - if (free_page_is_bad(page + i)) {
> + if (free_page_is_bad(tail_page)) {
> bad++;
> continue;
> }
> }
> - (page + i)->flags.f &= ~PAGE_FLAGS_CHECK_AT_PREP;
> + tail_page->flags.f &= ~PAGE_FLAGS_CHECK_AT_PREP;
> + if (is_check_pages_enabled() && tail_page->private) {
> + bad_page(tail_page, "nonzero private");
> + bad++;
> + continue;
It could be moved to the already existing is_check_pages_enabled() block
above. The flags reset doesn't need to happen before the check, no?
> + }
> }
> }
> if (folio_test_anon(folio)) {
>
next prev parent reply other threads:[~2026-07-09 8:24 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-03 13:47 [PATCH v2 0/5] Keep tail page private zero at free and folio split time Zi Yan
2026-07-03 13:47 ` [PATCH v2 1/5] mm/percpu-km: clear page->private before free them Zi Yan
2026-07-06 8:37 ` David Hildenbrand (Arm)
2026-07-09 7:58 ` Vlastimil Babka (SUSE)
2026-07-03 13:47 ` [PATCH v2 2/5] mm/compaction: stop recording free page order in page->private Zi Yan
2026-07-03 13:47 ` [PATCH v2 3/5] mm/huge_memory: add page->private check back in __split_folio_to_order() Zi Yan
2026-07-06 0:52 ` Baolin Wang
2026-07-06 8:30 ` David Hildenbrand (Arm)
2026-07-06 8:33 ` David Hildenbrand (Arm)
2026-07-09 8:03 ` Vlastimil Babka (SUSE)
2026-07-09 16:11 ` Zi Yan
2026-07-03 13:47 ` [PATCH v2 4/5] mm/page_alloc: make sure tail_page->private is zero at page free time Zi Yan
2026-07-09 8:24 ` Vlastimil Babka (SUSE) [this message]
2026-07-09 16:13 ` Zi Yan
2026-07-03 13:47 ` [PATCH v2 5/5] mm/page_alloc: remove set_page_private() in prep_compound_tail() Zi Yan
2026-07-03 14:52 ` Lance Yang
2026-07-06 8:26 ` David Hildenbrand (Arm)
2026-07-05 3:00 ` [PATCH v2 0/5] Keep tail page private zero at free and folio split time Zi Yan
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=9fc67666-ac70-4d03-8836-5f8a9f5f1ff6@kernel.org \
--to=vbabka@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=cl@gentwo.org \
--cc=david@kernel.org \
--cc=dennis@kernel.org \
--cc=dev.jain@arm.com \
--cc=hannes@cmpxchg.org \
--cc=jackmanb@google.com \
--cc=lance.yang@linux.dev \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=npache@redhat.com \
--cc=rppt@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=surenb@google.com \
--cc=tj@kernel.org \
--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