From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
To: zhangjiao2 <zhangjiao2@cmss.chinamobile.com>
Cc: akpm@linux-foundation.org, david@kernel.org, surenb@google.com,
vbabka@kernel.org, kas@kernel.org, dave.hansen@linux.intel.com,
mirq-linux@rere.qmqm.pl, arnd@arndb.de, sfr@canb.auug.org.au,
usama.anjum@arm.com, avagin@gmail.com, stable@vger.kernel.org,
linux-kernel@vger.kernel.org, trivial@kernel.org,
Muhammad Usama Anjum <usama.anjum@collabora.com>
Subject: Re: [PATCH] fs/proc/task_mmu: fix uninitialized read in pagemap_scan_push_range()
Date: Wed, 18 Nov 2026 14:25:42 +0000 [thread overview]
Message-ID: <av20LHgDx5Bu5aqf@gremlin> (raw)
In-Reply-To: <20261118093959.1728-1-zhangjiao2@cmss.chinamobile.com>
You are missing cc's. Fixing this is easy with b4 [0] (the recommended way
of sending patches to mm):
$ b4 prep --auto-to-cc
Alternatively, you can use scripts/get_maintainer.pl:
$ scripts/get_maintainer.pl --nogit-fallback <files-or-patches>
[0]: https://b4.docs.kernel.org/en/latest/contributor/send.html
Specifically, the following appear to be missing:
linux-fsdevel@vger.kernel.org
linux-mm@kvack.org
liam@infradead.org
jannh@google.com
pfalcato@suse.de
On Wed, Nov 18, 2026 at 05:39:58PM +0800, zhangjiao2 wrote:
> From: zhang jiao <zhangjiao2@cmss.chinamobile.com>
>
> PAGEMAP_SCAN ioctl accumulates struct page_region entries in a bounce
> buffer before copying them out to userspace. The bounce buffer is
> allocated with kmalloc() and only the first entry's ->start and ->end
> fields are reset, leaving its ->categories field uninitialized.
>
> pagemap_scan_push_range() decides whether an incoming range can be
> merged into the current entry with:
>
> if (addr == cur_buf->end && categories == cur_buf->categories)
>
> A scan starting at address 0 is accepted (arg->start is only checked
> for page alignment) and page 0 can be mapped when mmap_min_addr permits
> it. If the first matching page is then reported at address 0,
> addr == cur_buf->end == 0 holds and the uninitialized
> cur_buf->categories is read, so the merge decision depends on stale
> slab contents and KMSAN would flag an uninit-value use. No kernel data
Are you sure KMSAN would? Did you reproduce?
> can actually be disclosed, because the comparison only succeeds when
> the uninitialized value equals the categories that would be stored
> anyway.
This is too dense, can you simplify please?
This does basically amount to 'no actual issue in practice' :) please make that
clear.
>
> Fix this by zero-allocating the bounce buffer, which also makes the
> manual reset of the first entry redundant. The buffer is allocated
> once per ioctl invocation, so the additional zeroing cost is
> negligible.
>
> Fixes: 52526ca7fdb9 ("fs/proc/task_mmu: implement IOCTL to get and optionally clear info about PTEs")
I'm not sure even this is valid, since this doesn't actually amount to a real
world bug. But I guess debatable.
> Cc: <stable@vger.kernel.org>
But this isn't debatable, no cc-stable, that's really silly. Zero impact = no
backports needed :)
> Cc: Muhammad Usama Anjum <usama.anjum@collabora.com>
> Signed-off-by: zhang jiao <zhangjiao2@cmss.chinamobile.com>
In general the solution looks fine, but please make sure to cc the right people
and fix the commit message + tags. Thanks!
> ---
> fs/proc/task_mmu.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
> index 22361607020d..4e552f9db8ba 100644
> --- a/fs/proc/task_mmu.c
> +++ b/fs/proc/task_mmu.c
> @@ -3082,11 +3082,10 @@ static int pagemap_scan_init_bounce_buffer(struct pagemap_scan_private *p)
>
> p->vec_buf_len = min_t(size_t, PAGEMAP_WALK_SIZE >> PAGE_SHIFT,
> p->arg.vec_len);
> - p->vec_buf = kmalloc_objs(*p->vec_buf, p->vec_buf_len);
> + p->vec_buf = kzalloc_objs(*p->vec_buf, p->vec_buf_len);
> if (!p->vec_buf)
> return -ENOMEM;
>
> - p->vec_buf->start = p->vec_buf->end = 0;
> p->vec_out = (struct page_region __user *)(long)p->arg.vec;
>
> return 0;
> --
> 2.33.0
>
>
>
--
Cheers, Lorenzo
prev parent reply other threads:[~2026-11-18 14:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 9:39 [PATCH] fs/proc/task_mmu: fix uninitialized read in pagemap_scan_push_range() zhangjiao2
2026-11-18 14:25 ` Lorenzo Stoakes (ARM) [this message]
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=av20LHgDx5Bu5aqf@gremlin \
--to=ljs@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=avagin@gmail.com \
--cc=dave.hansen@linux.intel.com \
--cc=david@kernel.org \
--cc=kas@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mirq-linux@rere.qmqm.pl \
--cc=sfr@canb.auug.org.au \
--cc=stable@vger.kernel.org \
--cc=surenb@google.com \
--cc=trivial@kernel.org \
--cc=usama.anjum@arm.com \
--cc=usama.anjum@collabora.com \
--cc=vbabka@kernel.org \
--cc=zhangjiao2@cmss.chinamobile.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.