From patchwork Sun Apr 21 19:42:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 13637520 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F22033FB14; Sun, 21 Apr 2024 19:42:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713728547; cv=none; b=Tefcbbj9DcbfDX3CUm1ZH6wKcU4PIS+JC5jljIg9Kze0ztVjhK+TXU0eMDQ/iPHwXjGyxZjq94G6Q07d4Motf+OHneoj5lH4KjbUgsQhvpT2/2Vmp3hR1gj5Hy5cDgk6VL4u9aBY9UxSsq6dOmzKL+/JdXcSnk7xm/wkwr+en+0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713728547; c=relaxed/simple; bh=WN9IWTdTK5TSpbOfDXO0WV3z3MUbFSE4i1zq1kirIpw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OUuXCq39S403SA4MYtgPF8/N4WYmEoAwuNM2q5lPVL5xWd/UuvGFyThzgZ7JU7oKJTNp12Se75yKwMp5lRuxBKsJfYhXyRzTR7dWtmku7FpNR4N77twvMVB38phY7WmZfMJG2hx4J4CgH4yg8zjHpWeXfsN9z2njhclSM9aPhgU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mQm8lrPM; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mQm8lrPM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1ED84C113CE; Sun, 21 Apr 2024 19:42:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713728546; bh=WN9IWTdTK5TSpbOfDXO0WV3z3MUbFSE4i1zq1kirIpw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mQm8lrPM+Jog/b41kpEzCz2NNZlfVKPNNkXBcctQwfNZIVmVd53iDJGrx5OG/a7GJ jBiU6MTPWD5kqys3uRFOpx0LQ2+diSVm+EG82908oOEDwW04pgsgGFUDtJUGa/Yd4T P1CFxGZAFpwpaQdtsTabHRU80cIdXFruxYqVIwMqxl3PpoSfbv0lhDQy7JE1nQWfoY +eUQiibhxHZPl66/bTKESMN/VMsRLi/1Bcm/1YOO4UZRzYdAQQmaMjBOJApqmUPW/k MWSDz/WZLksMWq3wyTgtrtficU5iQ9Duef4Z3JyFBDk0dFCtDxz0yvT/ZNk/5FpJH0 M0Fz7RHUEt8lQ== From: Jiri Olsa To: Steven Rostedt , Masami Hiramatsu , Oleg Nesterov , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-api@vger.kernel.org, x86@kernel.org, bpf@vger.kernel.org, Song Liu , Yonghong Song , John Fastabend , Peter Zijlstra , Thomas Gleixner , "Borislav Petkov (AMD)" , Ingo Molnar , Andy Lutomirski Subject: [PATCHv3 bpf-next 1/7] uprobe: Wire up uretprobe system call Date: Sun, 21 Apr 2024 21:42:00 +0200 Message-ID: <20240421194206.1010934-2-jolsa@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240421194206.1010934-1-jolsa@kernel.org> References: <20240421194206.1010934-1-jolsa@kernel.org> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Wiring up uretprobe system call, which comes in following changes. We need to do the wiring before, because the uretprobe implementation needs the syscall number. Note at the moment uretprobe syscall is supported only for native 64-bit process. Signed-off-by: Jiri Olsa Reviewed-by: Oleg Nesterov Acked-by: Andrii Nakryiko --- arch/x86/entry/syscalls/syscall_64.tbl | 1 + include/linux/syscalls.h | 2 ++ include/uapi/asm-generic/unistd.h | 5 ++++- kernel/sys_ni.c | 2 ++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/x86/entry/syscalls/syscall_64.tbl b/arch/x86/entry/syscalls/syscall_64.tbl index 7e8d46f4147f..af0a33ab06ee 100644 --- a/arch/x86/entry/syscalls/syscall_64.tbl +++ b/arch/x86/entry/syscalls/syscall_64.tbl @@ -383,6 +383,7 @@ 459 common lsm_get_self_attr sys_lsm_get_self_attr 460 common lsm_set_self_attr sys_lsm_set_self_attr 461 common lsm_list_modules sys_lsm_list_modules +462 64 uretprobe sys_uretprobe # # Due to a historical design error, certain syscalls are numbered differently diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index e619ac10cd23..5318e0e76799 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -972,6 +972,8 @@ asmlinkage long sys_lsm_list_modules(u64 *ids, u32 *size, u32 flags); /* x86 */ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int on); +asmlinkage long sys_uretprobe(void); + /* pciconfig: alpha, arm, arm64, ia64, sparc */ asmlinkage long sys_pciconfig_read(unsigned long bus, unsigned long dfn, unsigned long off, unsigned long len, diff --git a/include/uapi/asm-generic/unistd.h b/include/uapi/asm-generic/unistd.h index 75f00965ab15..8a747cd1d735 100644 --- a/include/uapi/asm-generic/unistd.h +++ b/include/uapi/asm-generic/unistd.h @@ -842,8 +842,11 @@ __SYSCALL(__NR_lsm_set_self_attr, sys_lsm_set_self_attr) #define __NR_lsm_list_modules 461 __SYSCALL(__NR_lsm_list_modules, sys_lsm_list_modules) +#define __NR_uretprobe 462 +__SYSCALL(__NR_uretprobe, sys_uretprobe) + #undef __NR_syscalls -#define __NR_syscalls 462 +#define __NR_syscalls 463 /* * 32 bit systems traditionally used different diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c index faad00cce269..be6195e0d078 100644 --- a/kernel/sys_ni.c +++ b/kernel/sys_ni.c @@ -391,3 +391,5 @@ COND_SYSCALL(setuid16); /* restartable sequence */ COND_SYSCALL(rseq); + +COND_SYSCALL(uretprobe); From patchwork Sun Apr 21 19:42:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 13637521 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 109D63FE51; Sun, 21 Apr 2024 19:42:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713728560; cv=none; b=a4mS3ig4jx6UTU6RJT6K47LWfL5eWzKKTLCiNLvPnMdbzMjmL9ktbzkVm02ZE4+Spu9+D5MYb9cvycSQTp9migbauL2nQ0629RQ+3sOCxFUZPSzbVJB/zWoRwEzMZC6U8JQjRqDTKcLbJNkzE4/Y4EaOfzVo0VT8Bb9gMHyaDmY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713728560; c=relaxed/simple; bh=b9WpzrDRUIl2I0mdMkc6Qa7FzaGMsYMkdoqHsqKyUZc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eHxpaCmmBrRhHlXVy1BqQC0ElPkU1SPvl/x8OObtUz/lWg5UErNxdduZhAhuLesykTHHG7brz6FLetaO/Bd050MohvX1e0Xf7tloGcWEosn/ZvR9+BXhWhzHi02YwWkUkEPYCNmi3EscCe/dKRODc2+yxpOQczVmpyVWPXU1GEU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=A2dk8MY5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="A2dk8MY5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6EC96C113CE; Sun, 21 Apr 2024 19:42:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713728559; bh=b9WpzrDRUIl2I0mdMkc6Qa7FzaGMsYMkdoqHsqKyUZc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A2dk8MY51k8a+bPkBPb8Oraeyhb04VrwVeHWxGV9zjbaWrWQCvgIdCIN+bbInOqRF Ecv82I5o9lATgqDU+sThY01k9iFIbsDFktjy7p5napK1ZfNb5C/btuKJcd9bo0Hmov TYTx0d4ZTEjAQFHGhUBoWPqSlGyr+2JFqeqifA1MUZagQZISNXmW6D8hn0JMsGAnPV E1Bb2YdRt7yQdP1t172I+y0WA30034wRoXg7QFtHJu23bsS7V/6tzwJmiMGBbelNHL Yi9easFZMz7ZwhCtJqb8ldGzAyDKtLzC7A97+P3kcS2gJ1cnoWpN2NjQmx4LlwjvmH /8LM9xP7jz4AA== From: Jiri Olsa To: Steven Rostedt , Masami Hiramatsu , Oleg Nesterov , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-api@vger.kernel.org, x86@kernel.org, bpf@vger.kernel.org, Song Liu , Yonghong Song , John Fastabend , Peter Zijlstra , Thomas Gleixner , "Borislav Petkov (AMD)" , Ingo Molnar , Andy Lutomirski Subject: [PATCHv3 bpf-next 2/7] uprobe: Add uretprobe syscall to speed up return probe Date: Sun, 21 Apr 2024 21:42:01 +0200 Message-ID: <20240421194206.1010934-3-jolsa@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240421194206.1010934-1-jolsa@kernel.org> References: <20240421194206.1010934-1-jolsa@kernel.org> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Adding uretprobe syscall instead of trap to speed up return probe. At the moment the uretprobe setup/path is: - install entry uprobe - when the uprobe is hit, it overwrites probed function's return address on stack with address of the trampoline that contains breakpoint instruction - the breakpoint trap code handles the uretprobe consumers execution and jumps back to original return address This patch replaces the above trampoline's breakpoint instruction with new ureprobe syscall call. This syscall does exactly the same job as the trap with some more extra work: - syscall trampoline must save original value for rax/r11/rcx registers on stack - rax is set to syscall number and r11/rcx are changed and used by syscall instruction - the syscall code reads the original values of those registers and restore those values in task's pt_regs area - only caller from trampoline exposed in '[uprobes]' is allowed, the process will receive SIGILL signal otherwise Even with some extra work, using the uretprobes syscall shows speed improvement (compared to using standard breakpoint): On Intel (11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz) current: uretprobe-nop : 1.498 ± 0.000M/s uretprobe-push : 1.448 ± 0.001M/s uretprobe-ret : 0.816 ± 0.001M/s with the fix: uretprobe-nop : 1.969 ± 0.002M/s < 31% speed up uretprobe-push : 1.910 ± 0.000M/s < 31% speed up uretprobe-ret : 0.934 ± 0.000M/s < 14% speed up On Amd (AMD Ryzen 7 5700U) current: uretprobe-nop : 0.778 ± 0.001M/s uretprobe-push : 0.744 ± 0.001M/s uretprobe-ret : 0.540 ± 0.001M/s with the fix: uretprobe-nop : 0.860 ± 0.001M/s < 10% speed up uretprobe-push : 0.818 ± 0.001M/s < 10% speed up uretprobe-ret : 0.578 ± 0.000M/s < 7% speed up The performance test spawns a thread that runs loop which triggers uprobe with attached bpf program that increments the counter that gets printed in results above. The uprobe (and uretprobe) kind is determined by which instruction is being patched with breakpoint instruction. That's also important for uretprobes, because uprobe is installed for each uretprobe. The performance test is part of bpf selftests: tools/testing/selftests/bpf/run_bench_uprobes.sh Note at the moment uretprobe syscall is supported only for native 64-bit process, compat process still uses standard breakpoint. Suggested-by: Andrii Nakryiko Signed-off-by: Oleg Nesterov Signed-off-by: Jiri Olsa Reviewed-by: Oleg Nesterov Acked-by: Andrii Nakryiko --- arch/x86/kernel/uprobes.c | 115 ++++++++++++++++++++++++++++++++++++++ include/linux/uprobes.h | 3 + kernel/events/uprobes.c | 24 +++++--- 3 files changed, 135 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c index 6c07f6daaa22..81e6ee95784d 100644 --- a/arch/x86/kernel/uprobes.c +++ b/arch/x86/kernel/uprobes.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -308,6 +309,120 @@ static int uprobe_init_insn(struct arch_uprobe *auprobe, struct insn *insn, bool } #ifdef CONFIG_X86_64 + +asm ( + ".pushsection .rodata\n" + ".global uretprobe_syscall_entry\n" + "uretprobe_syscall_entry:\n" + "pushq %rax\n" + "pushq %rcx\n" + "pushq %r11\n" + "movq $" __stringify(__NR_uretprobe) ", %rax\n" + "syscall\n" + ".global uretprobe_syscall_check\n" + "uretprobe_syscall_check:\n" + "popq %r11\n" + "popq %rcx\n" + + /* The uretprobe syscall replaces stored %rax value with final + * return address, so we don't restore %rax in here and just + * call ret. + */ + "retq\n" + ".global uretprobe_syscall_end\n" + "uretprobe_syscall_end:\n" + ".popsection\n" +); + +extern u8 uretprobe_syscall_entry[]; +extern u8 uretprobe_syscall_check[]; +extern u8 uretprobe_syscall_end[]; + +void *arch_uprobe_trampoline(unsigned long *psize) +{ + static uprobe_opcode_t insn = UPROBE_SWBP_INSN; + struct pt_regs *regs = task_pt_regs(current); + + /* + * At the moment the uretprobe syscall trampoline is supported + * only for native 64-bit process, the compat process still uses + * standard breakpoint. + */ + if (user_64bit_mode(regs)) { + *psize = uretprobe_syscall_end - uretprobe_syscall_entry; + return uretprobe_syscall_entry; + } + + *psize = UPROBE_SWBP_INSN_SIZE; + return &insn; +} + +static unsigned long trampoline_check_ip(void) +{ + unsigned long tramp = uprobe_get_trampoline_vaddr(); + + return tramp + (uretprobe_syscall_check - uretprobe_syscall_entry); +} + +SYSCALL_DEFINE0(uretprobe) +{ + struct pt_regs *regs = task_pt_regs(current); + unsigned long err, ip, sp, r11_cx_ax[3]; + + if (regs->ip != trampoline_check_ip()) + goto sigill; + + err = copy_from_user(r11_cx_ax, (void __user *)regs->sp, sizeof(r11_cx_ax)); + if (err) + goto sigill; + + /* expose the "right" values of r11/cx/ax/sp to uprobe_consumer/s */ + regs->r11 = r11_cx_ax[0]; + regs->cx = r11_cx_ax[1]; + regs->ax = r11_cx_ax[2]; + regs->sp += sizeof(r11_cx_ax); + regs->orig_ax = -1; + + ip = regs->ip; + sp = regs->sp; + + uprobe_handle_trampoline(regs); + + /* + * uprobe_consumer has changed sp, we can do nothing, + * just return via iret + */ + if (regs->sp != sp) + return regs->ax; + regs->sp -= sizeof(r11_cx_ax); + + /* for the case uprobe_consumer has changed r11/cx */ + r11_cx_ax[0] = regs->r11; + r11_cx_ax[1] = regs->cx; + + /* + * ax register is passed through as return value, so we can use + * its space on stack for ip value and jump to it through the + * trampoline's ret instruction + */ + r11_cx_ax[2] = regs->ip; + regs->ip = ip; + + err = copy_to_user((void __user *)regs->sp, r11_cx_ax, sizeof(r11_cx_ax)); + if (err) + goto sigill; + + /* ensure sysret, see do_syscall_64() */ + regs->r11 = regs->flags; + regs->cx = regs->ip; + + return regs->ax; + +sigill: + force_sig(SIGILL); + return -1; +} + /* * If arch_uprobe->insn doesn't use rip-relative addressing, return * immediately. Otherwise, rewrite the instruction so that it accesses diff --git a/include/linux/uprobes.h b/include/linux/uprobes.h index f46e0ca0169c..b503fafb7fb3 100644 --- a/include/linux/uprobes.h +++ b/include/linux/uprobes.h @@ -138,6 +138,9 @@ extern bool arch_uretprobe_is_alive(struct return_instance *ret, enum rp_check c extern bool arch_uprobe_ignore(struct arch_uprobe *aup, struct pt_regs *regs); extern void arch_uprobe_copy_ixol(struct page *page, unsigned long vaddr, void *src, unsigned long len); +extern void uprobe_handle_trampoline(struct pt_regs *regs); +extern void *arch_uprobe_trampoline(unsigned long *psize); +extern unsigned long uprobe_get_trampoline_vaddr(void); #else /* !CONFIG_UPROBES */ struct uprobes_state { }; diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index e4834d23e1d1..c550449d66be 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -1474,11 +1474,20 @@ static int xol_add_vma(struct mm_struct *mm, struct xol_area *area) return ret; } +void * __weak arch_uprobe_trampoline(unsigned long *psize) +{ + static uprobe_opcode_t insn = UPROBE_SWBP_INSN; + + *psize = UPROBE_SWBP_INSN_SIZE; + return &insn; +} + static struct xol_area *__create_xol_area(unsigned long vaddr) { struct mm_struct *mm = current->mm; - uprobe_opcode_t insn = UPROBE_SWBP_INSN; + unsigned long insns_size; struct xol_area *area; + void *insns; area = kmalloc(sizeof(*area), GFP_KERNEL); if (unlikely(!area)) @@ -1502,7 +1511,8 @@ static struct xol_area *__create_xol_area(unsigned long vaddr) /* Reserve the 1st slot for get_trampoline_vaddr() */ set_bit(0, area->bitmap); atomic_set(&area->slot_count, 1); - arch_uprobe_copy_ixol(area->pages[0], 0, &insn, UPROBE_SWBP_INSN_SIZE); + insns = arch_uprobe_trampoline(&insns_size); + arch_uprobe_copy_ixol(area->pages[0], 0, insns, insns_size); if (!xol_add_vma(mm, area)) return area; @@ -1827,7 +1837,7 @@ void uprobe_copy_process(struct task_struct *t, unsigned long flags) * * Returns -1 in case the xol_area is not allocated. */ -static unsigned long get_trampoline_vaddr(void) +unsigned long uprobe_get_trampoline_vaddr(void) { struct xol_area *area; unsigned long trampoline_vaddr = -1; @@ -1878,7 +1888,7 @@ static void prepare_uretprobe(struct uprobe *uprobe, struct pt_regs *regs) if (!ri) return; - trampoline_vaddr = get_trampoline_vaddr(); + trampoline_vaddr = uprobe_get_trampoline_vaddr(); orig_ret_vaddr = arch_uretprobe_hijack_return_addr(trampoline_vaddr, regs); if (orig_ret_vaddr == -1) goto fail; @@ -2123,7 +2133,7 @@ static struct return_instance *find_next_ret_chain(struct return_instance *ri) return ri; } -static void handle_trampoline(struct pt_regs *regs) +void uprobe_handle_trampoline(struct pt_regs *regs) { struct uprobe_task *utask; struct return_instance *ri, *next; @@ -2187,8 +2197,8 @@ static void handle_swbp(struct pt_regs *regs) int is_swbp; bp_vaddr = uprobe_get_swbp_addr(regs); - if (bp_vaddr == get_trampoline_vaddr()) - return handle_trampoline(regs); + if (bp_vaddr == uprobe_get_trampoline_vaddr()) + return uprobe_handle_trampoline(regs); uprobe = find_active_uprobe(bp_vaddr, &is_swbp); if (!uprobe) { From patchwork Sun Apr 21 19:42:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 13637522 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ECD883A1A2; Sun, 21 Apr 2024 19:42:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713728573; cv=none; b=WvvsdzviaB4zgJDMoTcEatiExaRyeVdnX6R3UB0HL8Wu99ctx+2zFmIZzP7Tv2s9Kx6Yqj/XMRFPIecchxfwodFarXJLzkzqrWarsz/Rpsztgf4coIgAsCmOS35OXgShT6uQsc6C1/E3TPhMOcrgsQj1KWWx8bXK3IbkWSHTdHE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713728573; c=relaxed/simple; bh=X3NKIEpwmKsyUxgmoaW6AEzBnvvIxsNfnxPt7ebcd1E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gmInzQtqQkXePP1h8WpJrGK2wLlq0faBC3knMqJ5PwDA+UR3xc5yH8D+Zn1Q33yTdQJWsU/pigYemDNvz9k2wPRgKkiQrHpVIJuQk67wNbb+k8rYXNlP97HcpHQuGFgYe8gIHufVUs5ObsvvXz1qamsfBbCl87cS69Rasec8Mac= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bdONDeQY; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bdONDeQY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B520BC113CE; Sun, 21 Apr 2024 19:42:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713728572; bh=X3NKIEpwmKsyUxgmoaW6AEzBnvvIxsNfnxPt7ebcd1E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bdONDeQYqtOSB2DmNo5syK+xl4CFS3mYTIG0lhBTSZ5zC6gYck/46zruYrf0IFOZQ BQiVzWMyyQBWvu1MSSWX0GmtLZoG+JXU6yKwBWPXUQTToex3rmGJMMjWWsr3UB09Hd bxEg47u5FHB0Iwn7aamw1tHNd2Ef49pA/T4Vj5YPcaj0SfAPraHlRKrH3Sx5VFb7ei 20ifdoN2jgfySM069H0B+HDrLZXn/Jmn4oOQ6yEhsuaSxyaG4pETcE10hdDL9AmEFr cx0lPp8gtmF8PNS7IU9XI6SE6XdoCN8nh4o7eb7VG4/mWDjI1PKK5giFDFxRpar47a z+OwxSqUkViiQ== From: Jiri Olsa To: Steven Rostedt , Masami Hiramatsu , Oleg Nesterov , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-api@vger.kernel.org, x86@kernel.org, bpf@vger.kernel.org, Song Liu , Yonghong Song , John Fastabend , Peter Zijlstra , Thomas Gleixner , "Borislav Petkov (AMD)" , Ingo Molnar , Andy Lutomirski Subject: [PATCHv3 bpf-next 3/7] selftests/bpf: Add uretprobe syscall test for regs integrity Date: Sun, 21 Apr 2024 21:42:02 +0200 Message-ID: <20240421194206.1010934-4-jolsa@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240421194206.1010934-1-jolsa@kernel.org> References: <20240421194206.1010934-1-jolsa@kernel.org> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add uretprobe syscall test that compares register values before and after the uretprobe is hit. It also compares the register values seen from attached bpf program. Acked-by: Andrii Nakryiko Signed-off-by: Jiri Olsa --- tools/include/linux/compiler.h | 4 + .../selftests/bpf/prog_tests/uprobe_syscall.c | 163 ++++++++++++++++++ .../selftests/bpf/progs/uprobe_syscall.c | 15 ++ 3 files changed, 182 insertions(+) create mode 100644 tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c create mode 100644 tools/testing/selftests/bpf/progs/uprobe_syscall.c diff --git a/tools/include/linux/compiler.h b/tools/include/linux/compiler.h index 8a63a9913495..6f7f22ac9da5 100644 --- a/tools/include/linux/compiler.h +++ b/tools/include/linux/compiler.h @@ -62,6 +62,10 @@ #define __nocf_check __attribute__((nocf_check)) #endif +#ifndef __naked +#define __naked __attribute__((__naked__)) +#endif + /* Are two types/vars the same type (ignoring qualifiers)? */ #ifndef __same_type # define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) diff --git a/tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c b/tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c new file mode 100644 index 000000000000..311ac19d8992 --- /dev/null +++ b/tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c @@ -0,0 +1,163 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include + +#ifdef __x86_64__ + +#include +#include +#include +#include "uprobe_syscall.skel.h" + +__naked unsigned long uretprobe_regs_trigger(void) +{ + asm volatile ( + "movq $0xdeadbeef, %rax\n" + "ret\n" + ); +} + +__naked void uretprobe_regs(struct pt_regs *before, struct pt_regs *after) +{ + asm volatile ( + "movq %r15, 0(%rdi)\n" + "movq %r14, 8(%rdi)\n" + "movq %r13, 16(%rdi)\n" + "movq %r12, 24(%rdi)\n" + "movq %rbp, 32(%rdi)\n" + "movq %rbx, 40(%rdi)\n" + "movq %r11, 48(%rdi)\n" + "movq %r10, 56(%rdi)\n" + "movq %r9, 64(%rdi)\n" + "movq %r8, 72(%rdi)\n" + "movq %rax, 80(%rdi)\n" + "movq %rcx, 88(%rdi)\n" + "movq %rdx, 96(%rdi)\n" + "movq %rsi, 104(%rdi)\n" + "movq %rdi, 112(%rdi)\n" + "movq $0, 120(%rdi)\n" /* orig_rax */ + "movq $0, 128(%rdi)\n" /* rip */ + "movq $0, 136(%rdi)\n" /* cs */ + "pushf\n" + "pop %rax\n" + "movq %rax, 144(%rdi)\n" /* eflags */ + "movq %rsp, 152(%rdi)\n" /* rsp */ + "movq $0, 160(%rdi)\n" /* ss */ + + /* save 2nd argument */ + "pushq %rsi\n" + "call uretprobe_regs_trigger\n" + + /* save return value and load 2nd argument pointer to rax */ + "pushq %rax\n" + "movq 8(%rsp), %rax\n" + + "movq %r15, 0(%rax)\n" + "movq %r14, 8(%rax)\n" + "movq %r13, 16(%rax)\n" + "movq %r12, 24(%rax)\n" + "movq %rbp, 32(%rax)\n" + "movq %rbx, 40(%rax)\n" + "movq %r11, 48(%rax)\n" + "movq %r10, 56(%rax)\n" + "movq %r9, 64(%rax)\n" + "movq %r8, 72(%rax)\n" + "movq %rcx, 88(%rax)\n" + "movq %rdx, 96(%rax)\n" + "movq %rsi, 104(%rax)\n" + "movq %rdi, 112(%rax)\n" + "movq $0, 120(%rax)\n" /* orig_rax */ + "movq $0, 128(%rax)\n" /* rip */ + "movq $0, 136(%rax)\n" /* cs */ + + /* restore return value and 2nd argument */ + "pop %rax\n" + "pop %rsi\n" + + "movq %rax, 80(%rsi)\n" + + "pushf\n" + "pop %rax\n" + + "movq %rax, 144(%rsi)\n" /* eflags */ + "movq %rsp, 152(%rsi)\n" /* rsp */ + "movq $0, 160(%rsi)\n" /* ss */ + "ret\n" +); +} + +static void test_uretprobe_regs_equal(void) +{ + struct uprobe_syscall *skel = NULL; + struct pt_regs before = {}, after = {}; + unsigned long *pb = (unsigned long *) &before; + unsigned long *pa = (unsigned long *) &after; + unsigned long *pp; + unsigned int i, cnt; + int err; + + skel = uprobe_syscall__open_and_load(); + if (!ASSERT_OK_PTR(skel, "uprobe_syscall__open_and_load")) + goto cleanup; + + err = uprobe_syscall__attach(skel); + if (!ASSERT_OK(err, "uprobe_syscall__attach")) + goto cleanup; + + uretprobe_regs(&before, &after); + + pp = (unsigned long *) &skel->bss->regs; + cnt = sizeof(before)/sizeof(*pb); + + for (i = 0; i < cnt; i++) { + unsigned int offset = i * sizeof(unsigned long); + + /* + * Check register before and after uretprobe_regs_trigger call + * that triggers the uretprobe. + */ + switch (offset) { + case offsetof(struct pt_regs, rax): + ASSERT_EQ(pa[i], 0xdeadbeef, "return value"); + break; + default: + if (!ASSERT_EQ(pb[i], pa[i], "register before-after value check")) + fprintf(stdout, "failed register offset %u\n", offset); + } + + /* + * Check register seen from bpf program and register after + * uretprobe_regs_trigger call + */ + switch (offset) { + /* + * These values will be different (not set in uretprobe_regs), + * we don't care. + */ + case offsetof(struct pt_regs, orig_rax): + case offsetof(struct pt_regs, rip): + case offsetof(struct pt_regs, cs): + case offsetof(struct pt_regs, rsp): + case offsetof(struct pt_regs, ss): + break; + default: + if (!ASSERT_EQ(pp[i], pa[i], "register prog-after value check")) + fprintf(stdout, "failed register offset %u\n", offset); + } + } + +cleanup: + uprobe_syscall__destroy(skel); +} +#else +static void test_uretprobe_regs_equal(void) +{ + test__skip(); +} +#endif + +void test_uprobe_syscall(void) +{ + if (test__start_subtest("uretprobe_regs_equal")) + test_uretprobe_regs_equal(); +} diff --git a/tools/testing/selftests/bpf/progs/uprobe_syscall.c b/tools/testing/selftests/bpf/progs/uprobe_syscall.c new file mode 100644 index 000000000000..8a4fa6c7ef59 --- /dev/null +++ b/tools/testing/selftests/bpf/progs/uprobe_syscall.c @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "vmlinux.h" +#include +#include + +struct pt_regs regs; + +char _license[] SEC("license") = "GPL"; + +SEC("uretprobe//proc/self/exe:uretprobe_regs_trigger") +int uretprobe(struct pt_regs *ctx) +{ + __builtin_memcpy(®s, ctx, sizeof(regs)); + return 0; +} From patchwork Sun Apr 21 19:42:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 13637523 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A84DB3FB14; Sun, 21 Apr 2024 19:43:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713728584; cv=none; b=gtcWsyvfbsi6YhPdiDgkNip76dBUISNtRQJHIgvQGkItlMvf3tsXNKRzySSaHrf8cT2REfmUGdd5jYQP7JLoPVHFzwxbzxCwZ7RLHo7cXvg8AS80hHYnJu2cSKWfK6NmPGPB//YlZCkxCMQ5F11p3mODWEhPmmGjgiP3ue/HBt4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713728584; c=relaxed/simple; bh=ICIP2D4Qfft573U04UqTjchind/ZIj/yAT/llU/A5k0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CUxnL2Fzuqz5GU96AZH1YaUxjc6tY4yYrl9H3/orutSie5K7NaSbtsc0gjmfa7n2DB7R22eMlEKu9vqWqVeeN3WS+XDpWoKpX5Sy7q5s7pXy8n+1idSMv3b8eyg1p1oujn2ncXn4PgIhO74s7C3lH0SnaeywTmb9dPJxQO1zGEA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Gc9SytYn; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Gc9SytYn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F12E5C113CE; Sun, 21 Apr 2024 19:42:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713728584; bh=ICIP2D4Qfft573U04UqTjchind/ZIj/yAT/llU/A5k0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gc9SytYnKoUHTSESPO8SHBF8ja7pmOqvoLiySMjlmyOrNfRQtcvFj8EmmLXLRPz30 qSRS8CYJZHZuh2xea9TqBVLn/nVI//DJ0WUjS7L13xhKRkHJ6BbfN3CrFZi/DsLwdJ f7TXdXzQxC6tWMafN+M0IOke78hxbV+olxEVWaug0Q9miSTgul2/QQKuQvbC5TK68W HSyx+IvMOqdC0T1IU+jJtMsQ0w+QdpjAPbiCNFBjzMNUx0Fapd5FXRtD6icNFBtcM1 LYlyhOX15zG7zDzLADoymQD1DrJTSLGZ4GIh/lD6DdVbnF/nEgeeg18qTrFY9bgiQc mVh9OiuZAaWzA== From: Jiri Olsa To: Steven Rostedt , Masami Hiramatsu , Oleg Nesterov , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-api@vger.kernel.org, x86@kernel.org, bpf@vger.kernel.org, Song Liu , Yonghong Song , John Fastabend , Peter Zijlstra , Thomas Gleixner , "Borislav Petkov (AMD)" , Ingo Molnar , Andy Lutomirski Subject: [PATCHv3 bpf-next 4/7] selftests/bpf: Add uretprobe syscall test for regs changes Date: Sun, 21 Apr 2024 21:42:03 +0200 Message-ID: <20240421194206.1010934-5-jolsa@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240421194206.1010934-1-jolsa@kernel.org> References: <20240421194206.1010934-1-jolsa@kernel.org> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Adding test that creates uprobe consumer on uretprobe which changes some of the registers. Making sure the changed registers are propagated to the user space when the ureptobe syscall trampoline is used on x86_64. To be able to do this, adding support to bpf_testmod to create uprobe via new attribute file: /sys/kernel/bpf_testmod_uprobe This file is expecting file offset and creates related uprobe on current process exe file and removes existing uprobe if offset is 0. The can be only single uprobe at any time. The uprobe has specific consumer that changes registers used in ureprobe syscall trampoline and which are later checked in the test. Acked-by: Andrii Nakryiko Signed-off-by: Jiri Olsa --- .../selftests/bpf/bpf_testmod/bpf_testmod.c | 123 +++++++++++++++++- .../selftests/bpf/prog_tests/uprobe_syscall.c | 67 ++++++++++ 2 files changed, 189 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c index 39ad96a18123..c832cbb42e74 100644 --- a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c +++ b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "bpf_testmod.h" #include "bpf_testmod_kfunc.h" @@ -343,6 +344,119 @@ static struct bin_attribute bin_attr_bpf_testmod_file __ro_after_init = { .write = bpf_testmod_test_write, }; +/* bpf_testmod_uprobe sysfs attribute is so far enabled for x86_64 only, + * please see test_uretprobe_regs_change test + */ +#ifdef __x86_64__ + +static int +uprobe_ret_handler(struct uprobe_consumer *self, unsigned long func, + struct pt_regs *regs) + +{ + regs->ax = 0x12345678deadbeef; + regs->cx = 0x87654321feebdaed; + regs->r11 = (u64) -1; + return true; +} + +struct testmod_uprobe { + struct path path; + loff_t offset; + struct uprobe_consumer consumer; +}; + +static DEFINE_MUTEX(testmod_uprobe_mutex); + +static struct testmod_uprobe uprobe = { + .consumer.ret_handler = uprobe_ret_handler, +}; + +static int testmod_register_uprobe(loff_t offset) +{ + int err = -EBUSY; + + if (uprobe.offset) + return -EBUSY; + + mutex_lock(&testmod_uprobe_mutex); + + if (uprobe.offset) + goto out; + + err = kern_path("/proc/self/exe", LOOKUP_FOLLOW, &uprobe.path); + if (err) + goto out; + + err = uprobe_register_refctr(d_real_inode(uprobe.path.dentry), + offset, 0, &uprobe.consumer); + if (err) + path_put(&uprobe.path); + else + uprobe.offset = offset; + +out: + mutex_unlock(&testmod_uprobe_mutex); + return err; +} + +static void testmod_unregister_uprobe(void) +{ + mutex_lock(&testmod_uprobe_mutex); + + if (uprobe.offset) { + uprobe_unregister(d_real_inode(uprobe.path.dentry), + uprobe.offset, &uprobe.consumer); + uprobe.offset = 0; + } + + mutex_unlock(&testmod_uprobe_mutex); +} + +static ssize_t +bpf_testmod_uprobe_write(struct file *file, struct kobject *kobj, + struct bin_attribute *bin_attr, + char *buf, loff_t off, size_t len) +{ + unsigned long offset; + int err; + + if (kstrtoul(buf, 0, &offset)) + return -EINVAL; + + if (offset) + err = testmod_register_uprobe(offset); + else + testmod_unregister_uprobe(); + + return err ?: strlen(buf); +} + +static struct bin_attribute bin_attr_bpf_testmod_uprobe_file __ro_after_init = { + .attr = { .name = "bpf_testmod_uprobe", .mode = 0666, }, + .write = bpf_testmod_uprobe_write, +}; + +static int register_bpf_testmod_uprobe(void) +{ + return sysfs_create_bin_file(kernel_kobj, &bin_attr_bpf_testmod_uprobe_file); +} + +static void unregister_bpf_testmod_uprobe(void) +{ + testmod_unregister_uprobe(); + sysfs_remove_bin_file(kernel_kobj, &bin_attr_bpf_testmod_uprobe_file); +} + +#else +static int register_bpf_testmod_uprobe(void) +{ + return 0; +} + +static void unregister_bpf_testmod_uprobe(void) { } +#endif + BTF_KFUNCS_START(bpf_testmod_common_kfunc_ids) BTF_ID_FLAGS(func, bpf_iter_testmod_seq_new, KF_ITER_NEW) BTF_ID_FLAGS(func, bpf_iter_testmod_seq_next, KF_ITER_NEXT | KF_RET_NULL) @@ -650,7 +764,13 @@ static int bpf_testmod_init(void) return ret; if (bpf_fentry_test1(0) < 0) return -EINVAL; - return sysfs_create_bin_file(kernel_kobj, &bin_attr_bpf_testmod_file); + ret = sysfs_create_bin_file(kernel_kobj, &bin_attr_bpf_testmod_file); + if (ret < 0) + return ret; + ret = register_bpf_testmod_uprobe(); + if (ret < 0) + return ret; + return 0; } static void bpf_testmod_exit(void) @@ -664,6 +784,7 @@ static void bpf_testmod_exit(void) msleep(20); sysfs_remove_bin_file(kernel_kobj, &bin_attr_bpf_testmod_file); + unregister_bpf_testmod_uprobe(); } module_init(bpf_testmod_init); diff --git a/tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c b/tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c index 311ac19d8992..1a50cd35205d 100644 --- a/tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c +++ b/tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c @@ -149,15 +149,82 @@ static void test_uretprobe_regs_equal(void) cleanup: uprobe_syscall__destroy(skel); } + +#define BPF_TESTMOD_UPROBE_TEST_FILE "/sys/kernel/bpf_testmod_uprobe" + +static int write_bpf_testmod_uprobe(unsigned long offset) +{ + size_t n, ret; + char buf[30]; + int fd; + + n = sprintf(buf, "%lu", offset); + + fd = open(BPF_TESTMOD_UPROBE_TEST_FILE, O_WRONLY); + if (fd < 0) + return -errno; + + ret = write(fd, buf, n); + close(fd); + return ret != n ? (int) ret : 0; +} + +static void test_uretprobe_regs_change(void) +{ + struct pt_regs before = {}, after = {}; + unsigned long *pb = (unsigned long *) &before; + unsigned long *pa = (unsigned long *) &after; + unsigned long cnt = sizeof(before)/sizeof(*pb); + unsigned int i, err, offset; + + offset = get_uprobe_offset(uretprobe_regs_trigger); + + err = write_bpf_testmod_uprobe(offset); + if (!ASSERT_OK(err, "register_uprobe")) + return; + + uretprobe_regs(&before, &after); + + err = write_bpf_testmod_uprobe(0); + if (!ASSERT_OK(err, "unregister_uprobe")) + return; + + for (i = 0; i < cnt; i++) { + unsigned int offset = i * sizeof(unsigned long); + + switch (offset) { + case offsetof(struct pt_regs, rax): + ASSERT_EQ(pa[i], 0x12345678deadbeef, "rax"); + break; + case offsetof(struct pt_regs, rcx): + ASSERT_EQ(pa[i], 0x87654321feebdaed, "rcx"); + break; + case offsetof(struct pt_regs, r11): + ASSERT_EQ(pa[i], (__u64) -1, "r11"); + break; + default: + if (!ASSERT_EQ(pa[i], pb[i], "register before-after value check")) + fprintf(stdout, "failed register offset %u\n", offset); + } + } +} + #else static void test_uretprobe_regs_equal(void) { test__skip(); } + +static void test_uretprobe_regs_change(void) +{ + test__skip(); +} #endif void test_uprobe_syscall(void) { if (test__start_subtest("uretprobe_regs_equal")) test_uretprobe_regs_equal(); + if (test__start_subtest("uretprobe_regs_change")) + test_uretprobe_regs_change(); } From patchwork Sun Apr 21 19:42:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 13637524 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A31F53FB14; Sun, 21 Apr 2024 19:43:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713728596; cv=none; b=DO4s5P3T4TVYKFwYxr1kvq3Q7f+CFpb7wR+n2WR5MMw6H1+4Uv1GUOpo1jyz/xj20HsRRoYUpdHIPYWVhheH9XkM7lj/RqZB+ah9bgq9V8vBL2Pgh3FDdSMcM62YlaOttNqoxOp7mWD7D3rU307sle7NyeV90uAjdIk4AlBVNnw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713728596; c=relaxed/simple; bh=zXsQFP+lBWcQOzhNUiIZY9EDEZ2vOGD8pKD7bKL08jE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XidYYX0vf+hWCAlyaEKMv2ynEQC6Rcyyt6809PuPAcGCWGSqDk5vqpfSQAqvbRfGiyPa4BUsiQIM40Fcl2DuCuGDE8+XrKGWWAXa79EaIlmJp0JsruO7oZO7icTCrvHUC8bWcu1HS2fQc0clHrINL2U5omYk8DolW4oJuizBoIs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Jn7soWvs; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Jn7soWvs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B21F9C113CE; Sun, 21 Apr 2024 19:43:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713728596; bh=zXsQFP+lBWcQOzhNUiIZY9EDEZ2vOGD8pKD7bKL08jE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jn7soWvs0sLr9hsTFqTnjXPH+4DzuW3o3L0MDPilqGczRK9fX7SmEV5p9Q+3PA8Gc /tHNoVHpEtrnDhSQ+5+FDP1KT83QyT9vyVk12ySLSS2pBl+rViPWm/65YekugUoCG2 vNo+Woa8nRi0iVTJxsnZMLwz3xT+oxNySIhAAhuXJ05FBQR7WcHS7G9+0R8DTf+GMx UygmSGPv5AaWIgi7DFjz+5qpl17T7j+oR6UeramK0hdiWxQBGlqpzveX5XksKttmos ABHkegTKGpBGDKmxyXqXoXz+wiXk3NUDZ96dpY7E6OmmYwbci2KutYpCq7dlunpJNn Smru/o4B/1Mlg== From: Jiri Olsa To: Steven Rostedt , Masami Hiramatsu , Oleg Nesterov , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-api@vger.kernel.org, x86@kernel.org, bpf@vger.kernel.org, Song Liu , Yonghong Song , John Fastabend , Peter Zijlstra , Thomas Gleixner , "Borislav Petkov (AMD)" , Ingo Molnar , Andy Lutomirski Subject: [PATCHv3 bpf-next 5/7] selftests/bpf: Add uretprobe syscall call from user space test Date: Sun, 21 Apr 2024 21:42:04 +0200 Message-ID: <20240421194206.1010934-6-jolsa@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240421194206.1010934-1-jolsa@kernel.org> References: <20240421194206.1010934-1-jolsa@kernel.org> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Adding test to verify that when called from outside of the trampoline provided by kernel, the uretprobe syscall will cause calling process to receive SIGILL signal and the attached bpf program is no executed. Signed-off-by: Jiri Olsa Acked-by: Andrii Nakryiko --- .../selftests/bpf/prog_tests/uprobe_syscall.c | 92 +++++++++++++++++++ .../selftests/bpf/progs/uprobe_syscall_call.c | 15 +++ 2 files changed, 107 insertions(+) create mode 100644 tools/testing/selftests/bpf/progs/uprobe_syscall_call.c diff --git a/tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c b/tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c index 1a50cd35205d..9233210a4c33 100644 --- a/tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c +++ b/tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c @@ -7,7 +7,10 @@ #include #include #include +#include +#include #include "uprobe_syscall.skel.h" +#include "uprobe_syscall_call.skel.h" __naked unsigned long uretprobe_regs_trigger(void) { @@ -209,6 +212,85 @@ static void test_uretprobe_regs_change(void) } } +#ifndef __NR_uretprobe +#define __NR_uretprobe 462 +#endif + +__naked unsigned long uretprobe_syscall_call_1(void) +{ + /* + * Pretend we are uretprobe trampoline to trigger the return + * probe invocation in order to verify we get SIGILL. + */ + asm volatile ( + "pushq %rax\n" + "pushq %rcx\n" + "pushq %r11\n" + "movq $" __stringify(__NR_uretprobe) ", %rax\n" + "syscall\n" + "popq %r11\n" + "popq %rcx\n" + "retq\n" + ); +} + +__naked unsigned long uretprobe_syscall_call(void) +{ + asm volatile ( + "call uretprobe_syscall_call_1\n" + "retq\n" + ); +} + +static void __test_uretprobe_syscall_call(void) +{ + struct uprobe_syscall_call *skel = NULL; + int err; + + skel = uprobe_syscall_call__open_and_load(); + if (!ASSERT_OK_PTR(skel, "uprobe_syscall_call__open_and_load")) + goto cleanup; + + err = uprobe_syscall_call__attach(skel); + if (!ASSERT_OK(err, "uprobe_syscall_call__attach")) + goto cleanup; + + uretprobe_syscall_call(); + +cleanup: + uprobe_syscall_call__destroy(skel); +} + +static void trace_pipe_cb(const char *str, void *data) +{ + if (strstr(str, "uretprobe called") != NULL) + (*(int *)data)++; +} + +static void test_uretprobe_syscall_call(void) +{ + int pid, status, found = 0; + + pid = fork(); + if (!ASSERT_GE(pid, 0, "fork")) + return; + + if (pid == 0) { + __test_uretprobe_syscall_call(); + _exit(0); + } + + waitpid(pid, &status, 0); + + /* verify the child got killed with SIGILL */ + ASSERT_EQ(WIFSIGNALED(status), 1, "WIFSIGNALED"); + ASSERT_EQ(WTERMSIG(status), SIGILL, "WTERMSIG"); + + /* verify the uretprobe program wasn't called */ + ASSERT_OK(read_trace_pipe_iter(trace_pipe_cb, &found, 1000), + "read_trace_pipe_iter"); + ASSERT_EQ(found, 0, "found"); +} #else static void test_uretprobe_regs_equal(void) { @@ -219,6 +301,11 @@ static void test_uretprobe_regs_change(void) { test__skip(); } + +static void test_uretprobe_syscall_call(void) +{ + test__skip(); +} #endif void test_uprobe_syscall(void) @@ -228,3 +315,8 @@ void test_uprobe_syscall(void) if (test__start_subtest("uretprobe_regs_change")) test_uretprobe_regs_change(); } + +void serial_test_uprobe_syscall_call(void) +{ + test_uretprobe_syscall_call(); +} diff --git a/tools/testing/selftests/bpf/progs/uprobe_syscall_call.c b/tools/testing/selftests/bpf/progs/uprobe_syscall_call.c new file mode 100644 index 000000000000..5ea03bb47198 --- /dev/null +++ b/tools/testing/selftests/bpf/progs/uprobe_syscall_call.c @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "vmlinux.h" +#include +#include + +struct pt_regs regs; + +char _license[] SEC("license") = "GPL"; + +SEC("uretprobe//proc/self/exe:uretprobe_syscall_call") +int uretprobe(struct pt_regs *regs) +{ + bpf_printk("uretprobe called"); + return 0; +} From patchwork Sun Apr 21 19:42:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 13637525 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8323F28DDF; Sun, 21 Apr 2024 19:43:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713728608; cv=none; b=jBhC0W3NHT02glj1wTeZbuZIOuYbMZMLjchX3K46zppHkYnvrtJqFY1vmbmaOjjmlG9yqmSCJqW5G2c+DQLKfCmXc5RYhwa2ygit+DjvcjIAN0v3zOsjtTr4F48lHioo5w2pikvMwWx0lQ+w5A0zh5whymmYrMscCSc+RIBiyAg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713728608; c=relaxed/simple; bh=i+DcjfVrFPHPURtr8mJSVqRQ94gO73L1dZ+DRtr/A1Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AVG54EJEOp4iarQPYDwr8ufPPhEgwhVzADm8+ph+fk6STpg0PKK3OzRzd3VZxv+KAz+qj4SpNNcT9tDBjd81gjD5iARszIGB8eBLuvmCU6frco1HlYNNIGxDZcnwP7QSpVXplir5H9GS+Vio00TIUfmbVNi+CTnHIrKePnRu7Ag= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=us4WsazY; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="us4WsazY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF77DC113CE; Sun, 21 Apr 2024 19:43:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713728608; bh=i+DcjfVrFPHPURtr8mJSVqRQ94gO73L1dZ+DRtr/A1Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=us4WsazYeVxuGWocOd7OfDa3SYP1x8dqhruEHiS3dz1eWzZ64gboBxmtTvMsilbrd 3aGFVczTQuPymqRt7uCx8AfXi/heFF5gmptNuMDdDZP6PHYfaDuqrvqgkZwo3oGOlV IDtIBeAMxulwFhz3IIY8iyYXxfe2nnyT6UmX8mHUDABZnXx88FkKMctyAu/SphulAv /i7LofItKZMj+Ed9Fx+GBm2ZEYFqTmtZ95oTOjAXewcQldQSOrT6LUNALHt9aRB6/k 3bCjG0OFSeStk/WCac+efitYPXK+iw6VzrPcHSxzvpi/PyqQOkyA7qCGYFPa/ZRfpj LbjlSRIc3sw+g== From: Jiri Olsa To: Steven Rostedt , Masami Hiramatsu , Oleg Nesterov , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-api@vger.kernel.org, x86@kernel.org, bpf@vger.kernel.org, Song Liu , Yonghong Song , John Fastabend , Peter Zijlstra , Thomas Gleixner , "Borislav Petkov (AMD)" , Ingo Molnar , Andy Lutomirski Subject: [PATCHv3 bpf-next 6/7] selftests/bpf: Add uretprobe compat test Date: Sun, 21 Apr 2024 21:42:05 +0200 Message-ID: <20240421194206.1010934-7-jolsa@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240421194206.1010934-1-jolsa@kernel.org> References: <20240421194206.1010934-1-jolsa@kernel.org> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Adding test that adds return uprobe inside 32 bit task and verify the return uprobe and attached bpf programs get properly executed. Signed-off-by: Jiri Olsa --- tools/testing/selftests/bpf/.gitignore | 1 + tools/testing/selftests/bpf/Makefile | 6 ++- .../selftests/bpf/prog_tests/uprobe_syscall.c | 40 +++++++++++++++++++ .../bpf/progs/uprobe_syscall_compat.c | 13 ++++++ 4 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/bpf/progs/uprobe_syscall_compat.c diff --git a/tools/testing/selftests/bpf/.gitignore b/tools/testing/selftests/bpf/.gitignore index f1aebabfb017..69d71223c0dd 100644 --- a/tools/testing/selftests/bpf/.gitignore +++ b/tools/testing/selftests/bpf/.gitignore @@ -45,6 +45,7 @@ test_cpp /veristat /sign-file /uprobe_multi +/uprobe_compat *.ko *.tmp xskxceiver diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index edc73f8f5aef..d170b63eca62 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -134,7 +134,7 @@ TEST_GEN_PROGS_EXTENDED = test_sock_addr test_skb_cgroup_id_user \ xskxceiver xdp_redirect_multi xdp_synproxy veristat xdp_hw_metadata \ xdp_features bpf_test_no_cfi.ko -TEST_GEN_FILES += liburandom_read.so urandom_read sign-file uprobe_multi +TEST_GEN_FILES += liburandom_read.so urandom_read sign-file uprobe_multi uprobe_compat # Emit succinct information message describing current building step # $1 - generic step name (e.g., CC, LINK, etc); @@ -761,6 +761,10 @@ $(OUTPUT)/uprobe_multi: uprobe_multi.c $(call msg,BINARY,,$@) $(Q)$(CC) $(CFLAGS) -O0 $(LDFLAGS) $^ $(LDLIBS) -o $@ +$(OUTPUT)/uprobe_compat: + $(call msg,BINARY,,$@) + $(Q)echo "int main() { return 0; }" | $(CC) $(CFLAGS) -xc -m32 -O0 - -o $@ + EXTRA_CLEAN := $(SCRATCH_DIR) $(HOST_SCRATCH_DIR) \ prog_tests/tests.h map_tests/tests.h verifier/tests.h \ feature bpftool \ diff --git a/tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c b/tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c index 9233210a4c33..3770254d893b 100644 --- a/tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c +++ b/tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c @@ -11,6 +11,7 @@ #include #include "uprobe_syscall.skel.h" #include "uprobe_syscall_call.skel.h" +#include "uprobe_syscall_compat.skel.h" __naked unsigned long uretprobe_regs_trigger(void) { @@ -291,6 +292,35 @@ static void test_uretprobe_syscall_call(void) "read_trace_pipe_iter"); ASSERT_EQ(found, 0, "found"); } + +static void trace_pipe_compat_cb(const char *str, void *data) +{ + if (strstr(str, "uretprobe compat") != NULL) + (*(int *)data)++; +} + +static void test_uretprobe_compat(void) +{ + struct uprobe_syscall_compat *skel = NULL; + int err, found = 0; + + skel = uprobe_syscall_compat__open_and_load(); + if (!ASSERT_OK_PTR(skel, "uprobe_syscall_compat__open_and_load")) + goto cleanup; + + err = uprobe_syscall_compat__attach(skel); + if (!ASSERT_OK(err, "uprobe_syscall_compat__attach")) + goto cleanup; + + system("./uprobe_compat"); + + ASSERT_OK(read_trace_pipe_iter(trace_pipe_compat_cb, &found, 1000), + "read_trace_pipe_iter"); + ASSERT_EQ(found, 1, "found"); + +cleanup: + uprobe_syscall_compat__destroy(skel); +} #else static void test_uretprobe_regs_equal(void) { @@ -306,6 +336,11 @@ static void test_uretprobe_syscall_call(void) { test__skip(); } + +static void test_uretprobe_compat(void) +{ + test__skip(); +} #endif void test_uprobe_syscall(void) @@ -320,3 +355,8 @@ void serial_test_uprobe_syscall_call(void) { test_uretprobe_syscall_call(); } + +void serial_test_uprobe_syscall_compat(void) +{ + test_uretprobe_compat(); +} diff --git a/tools/testing/selftests/bpf/progs/uprobe_syscall_compat.c b/tools/testing/selftests/bpf/progs/uprobe_syscall_compat.c new file mode 100644 index 000000000000..f8adde7f08e2 --- /dev/null +++ b/tools/testing/selftests/bpf/progs/uprobe_syscall_compat.c @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include +#include + +char _license[] SEC("license") = "GPL"; + +SEC("uretprobe.multi/./uprobe_compat:main") +int uretprobe_compat(struct pt_regs *ctx) +{ + bpf_printk("uretprobe compat\n"); + return 0; +} From patchwork Sun Apr 21 19:42:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 13637526 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B03523FE4B; Sun, 21 Apr 2024 19:43:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713728620; cv=none; b=u490vPHZW1I1WmbaHw8rqyp9+/N6Ofljn3x1kHJZicPA6KnvRo8vCSjVCevn8xWYRGe54jJUOFGZw34joy1TBudQYHelcVhgwB5Qv3MIyeQ65qBpqHSyUgJt4DEtQfCWNIkbNZj9rvMNxgpACDuBXNUKz4f1Je24OkiyxjSfVVc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713728620; c=relaxed/simple; bh=iIPEN5LzK/t1QT6usY68cfJg0ttPxsTTf/Tw7WiSAXk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=svfAwqnSzm64RBD601b3R1oE+maLgdRqw+cnwGOlV7vQaN6XnNFJMxVN0/Fjecgr+uWlsNpcl8GH+5iDy6giAMfYM3mYg1pVNUbpGBUgHx55NFoZ1dARjcjJxnkLfMvMmsIo7qofcJ12Yif2mV4KOxUhOlBJbWtz5AH7hBanE3M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QpN+maUP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QpN+maUP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1710C113CE; Sun, 21 Apr 2024 19:43:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713728620; bh=iIPEN5LzK/t1QT6usY68cfJg0ttPxsTTf/Tw7WiSAXk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QpN+maUPquceVNspLlWizuG9q7VdrvDmDtuZbIYKsEnKOWuvxtDxJqolXNmn7FF0U Cx2E5dlNsZ0S+S2/NCYWFZatGuz3DQyt6yVPBN/MLrohxXEe/lA/K3CuZN9mo5MZLs KdAS3yxsbnvWfzhWJ5N7tf88Z7BG1wlTbJ6QHI/G2p8EeWCnXcprJGrZK4LilrYzDS ybOP9AUBOLIS0R/kG7x6aOtnRqR5Mx9jDLVjTw1MPKGUUUJzxsCFY7qSyEDGmV4MtX O4ExJ1o8TcmhuAi/87nfPyaDrbsotAjJuhdET/fwVGTf8XKCOjoLL+P2DlUGLUZ7qH L6whLvqu6lkog== From: Jiri Olsa To: Steven Rostedt , Masami Hiramatsu , Oleg Nesterov , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-api@vger.kernel.org, x86@kernel.org, bpf@vger.kernel.org, Song Liu , Yonghong Song , John Fastabend , Peter Zijlstra , Thomas Gleixner , "Borislav Petkov (AMD)" , Ingo Molnar , Andy Lutomirski Subject: [PATCH 7/7] man2: Add uretprobe syscall page Date: Sun, 21 Apr 2024 21:42:06 +0200 Message-ID: <20240421194206.1010934-8-jolsa@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240421194206.1010934-1-jolsa@kernel.org> References: <20240421194206.1010934-1-jolsa@kernel.org> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Adding man page for new uretprobe syscall. Signed-off-by: Jiri Olsa --- man2/uretprobe.2 | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 man2/uretprobe.2 diff --git a/man2/uretprobe.2 b/man2/uretprobe.2 new file mode 100644 index 000000000000..c0343a88bb57 --- /dev/null +++ b/man2/uretprobe.2 @@ -0,0 +1,40 @@ +.\" Copyright (C) 2024, Jiri Olsa +.\" +.\" SPDX-License-Identifier: Linux-man-pages-copyleft +.\" +.TH uretprobe 2 (date) "Linux man-pages (unreleased)" +.SH NAME +uretprobe \- execute pending return uprobes +.SH SYNOPSIS +.nf +.B int uretprobe(void) +.fi +.SH DESCRIPTION +On x86_64 architecture the kernel is using uretprobe syscall to trigger +uprobe return probe consumers instead of using standard breakpoint instruction. +The reason is that it's much faster to do syscall than breakpoint trap +on x86_64 architecture. + +The uretprobe syscall is not supposed to be called directly by user, it's allowed +to be invoked only through user space trampoline provided by kernel. +When called from outside of this trampoline, the calling process will receive +.BR SIGILL . + +.SH RETURN VALUE +.BR uretprobe() +return value is specific for given architecture. + +.SH VERSIONS +This syscall is not specified in POSIX, +and details of its behavior vary across systems. +.SH STANDARDS +None. +.SH NOTES +.BR uretprobe() +exists only to allow the invocation of return uprobe consumers. +It should +.B never +be called directly. +Details of the arguments (if any) passed to +.BR uretprobe () +and the return value are specific for given architecture.