Linux Trace Kernel
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sahil Siddiq" <sahilcdq0@gmail.com>
Cc: linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v3 4/4] openrisc: Add Kretprobes
Date: Mon, 26 Oct 2026 20:28:44 +0000	[thread overview]
Message-ID: <sashiko-outbox-185721@kernel.org> (raw)
In-Reply-To: <20261026201240.107462-5-sahilcdq0@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] openrisc: missing NOKPROBE annotation on arch_rethook_trampoline()
--

commit 20e73d01661b40600429433415de2e9c63032d8f
Author: Sahil Siddiq <sahilcdq0@gmail.com>

openrisc: Add Kretprobes

This commit adds Kretprobes support for OpenRISC on top of the generic
rethook framework, providing arch_rethook_prepare(),
arch_rethook_trampoline_callback(), and the assembly return trampoline
arch_rethook_trampoline.

> diff --git a/arch/openrisc/kernel/rethook_trampoline.S b/arch/openrisc/kernel/rethook_trampoline.S
> new file mode 100644
> index 0000000000000..5e8fd5a652222
> --- /dev/null
> +++ b/arch/openrisc/kernel/rethook_trampoline.S
> @@ -0,0 +1,111 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +/*
> + * Author: Sahil Siddiq <sahilcdq0@gmail.com>
> + */
> +
> +#include <linux/linkage.h>
> +
> +#include <asm/asm.h>

[ ... ]

> +SYM_CODE_START(arch_rethook_trampoline)
> +	/* Allocate enough space on stack for pt_regs */
> +	l.addi	r1,r1,-PT_SIZE
> +	save_all_base_regs
> +
> +	l.addi	r3,r1,0	/* pt_regs */
> +	l.jal	arch_rethook_trampoline_callback
> +	l.nop
> +
> +	/* use the result as the return-address */
> +	l.addi	r9,r11,0
> +
> +	restore_all_base_regs
> +	l.addi	r1,r1,PT_SIZE
> +
> +	l.jr	r9
> +	l.nop
> +SYM_CODE_END(arch_rethook_trampoline)

[Severity: High]
Should arch_rethook_trampoline be marked with _ASM_NOKPROBE() here (or
NOKPROBE_SYMBOL() in arch/openrisc/kernel/rethook.c)?

Although arch/openrisc/kernel/rethook_trampoline.S includes <asm/asm.h> and
arch/openrisc/kernel/rethook.c marks arch_rethook_trampoline_callback() and
arch_rethook_prepare() with NOKPROBE_SYMBOL(), arch_rethook_trampoline is
placed in .text without a kprobe blacklist annotation.

Because arch_rethook_trampoline is not blacklisted, registering a kretprobe
or kprobe on arch_rethook_trampoline is permitted. When a kretprobed function
returns to arch_rethook_trampoline with r9 holding the address of
arch_rethook_trampoline, a kretprobe on arch_rethook_trampoline triggers:

pre_handler_kretprobe()
  rethook_hook()
    arch_rethook_prepare()
      rhn->ret_addr = regs->gpr9;

which pushes a rethook_node with ret_addr set to arch_rethook_trampoline onto
current->rethooks. When arch_rethook_trampoline_callback() then calls
rethook_trampoline_handler(), __rethook_find_ret_addr() skips nodes whose
ret_addr equals arch_rethook_trampoline:

kernel/trace/rethook.c:__rethook_find_ret_addr() {
    ...
	while (node) {
		rh = container_of(node, struct rethook_node, llist);
		if (rh->ret_addr != (unsigned long)arch_rethook_trampoline) {
			*cur = node;
			return rh->ret_addr;
		}
		node = node->next;
	}
	return 0;
}

Can this corrupt the current->rethooks shadow stack or trigger the BUG_ON(1)
in rethook_trampoline_handler() when a probe is attached to
arch_rethook_trampoline?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261026201240.107462-1-sahilcdq0@gmail.com?part=4

      reply	other threads:[~2026-10-26 20:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260930202744.50489-1-sahilcdq0@gmail.com>
2026-10-26 20:12 ` [PATCH v3 0/4] openrisc: Add support for KProbes and Kretprobes Sahil Siddiq
2026-10-26 20:12 ` [PATCH v3 1/4] openrisc: Add utilities and clean up simulation of instructions Sahil Siddiq
2026-10-26 20:12 ` [PATCH v3 2/4] openrisc: Add KProbes Sahil Siddiq
2026-10-26 20:26   ` Sahil
2026-10-26 20:35   ` sashiko-bot
2026-10-26 20:12 ` [PATCH v3 3/4] openrisc: Add unit tests for KProbes on branch instructions Sahil Siddiq
2026-10-26 20:26   ` sashiko-bot
2026-10-26 20:12 ` [PATCH v3 4/4] openrisc: Add Kretprobes Sahil Siddiq
2026-10-26 20:28   ` sashiko-bot [this message]

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-185721@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=sahilcdq0@gmail.com \
    --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