From: "zhen.ni" <zhen.ni@easystack.cn>
To: sashiko-reviews@lists.linux.dev
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH v2 4/6] mm/page_owner: record the NUMA node in the scan cursor
Date: Wed, 14 Oct 2026 15:39:15 +0800 [thread overview]
Message-ID: <f3b6f574-197c-4c19-94dc-463eef134236@easystack.cn> (raw)
In-Reply-To: <sashiko-outbox-169722@kernel.org>
在 2026/10/13 20:36, sashiko-bot@kernel.org 写道:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] mm: incomplete fix leaves page_owner vulnerable to unmapped page dereference
> --
>
> commit 7b174b26adeea5712aaa10bd465514b5ce7dbe36
> Author: Zhen Ni <zhen.ni@easystack.cn>
> Subject: mm/page_owner: record the NUMA node in the scan cursor
>
> This commit computes the page's NUMA node in page_owner_next_eligible()
> and stores it in the scan cursor to avoid dereferencing a potentially
> unmapped page later. It updates the debugfs nid filter and BPF program
> to use this stored node value.
>
>> diff --git a/mm/page_owner.c b/mm/page_owner.c
>> index 617346a4ab22a..113e4e7e0b3a1 100644
>> --- a/mm/page_owner.c
>> +++ b/mm/page_owner.c
> [ ... ]
>> @@ -810,18 +824,8 @@ read_page_owner(struct file *file, char __user *buf, size_t count, loff_t *ppos)
>> /* Find an allocated page */
>> while (page_owner_next_eligible(&scan)) {
>> if (state->nid_filter_enabled) {
>> - int nid;
>> - memdesc_flags_t page_flags =
>> - READ_ONCE(scan.page->flags);
>> -
>> - /*
>> - * Bypass PF_POISONED_CHECK() in page_to_nid() to avoid
>> - * VM_BUG_ON when accessing poisoned pages.
>> - */
>> - if (page_flags.f == PAGE_POISON_PATTERN)
>> - goto skip_continue;
>> - nid = memdesc_nid(&page_flags);
>> - if (!node_isset(nid, state->nid_filter))
>> + if (scan.nid < 0 ||
>> + !node_isset(scan.nid, state->nid_filter))
>> goto skip_continue;
>> }
>>
>
> [Severity: High]
> Does this fix leave scan.page vulnerable to an unmapped page dereference
> shortly after this block?
>
> Although this patch successfully avoids dereferencing scan.page when checking
> the node filter, page_owner_next_eligible() drops the RCU lock via
> page_ext_put() before returning.
>
> Just below the quoted block in read_page_owner(), scan.page is still
> passed directly to print_page_owner():
>
> read_page_owner() {
> ...
> while (page_owner_next_eligible(&scan)) {
> ...
> return print_page_owner(buf, count, scan.pfn, scan.page,
> &scan.po_snap, scan.po_snap.handle, state);
> ...
> }
>
> Inside print_page_owner(), the pointer is dereferenced by scnprintf using
> the %pGp formatter on &page->flags.f.
>
> If a concurrent memory hot-remove operation frees the vmemmap backing this
> struct page after the RCU lock is dropped, will this %pGp format access
> trigger a kernel panic?
>
> Additionally, a follow-up patch in this series (Patch 5) appears to introduce
> get_page_memcg_info() which also unconditionally dereferences scan.page
> outside the RCU lock from read_page_owner(). Does that face the same
> use-after-free risk?
>
The page_ext RCU lock does not pin the underlying struct page. The
dereference
in print_page_owner() predates this series and is not introduced by these
changes.
Thanks,
Zhen
next prev parent reply other threads:[~2026-10-14 8:14 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 12:21 [PATCH v2 0/6] mm/page_owner: add bpf_iter and kfuncs Zhen Ni
2026-10-13 12:21 ` [PATCH v2 1/6] mm/page_owner: extract page_owner_next_eligible() from read loop Zhen Ni
2026-10-13 12:21 ` [PATCH v2 2/6] mm/page_owner: add bpf_iter target "page_owner" Zhen Ni
2026-10-13 13:51 ` bot+bpf-ci
2026-10-13 12:21 ` [PATCH v2 3/6] mm/page_owner: add open-coded page_owner iterator Zhen Ni
2026-10-13 12:49 ` sashiko-bot
2026-10-14 8:01 ` zhen.ni
2026-10-13 13:51 ` bot+bpf-ci
2026-10-13 12:21 ` [PATCH v2 4/6] mm/page_owner: record the NUMA node in the scan cursor Zhen Ni
2026-10-13 12:36 ` sashiko-bot
2026-10-14 7:39 ` zhen.ni [this message]
2026-10-13 12:21 ` [PATCH v2 5/6] mm/page_owner: add bpf_page_owner_get_memcg_info() kfunc Zhen Ni
2026-10-13 12:49 ` sashiko-bot
2026-10-14 7:47 ` zhen.ni
2026-10-13 12:21 ` [PATCH v2 6/6] selftests/bpf: add tests for the page_owner bpf_iter target Zhen Ni
2026-10-13 12:38 ` sashiko-bot
2026-10-14 8:53 ` zhen.ni
2026-10-13 17:17 ` [PATCH v2 0/6] mm/page_owner: add bpf_iter and kfuncs 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=f3b6f574-197c-4c19-94dc-463eef134236@easystack.cn \
--to=zhen.ni@easystack.cn \
--cc=bpf@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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