Linux Trace Kernel
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: wen.yang@linux.dev
Cc: linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v7 09/14] rv: Add generic uprobe infrastructure for RV monitors
Date: Sun, 11 Oct 2026 19:49:10 +0000	[thread overview]
Message-ID: <sashiko-outbox-167418@kernel.org> (raw)
In-Reply-To: <1f311bb81a9270391bb9d3aa03b8b881de928c1a.1791745088.git.wen.yang@linux.dev>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] uprobes: missing vfsmount reference leads to VFS BUG on unmount
- [Medium] uprobes: double registration leaks inode reference and corrupts consumer list
- [Low] uprobes: missing <linux/export.h> inclusion
--

commit 27eb3c739b9acf445ce512a1c9be0a7dca8bace0
Author: Wen Yang <wen.yang@linux.dev>

rv: Add generic uprobe infrastructure for RV monitors

Monitors that instrument user-space function boundaries need to register
uprobes and deregister them safely. Provide a thin wrapper so monitors
share a single implementation of this boilerplate.

> diff --git a/include/rv/rv_uprobe.h b/include/rv/rv_uprobe.h
> new file mode 100644
> index 0000000000000..b93c2a81bc228
> --- /dev/null
> +++ b/include/rv/rv_uprobe.h
[ ... ]
> +/*
> + * Free the containing struct only after rv_uprobe_unregister_nosync() +
> + * rv_uprobe_unregister_sync() + iput(p->inode).
> + *
> + * The inode reference does not pin the dentry, so callers that re-resolve the
> + * probed path must hold a struct path: 9p cache=none remints an inode per
> + * lookup.
> + */
> +struct rv_uprobe {
> +	struct uprobe_consumer	uc;
> +	struct uprobe		*uprobe;
> +	struct inode		*inode;
> +};

[Severity: High]
Does this struct need to hold a reference to the vfsmount as well?

The core uprobes API documents that the caller of uprobe_register() is
required to keep the inode and the containing mount referenced. 

If the infrastructure only pins the inode via igrab(), and the caller does
not independently hold a mount reference, user-space could unmount the
filesystem while the monitor is active.

During unmount, the elevated inode i_count from igrab prevents eviction,
which causes the VFS superblock shutdown sequence in generic_shutdown_super()
to trigger a bug for busy inodes after unmount.

[ ... ]
> diff --git a/kernel/trace/rv/rv_uprobe.c b/kernel/trace/rv/rv_uprobe.c
> new file mode 100644
> index 0000000000000..1c7f8466aeedd
> --- /dev/null
> +++ b/kernel/trace/rv/rv_uprobe.c
[ ... ]
> +/*
> + * uprobe_register() takes no inode reference of its own, so grab one here and
> + * drop it only after rv_uprobe_unregister_sync().
> + */
> +int rv_uprobe_register(struct inode *inode, loff_t offset, struct rv_uprobe *p)
> +{
> +	int ret;
> +
> +	p->inode = igrab(inode);

[Severity: Medium]
What happens if rv_uprobe_register() is called on an already registered
struct rv_uprobe?

Since p->inode is unconditionally overwritten with igrab(inode), the previous
inode reference seems to be leaked without calling iput().

Additionally, passing an actively linked uprobe_consumer to uprobe_register()
again could corrupt the uprobe subsystem's internal consumer lists.

Would it be safer to check if p->inode is already set before proceeding?

> +	if (!p->inode)
> +		return -ESTALE;
> +
> +	p->uprobe = uprobe_register(inode, offset, 0, &p->uc);
> +	if (IS_ERR(p->uprobe)) {
> +		ret = PTR_ERR(p->uprobe);
> +		p->uprobe = NULL;
> +		iput(p->inode);
> +		p->inode = NULL;
> +		return ret;
> +	}
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(rv_uprobe_register);

[Severity: Low]
Could this EXPORT_SYMBOL_GPL usage cause build failures on some architectures?

The source file uses EXPORT_SYMBOL_GPL but does not explicitly include
<linux/export.h>. Relying on implicit transitive inclusion of this header
can lead to build breakages on alternative configurations.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1791745088.git.wen.yang@linux.dev?part=9

  reply	other threads:[~2026-10-11 19:49 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-11 19:39 [PATCH v7 00/14] rv: Add task latency over budget RV monitor wen.yang
2026-10-11 19:39 ` [PATCH v7 01/14] rv: Force environment reset action on HA monitor start wen.yang
2026-10-11 19:39 ` [PATCH v7 02/14] rv: Fix ha_monitor timer and invariant underflow wen.yang
2026-10-11 19:39 ` [PATCH v7 03/14] rv: Add a KUnit test for the HA timer underflow wen.yang
2026-10-11 19:52   ` sashiko-bot
2026-10-12  7:47   ` kernel test robot
2026-10-12  9:27   ` kernel test robot
2026-10-12 11:18   ` kernel test robot
2026-10-11 19:39 ` [PATCH v7 04/14] rv: Disarm HA timers on the storage free path wen.yang
2026-10-11 19:51   ` sashiko-bot
2026-10-11 19:39 ` [PATCH v7 05/14] rv: Add a KUnit test for " wen.yang
2026-10-11 19:50   ` sashiko-bot
2026-10-11 19:39 ` [PATCH v7 06/14] rv: Make da_monitor_reset_hook and EVENT_NONE_LBL overridable wen.yang
2026-10-11 19:53   ` sashiko-bot
2026-10-11 19:39 ` [PATCH v7 07/14] rv: Introduce DA_MON_ALLOCATION_STRATEGY wen.yang
2026-10-11 19:57   ` sashiko-bot
2026-10-11 19:39 ` [PATCH v7 08/14] rv: Add per-object teardown hook da_extra_cleanup wen.yang
2026-10-11 19:54   ` sashiko-bot
2026-10-11 19:39 ` [PATCH v7 09/14] rv: Add generic uprobe infrastructure for RV monitors wen.yang
2026-10-11 19:49   ` sashiko-bot [this message]
2026-10-11 19:39 ` [PATCH v7 10/14] rv: Add tlob model DOT file wen.yang
2026-10-11 19:39 ` [PATCH v7 11/14] rv: Add tlob hybrid automaton monitor wen.yang
2026-10-11 19:58   ` sashiko-bot
2026-10-11 19:39 ` [PATCH v7 12/14] rv: Add KUnit tests for the tlob monitor wen.yang
2026-10-11 19:39 ` [PATCH v7 13/14] selftests/verification: Add tlob selftests wen.yang
2026-10-11 19:51   ` sashiko-bot
2026-10-11 19:39 ` [PATCH v7 14/14] selftests/ftrace: Walk up parent dirs to find test.d/functions wen.yang
2026-10-12 11:58 ` [PATCH v7 00/14] rv: Add task latency over budget RV monitor Gabriele Monaco

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-167418@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