From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796347536; b=ZSDWNoo+hJfmL6gjNE0cUwwyqSQEvuRbZ8BIjYCNrWsk7X/sWstgS1E9PX5uhyDPSZdG yQSZJozAanZ8Yp0/VyfQUmK/r/IknXIfVJ4DQKQ7/0uEtCknk8r+r71i+QgmsoNUtNSzs /uYgzO9uRgblR2PkuUR0TvgHzV2JdbIIL9KyU6nD0+4B7zl8g1Mc2arq6TBoEDDmgf/Pm 3G2VdXsLdOmYLvp2rqLuVvO1Qf+Di93JX95DNJSUtVnOMygVQaLWPOWZnsG0xNprrAIoJ hH94q6HqILWsFJA83F6oo3YelLbxYi+WeZqjeVfi5RN/i98LOnRhId9FDWvRtRHK3Hw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796347536; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=wbbIvdJZ53mI44eunUYxsUM64o1T1ocQqFUNF0rY6q8=; b=MAn6JXqciVtO+HeqpjkLJ5kWsgMgWMMC1mpPOOpo6zEGLKNowTDY+vophRTuEH17aX31 lvnDEVDObjvO8noslkAgvFQePaRwBqocKJOEM/Ve2PtDyqRLI2KtplKAgrwbkDg4G6l/X DuC+/us6tmEmZUDqDrkXaSVkc29tJRvWQimJIixtlh0b9DDn73INYrHRrBiVF4CmgQUtE Aby7LGvd6MjY8j3pHehfvWYV9jhL7R5JzqcEidlT3JtEorBDKHyWdbC777pYLRg+igQvN oGpAwZ4ZPKFg0jVBhyQ4qdzxRaG8lW+bWuuSg5xsh/uEIH8e6WfhRbIUT10FU1YYGVA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Cvx6HyCY; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 12662606A322 for ; Fri, 4 Dec 2026 01:25:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Cvx6HyCY Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9789F1F000CE; Fri, 4 Dec 2026 01:25:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796347535; bh=wbbIvdJZ53mI44eunUYxsUM64o1T1ocQqFUNF0rY6q8=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=Cvx6HyCYuvM+BIY+jQd+Q+6/W6ZENzHBOw5VgIuBsVrWylfF4QhbBCyRSxRTkoij2 eyQbqNGafvm8YMl+SaLcQc8yU3j8KknbzJdUu+IQV7DBBp1kWYwvxsIXY68IWURVBm 1h+jbAPigW4WOCuj8TG4iW6Hve+cvdB5f0uql+t2gunIP+IkVwCguoK7qXppFwv1rT AsonRBkmDmwaYCmL7Zvfu1VlTVhwcAIIqJUqyr3TmTsy+YQpOckfSFUTskeV9Fd8T5 ie4GFvAE+VpFnCtAE0UB/MstIdgH6YSgCOu09oo5dNTlpjxani7gUQtJ9bTzBy7gr/ /32LKot2cIUsw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 4/6] perf synthetic-events: Use PROCMAP_QUERY to synthesize mmap events Reply-To: sashiko-reviews@lists.linux.dev To: "Ian Rogers" , linux-perf-users@vger.kernel.org In-Reply-To: <20261204010452.1937224-5-irogers@google.com> References: <20261204010452.1937224-1-irogers@google.com> <20261204010452.1937224-5-irogers@google.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 01:25:35 +0000 X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] perf: PROCMAP_QUERY requests build IDs for non-regular device VMAs - [Medium] perf: backwards addr on retry in synth_mmap2_state__procmap_query_pass() - [Low] perf: synth_mmap2_state__procmap_query_pass() skips timeout check -- commit b2c1ada3a9050c0e1eaf2b8ff80a88664c6a6487 Author: Ian Rogers perf synthetic-events: Use PROCMAP_QUERY to synthesize mmap events This commit switches MMAP2 event synthesis to use the PROCMAP_QUERY ioctl on /proc//task//maps when supported, keeping the text parser as a fallback. It also asks the kernel for build IDs on DSO cache misses to avoid opening ELF files from userspace. Link: https://lore.kernel.org/lkml/20261202124341.GA677025@noisy.programmin= g.kicks-ass.net/ > diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthet= ic-events.c > index 445199d7bbd46..3ad482f9115a9 100644 > --- a/tools/perf/util/synthetic-events.c > +++ b/tools/perf/util/synthetic-events.c [ ... ] > +static int synth_mmap2_state__procmap_query_pass(struct synth_mmap2_stat= e *state, int fd, > + __u64 query_flags, bool skip_readable, > + bool *first) > +{ > + union perf_event *event =3D state->event; > + char *name =3D event->mmap2.filename; > + const u32 name_size =3D sizeof(event->mmap2.filename) - state->machine-= >id_hdr_size; > + __u64 addr =3D 0; > + > + while (true) { > + struct synth_mmap2_vma vma =3D { .bid =3D { .size =3D 0, }, }; > + struct procmap_query q; > + bool want_name =3D !skip_readable; > + bool name_too_long =3D false; > + int ret; > +retry: [ ... ] > + if (skip_readable && (q.vma_flags & PROCMAP_QUERY_VMA_READABLE)) { > + addr =3D q.vma_end; > + continue; > + } [Severity: Low] Does skipping readable VMAs here bypass the --proc-map-timeout check? The only check against state->timeout is inside synth_mmap2_state__process_vma(), which this continue skips. On a process with many readable executable VMAs during data mmap synthesis, the second pass can keep issuing PROCMAP_QUERY ioctls past the timeout without warning or setting PERF_RECORD_MISC_PROC_MAP_PARSE_TIMEOUT. > + if (!want_name) { > + /* A wanted VMA, query it again to get its name. */ > + want_name =3D true; > + addr =3D q.vma_start; > + goto retry; > + } [Severity: Medium] Can moving addr backwards to q.vma_start here trap perf in an infinite loop when a target process concurrently modifies its VMAs? PROCMAP_QUERY_COVERING_OR_NEXT_VMA returns a covering VMA even when vma_start is below addr. If an unprivileged target process alternates mprotect() on the prefix [base, mid) of a contiguous region [base, end) between PROT_READ|PROT_EXEC and PROT_EXEC while perf is in Pass 2: perf (Pass 2, addr =3D mid) target process ioctl(PROCMAP_QUERY, mid) -> covering VMA [base, end), --x want_name =3D true addr =3D q.vma_start (base) goto retry mprotect([base, mid), r-x) ioctl(PROCMAP_QUERY, base) -> VMA [base, mid), r-x skip_readable matches: addr =3D q.vma_end (mid) continue (resets want_name =3D false) <-- repeats forever mprotect([base, mid), --x) Because neither goto retry nor the skip_readable continue checks state->timeout, perf can spin indefinitely and bypass --proc-map-timeout during system-wide data mmap recording. Retrying at the original addr (or ensuring addr never moves backwards) would preserve forward progress. [ ... ] > + /* > + * Get the build ID of wanted file backed VMAs. Other VMAs > + * have no build ID, or are unwanted and skipped. > + */ > + if (!symbol_conf.no_buildid_mmap2 && q.inode && name[0] =3D=3D '/' && > + ((vma.prot & PROT_EXEC) || (state->mmap_data && (vma.prot & PROT_R= EAD))) && > + (!state->hugetlbfs_mnt_len || > + strncmp(name, state->hugetlbfs_mnt, state->hugetlbfs_mnt_len))) > + synth_mmap2_state__vma_build_id(state, fd, &q, name, &vma); [Severity: Medium] Can this request build IDs from the kernel for non-regular files such as mapped character devices? Previously, filename__read_build_id() checked is_regular_file() before opening a mapped path, skipping device files. With mmap_data enabled, readable mappings like /dev/dri/renderD128 satisfy the check above, miss the DSO build ID cache, and cause synth_mmap2_state__vma_build_id() to issue PROCMAP_QUERY with build_id_size set. In the kernel, do_procmap_query() passes vma->vm_file straight to build_id_parse_file() -> __kernel_read(), triggering ratelimited "kernel read not supported" warnings in dmesg for device files without read_iter (or with both read and read_iter). On 6.11-6.18 kernels lacking commit 777a8560fd29 ("lib/buildid: use __kernel_read() for sleepable context"), querying build IDs on mapped device files without read_folio causes a kernel NULL pointer dereference in filemap_read_folio(). --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204010452.1937= 224-1-irogers@google.com?part=3D4