From: Jiri Olsa <olsajiri@gmail.com>
To: Jiri Olsa <olsajiri@gmail.com>
Cc: sashiko-reviews@lists.linux.dev, bpf@vger.kernel.org
Subject: Re: [PATCH 1/7] uprobes/x86: Move optimized uprobe from nop5 to nop10
Date: Mon, 18 May 2026 10:31:51 +0200 [thread overview]
Message-ID: <agrOd1GVFYSH_txN@krava> (raw)
In-Reply-To: <agmpurrWy15nahPK@krava>
On Sun, May 17, 2026 at 01:42:50PM +0200, Jiri Olsa wrote:
SNIP
> > > Is there a similar issue for forked children that inherit the optimized
> > > 10-byte sequence?
> > >
> > > During fork, uprobe_mmap() installs a breakpoint in the child by writing
> > > 0xCC to the first byte, changing the instruction from 48 8d... to cc 8d...
> > >
> > > If the uprobe is unregistered before the child hits and re-optimizes it,
> > > __is_optimized() will return false because is_lea_insn() strictly expects
> > > the first byte to be 0x48:
> > >
> > > arch/x86/kernel/uprobes.c:is_lea_insn() {
> > > return !memcmp(insn, lea_rsp, LEA_INSN_SIZE);
> > > }
> > >
> > > The fallback check for the re-attached probe on top of jmp8 also fails
> > > because insn[1] is 0x8d, not OPT_JMP8_OFFSET.
> > >
> > > Could set_orig_insn() then fall back to writing just the first byte of
> > > the original instruction over the 0xcc, again leaving 66 8d 64 24 80 e8 ...
> > > and silently truncating the child's stack pointer?
> >
> > nice.. maybe we can skip the install_breakpoint call in uprobe_mmap
> > for optimized probes.. will check
>
> I think we need to dup uprobe trampolines on fork like below
or just allow it to be copied on fork
jirka
---
diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
index 4d91930aa792..e0067d1b6242 100644
--- a/arch/x86/kernel/uprobes.c
+++ b/arch/x86/kernel/uprobes.c
@@ -719,7 +719,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,
&tramp_mapping);
if (IS_ERR(vma)) {
kfree(tramp);
next prev parent reply other threads:[~2026-05-18 8:31 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-14 13:53 [PATCH 0/7] uprobes/x86: Fix red zone issue for optimized uprobes Jiri Olsa
2026-05-14 13:53 ` [PATCH 1/7] uprobes/x86: Move optimized uprobe from nop5 to nop10 Jiri Olsa
2026-05-14 16:54 ` Jakub Sitnicki
2026-05-15 12:31 ` Jiri Olsa
2026-05-14 20:05 ` sashiko-bot
2026-05-15 12:31 ` Jiri Olsa
2026-05-17 11:42 ` Jiri Olsa
2026-05-18 8:31 ` Jiri Olsa [this message]
2026-05-15 20:31 ` Andrii Nakryiko
2026-05-17 11:45 ` Jiri Olsa
2026-05-18 10:43 ` Peter Zijlstra
2026-05-18 16:14 ` Andrii Nakryiko
2026-05-18 16:39 ` Jiri Olsa
2026-05-14 13:53 ` [PATCH 2/7] libbpf: Change has_nop_combo to work on top of nop10 Jiri Olsa
2026-05-14 14:55 ` bot+bpf-ci
2026-05-15 12:32 ` Jiri Olsa
2026-05-15 11:12 ` Jakub Sitnicki
2026-05-14 13:53 ` [PATCH 3/7] selftests/bpf: Emit nop,nop10 instructions combo for x86_64 arch Jiri Olsa
2026-05-14 20:44 ` sashiko-bot
2026-05-15 12:32 ` Jiri Olsa
2026-05-14 13:53 ` [PATCH 4/7] selftests/bpf: Change uprobe syscall tests to use nop10 Jiri Olsa
2026-05-14 20:51 ` sashiko-bot
2026-05-15 12:32 ` Jiri Olsa
2026-05-14 13:53 ` [PATCH 5/7] selftests/bpf: Change uprobe/usdt trigger bench code " Jiri Olsa
2026-05-14 13:53 ` [PATCH 6/7] selftests/bpf: Add reattach tests for uprobe syscall Jiri Olsa
2026-05-14 13:53 ` [PATCH 7/7] selftests/bpf: Add tests for uprobe nop10 red zone clobbering Jiri Olsa
2026-05-14 14:55 ` bot+bpf-ci
2026-05-18 7:30 ` Jiri Olsa
2026-05-14 21:22 ` 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=agrOd1GVFYSH_txN@krava \
--to=olsajiri@gmail.com \
--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 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.