From: sashiko-bot@kernel.org
To: "Jiri Olsa" <jolsa@kernel.org>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCHv2 02/11] uprobes/x86: Allow to copy uprobe trampolines on fork
Date: Mon, 18 May 2026 11:42:08 +0000 [thread overview]
Message-ID: <20260518114208.CE128C2BCF6@smtp.kernel.org> (raw)
In-Reply-To: <20260518105957.123445-3-jolsa@kernel.org>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Critical] __in_uprobe_trampoline uses current->mm instead of the target mm_struct, causing kernel crashes and instruction stream corruption during uprobe_unregister.
- [High] Removing VM_DONTCOPY without synchronizing the uprobes state causes a linear VMA leak across fork chains.
--
commit be0e6254bd9df4f56adce23d7a5e24a78c286291
Author: Jiri Olsa <jolsa@kernel.org>
uprobes/x86: Allow to copy uprobe trampolines on fork
This commit allows vma uprobe trampoline objects to be copied on fork to
the new process by removing the VM_DONTCOPY flag.
> diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
> --- a/arch/x86/kernel/uprobes.c
> +++ b/arch/x86/kernel/uprobes.c
> @@ -702,7 +702,7 @@ static struct uprobe_trampoline *create_uprobe_trampoline(unsigned long vaddr)
>
> tramp->vaddr = vaddr;
> vma = _install_special_mapping(mm, tramp->vaddr, PAGE_SIZE,
> - VM_READ|VM_EXEC|VM_MAYEXEC|VM_MAYREAD|VM_DONTCOPY|VM_IO,
> + VM_READ|VM_EXEC|VM_MAYEXEC|VM_MAYREAD|VM_IO,
Does removing VM_DONTCOPY without synchronizing the uprobes state cause a
linear VMA leak across fork chains?
When dup_mmap() copies the uprobe trampoline VMA to the child process during
fork(), the child's tracking list (mm->uprobes_state.head_tramps) is
initialized as completely empty via mm_init_uprobes_state(), meaning the
parent's state is not duplicated.
When the child process executes a uprobe, arch_uprobe_optimize() calls
get_uprobe_trampoline(). Because head_tramps is empty, it fails to find the
VMA it already inherited. It then falls back to create_uprobe_trampoline(),
which calls find_nearest_trampoline(). Since the inherited VMA is already
mapped, find_nearest_trampoline() finds a new unmapped area and installs a
second duplicate trampoline VMA.
In a deep fork chain, each generation inherits all previous VMAs, has an
empty head_tramps list, and creates a new VMA. Can this cause a linear
accumulation of redundant VMAs, eventually exhausting vm.max_map_count and
virtual memory?
As a related question about the uprobe trampolines introduced in the preceding
commit ba2bfc97b462, does __in_uprobe_trampoline() safely handle unregistered
uprobes?
When a uprobe is unregistered (e.g., via bpf_uprobe_unregister in a workqueue
or by a different process like perf), set_orig_insn() calls is_optimized() to
check if the uprobe is optimized. If is_optimized() internally calls
__in_uprobe_trampoline() which hardcodes current->mm for the VMA lookup, does
it completely ignore the passed mm parameter?
If unregistered asynchronously from a kernel thread, current->mm is NULL. Can
this cause a deterministic NULL pointer dereference in vma_lookup() and crash
the kernel?
Additionally, if unregistered by a different process, would vma_lookup()
search the wrong mm, return false, and cause set_orig_insn() to incorrectly
assume the instruction is not optimized? Could this lead to replacing only
the first byte of the 5-byte CALL instruction with the original opcode,
leaving the 4-byte relative offset as garbage and crashing the traced process
when it executes the corrupted instruction?
> &tramp_mapping);
> if (IS_ERR(vma)) {
> kfree(tramp);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260518105957.123445-3-jolsa@kernel.org?part=1
next prev parent reply other threads:[~2026-05-18 11:42 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-18 10:59 [PATCHv2 00/11] uprobes/x86: Fix red zone issue for optimized uprobes Jiri Olsa
2026-05-18 10:59 ` [PATCHv2 01/11] uprobes/x86: Use proper mm_struct in __in_uprobe_trampoline Jiri Olsa
2026-05-18 10:59 ` [PATCHv2 02/11] uprobes/x86: Allow to copy uprobe trampolines on fork Jiri Olsa
2026-05-18 11:42 ` sashiko-bot [this message]
2026-05-18 12:50 ` Jiri Olsa
2026-05-18 16:04 ` Jiri Olsa
2026-05-18 10:59 ` [PATCHv2 03/11] uprobes/x86: Move optimized uprobe from nop5 to nop10 Jiri Olsa
2026-05-18 11:50 ` bot+bpf-ci
2026-05-18 10:59 ` [PATCHv2 04/11] libbpf: Change has_nop_combo to work on top of nop10 Jiri Olsa
2026-05-18 11:37 ` bot+bpf-ci
2026-05-19 20:36 ` Jiri Olsa
2026-05-18 10:59 ` [PATCHv2 05/11] libbpf: Detect uprobe syscall with new error Jiri Olsa
2026-05-18 11:31 ` sashiko-bot
2026-05-19 20:36 ` Jiri Olsa
2026-05-18 11:37 ` bot+bpf-ci
2026-05-18 17:39 ` Andrii Nakryiko
2026-05-18 10:59 ` [PATCHv2 06/11] selftests/bpf: Emit nop,nop10 instructions combo for x86_64 arch Jiri Olsa
2026-05-18 11:17 ` sashiko-bot
2026-05-19 20:36 ` Jiri Olsa
2026-05-18 10:59 ` [PATCHv2 07/11] selftests/bpf: Change uprobe syscall tests to use nop10 Jiri Olsa
2026-05-18 11:16 ` sashiko-bot
2026-05-19 20:36 ` Jiri Olsa
2026-05-18 11:50 ` bot+bpf-ci
2026-05-18 10:59 ` [PATCHv2 08/11] selftests/bpf: Change uprobe/usdt trigger bench code " Jiri Olsa
2026-05-18 11:37 ` bot+bpf-ci
2026-05-18 10:59 ` [PATCHv2 09/11] selftests/bpf: Add reattach tests for uprobe syscall Jiri Olsa
2026-05-18 10:59 ` [PATCHv2 10/11] selftests/bpf: Add tests for uprobe nop10 red zone clobbering Jiri Olsa
2026-05-18 10:59 ` [PATCHv2 11/11] selftests/bpf: Add tests for forked/cloned optimized uprobes Jiri Olsa
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=20260518114208.CE128C2BCF6@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=jolsa@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