From: sashiko-bot@kernel.org
To: wen.yang@linux.dev
Cc: linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v5 2/9] rv: Add generic uprobe infrastructure for RV monitors
Date: Wed, 19 Aug 2026 18:27:00 +0000 [thread overview]
Message-ID: <20260819182701.039F81F000E9@smtp.kernel.org> (raw)
In-Reply-To: <683751e6d588baf407a96a0a7a2e9ec12c5d865b.1787161646.git.wen.yang@linux.dev>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] The `rv_uprobe_unregister_nosync` API destroys state needed for safe batch cleanup, leading to resource leaks or double-frees.
- [High] The `DECLARE_RV_UPROBE` macro fails to zero-initialize the structure, risking execution of uninitialized function pointers.
- [Medium] The commit message explicitly contradicts the code regarding path release in `rv_uprobe_unregister_nosync`.
--
--- Patch [2]: [PATCH v5 2/9] rv: Add generic uprobe infrastructure for RV monitors ---
commit 51a0e9ee4d8b7c0315a129cc3c664429f117eeb4
Author: Wen Yang <wen.yang@linux.dev>
rv: Add generic uprobe infrastructure for RV monitors
Monitors that instrument user-space function boundaries need to resolve
paths, register uprobes, and deregister them safely. Provide a thin
wrapper so monitors share a single implementation of this boilerplate.
> The path is released in
> rv_uprobe_unregister_nosync() after the consumer has been removed.
[Severity: Medium]
The commit message states that the path is released in
rv_uprobe_unregister_nosync() after the consumer has been removed.
Is this description accurate?
Looking at the code for rv_uprobe_unregister_nosync(), it explicitly
defers releasing the path to the caller. Could the commit message be
updated to match the actual implementation?
> diff --git a/include/rv/rv_uprobe.h b/include/rv/rv_uprobe.h
> index 0000000000000..d0a9079ac5be4
> --- /dev/null
> +++ b/include/rv/rv_uprobe.h
[ ... ]
> +/* Embed a named rv_uprobe inside a caller struct */
> +#define DECLARE_RV_UPROBE(name) struct rv_uprobe name
[Severity: High]
Does this macro zero-initialize the structure?
Since it simply expands to a struct declaration, local variables using
this macro might contain stack garbage. If a caller only sets p->uc.handler,
could this leave other uprobe_consumer fields like filter or ret_handler
uninitialized, causing the uprobe subsystem to execute random memory when
triggered?
> diff --git a/kernel/trace/rv/rv_uprobe.c b/kernel/trace/rv/rv_uprobe.c
> index 0000000000000..b412a8e28a6ec
> --- /dev/null
> +++ b/kernel/trace/rv/rv_uprobe.c
[ ... ]
> +int rv_uprobe_register(const char *binpath, loff_t offset, struct rv_uprobe *p)
> +{
> + struct inode *inode;
> + int ret;
[ ... ]
> + p->uprobe = uprobe_register(inode, offset, 0, &p->uc);
> + if (IS_ERR(p->uprobe)) {
> + ret = PTR_ERR(p->uprobe);
> + p->uprobe = NULL;
> + path_put(&p->path);
> + return ret;
> + }
> +
> + return 0;
> +}
[Severity: High]
When uprobe_register() fails, path_put() is called, but p->path is not
cleared. If a caller blindly loops over an array of probes to clean up
paths later, could this leave dangling pointers that result in a
double-free?
[ ... ]
> +void rv_uprobe_unregister(struct rv_uprobe *p)
> +{
> + if (!p || !p->uprobe)
> + return;
> +
> + uprobe_unregister_nosync(p->uprobe, &p->uc);
> + p->uprobe = NULL;
> + rv_uprobe_sync();
> + path_put(&p->path);
> +}
[ ... ]
> +void rv_uprobe_unregister_nosync(struct rv_uprobe *p)
> +{
> + if (!p || !p->uprobe)
> + return;
> +
> + uprobe_unregister_nosync(p->uprobe, &p->uc);
> + p->uprobe = NULL;
> + /* path held; caller must call rv_uprobe_sync() then path_put(&p->path) */
> +}
[Severity: High]
By setting p->uprobe to NULL here, does rv_uprobe_unregister_nosync()
destroy the state needed to safely perform the path cleanup?
If a caller attempts to use rv_uprobe_unregister() to clean up paths
after a batch of nosync operations, it will return early because
p->uprobe is NULL, silently leaking the VFS path reference:
rv_uprobe_unregister() {
if (!p || !p->uprobe)
return;
...
}
Alternatively, without external shadow state, how can a caller
distinguish between a successfully unregistered probe that needs a
path_put() and a probe that failed registration initially?
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1787161646.git.wen.yang@linux.dev?part=2
next prev parent reply other threads:[~2026-08-19 18:27 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-19 18:15 [PATCH v5 0/9] rv: Add task latency over budget RV monitor wen.yang
2026-08-19 18:15 ` [PATCH v5 1/9] rv: Introduce DA_MON_ALLOCATION_STRATEGY wen.yang
2026-08-19 18:30 ` sashiko-bot
2026-08-19 18:15 ` [PATCH v5 2/9] rv: Add generic uprobe infrastructure for RV monitors wen.yang
2026-08-19 18:27 ` sashiko-bot [this message]
2026-08-19 18:15 ` [PATCH v5 3/9] rv: Add tlob model DOT file wen.yang
2026-08-19 18:25 ` sashiko-bot
2026-08-19 18:15 ` [PATCH v5 4/9] rv: Fix ha_invariant_passed_ns silent bypass of invariant check wen.yang
2026-08-19 18:32 ` sashiko-bot
2026-08-19 18:15 ` [PATCH v5 5/9] rv: Make da_monitor_reset_hook and EVENT_NONE_LBL overridable wen.yang
2026-08-19 18:30 ` sashiko-bot
2026-08-19 18:15 ` [PATCH v5 6/9] rv: Add tlob hybrid automaton monitor wen.yang
2026-08-19 18:34 ` sashiko-bot
2026-08-19 18:15 ` [PATCH v5 7/9] rv: Add KUnit tests for the tlob monitor wen.yang
2026-08-19 18:24 ` sashiko-bot
2026-08-19 18:15 ` [PATCH v5 8/9] selftests/verification: Add tlob selftests wen.yang
2026-08-19 18:27 ` sashiko-bot
2026-08-19 18:15 ` [PATCH v5 9/9] selftests/ftrace: Walk up to find test.d/functions when a subdirectory is passed wen.yang
2026-08-19 18:31 ` 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=20260819182701.039F81F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=wen.yang@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