From: sashiko-bot@kernel.org
To: "Ian Rogers" <irogers@google.com>, linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v2 4/6] perf synthetic-events: Use PROCMAP_QUERY to synthesize mmap events
Date: Fri, 04 Dec 2026 05:21:43 +0000 [thread overview]
Message-ID: <sashiko-outbox-249133@kernel.org> (raw)
In-Reply-To: <20261204045948.2254888-5-irogers@google.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] perf synthetic-events: incomplete
procmap_query__skip_build_id() denylist
- [Low] perf synthetic-events: untracked tools fs.h include and
inaccurate comment
--
commit 731593d66b5cd9e950bcf3d00319b9a21bc49f26
Author: Ian Rogers <irogers@google.com>
perf synthetic-events: Use PROCMAP_QUERY to synthesize mmap events
This commit updates perf_event__synthesize_mmap_events() to use the
PROCMAP_QUERY ioctl to enumerate VMAs and retrieve build IDs directly from
the kernel, falling back to parsing /proc/<pid>/task/<pid>/maps text when
unsupported.
Link: https://lore.kernel.org/lkml/20261202124341.GA677025@noisy.programming.kicks-ass.net/
> diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic-events.c
> index 445199d7bbd46..d6d99de1774b5 100644
> --- a/tools/perf/util/synthetic-events.c
> +++ b/tools/perf/util/synthetic-events.c
[ ... ]
> @@ -20,6 +21,8 @@
> #include "util/target.h"
> #include "util/time-utils.h"
> #include <linux/bitops.h>
> +#include <linux/compiler.h>
> +#include <linux/fs.h> /* PROCMAP_QUERY, from tools/include/uapi if not in system headers */
> #include <linux/kernel.h>
> #include <linux/string.h>
> #include <linux/zalloc.h>
[Severity: Low]
Does the inline comment accurately describe the include precedence here?
tools/perf/Makefile.config puts -I$(srctree)/tools/include/uapi ahead of
system include paths, so this unconditionally includes
tools/include/uapi/linux/fs.h rather than falling back to it when system
headers lack PROCMAP_QUERY (the commit message states the same).
In addition, tools/perf/check-headers.sh only checks include/uapi/linux/fs.h
under BEAUTY_FILES and does not track tools/include/uapi/linux/fs.h, which
has already drifted from include/uapi/linux/fs.h. If perf now compiles
against that copy, check-headers.sh should track it.
[ ... ]
> +static bool procmap_query__skip_build_id(struct machine *machine, const char *name)
> +{
> + struct stat st;
> +
> + /*
> + * Skip device nodes and pseudo-filesystems before asking the kernel
> + * for a build ID: do_procmap_query() passes vma->vm_file straight to
> + * build_id_parse_file() -> __kernel_read(), which warns on device
> + * files without ->read_iter and can crash 6.11-6.18 kernels lacking
> + * commit 777a8560fd29 ("lib/buildid: use __kernel_read() for
> + * sleepable context"). Allow /dev/shm/ regular files.
> + */
> + if ((!strncmp(name, "/dev/", 5) && strncmp(name, "/dev/shm/", 9)) ||
> + !strncmp(name, "/sys/", 5) || !strncmp(name, "/proc/", 6))
> + return true;
> +
> + /*
> + * Skip any other non-regular file visible in this mount namespace.
> + * If stat() fails (e.g. a deleted binary or a file only in the
> + * target's mount namespace), still let the kernel try.
> + */
> + if (machine__is_host(machine) && stat(name, &st) == 0 && !S_ISREG(st.st_mode))
> + return true;
> +
> + return false;
> +}
[Severity: Medium]
Can procmap_query__skip_build_id() still trigger a kernel NULL pointer
dereference on 6.11-6.18 kernels lacking commit 777a8560fd29 ("lib/buildid:
use __kernel_read() for sleepable context")?
On those kernels, do_procmap_query() -> build_id_parse_file() calls
read_cache_folio() when page 0 is not resident, which dereferences
mapping->a_ops->read_folio in filemap_read_folio().
Several common mappings have a non-zero inode, a leading '/', and a NULL
read_folio, yet bypass this denylist: shmem/tmpfs files (including /dev/shm/,
explicitly allowed here, and /memfd:), /dmabuf: mappings, hugetlbfs mappings
such as /anon_hugepage (deleted), and /[aio] (deleted) mappings.
On 6.19+ kernels, device nodes outside /dev/, /sys/, and /proc/ in another
mount namespace also bypass the host-namespace stat() check and can trigger
pr_warn_ratelimited() in __kernel_read().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204045948.2254888-1-irogers@google.com?part=4
next prev parent reply other threads:[~2026-12-04 5:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 4:59 [PATCH v2 0/6] perf synthetic-events: Use PROCMAP_QUERY for mmap synthesis Ian Rogers
2026-12-04 4:59 ` [PATCH v2 1/6] perf machine: Fix leak when creating host kernel maps fails Ian Rogers
2026-12-04 4:59 ` [PATCH v2 2/6] perf synthetic-events: Fix race on DSO build IDs when synthesizing Ian Rogers
2026-12-04 4:59 ` [PATCH v2 3/6] perf bench synthesize: Initialize symbols so build IDs can be read Ian Rogers
2026-12-04 4:59 ` [PATCH v2 4/6] perf synthetic-events: Use PROCMAP_QUERY to synthesize mmap events Ian Rogers
2026-12-04 5:21 ` sashiko-bot [this message]
2026-12-04 4:59 ` [PATCH v2 5/6] perf bench synthesize: Add --procmap-query option Ian Rogers
2026-12-04 4:59 ` [PATCH v2 6/6] perf test: Add test comparing PROCMAP_QUERY and /proc/pid/maps synthesis Ian Rogers
2026-12-04 5:21 ` [PATCH v2 0/6] perf synthetic-events: Use PROCMAP_QUERY for mmap synthesis sashiko-bot
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=sashiko-outbox-249133@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=irogers@google.com \
--cc=linux-perf-users@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