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 v4 3/4] rv/reactors: export rv_register_reactor() and rv_unregister_reactor()
Date: Thu, 27 Aug 2026 18:48:51 +0000	[thread overview]
Message-ID: <20260827184851.E998D1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <888aca9131b5e9c80ac5085f964099b5090e7185.1787854397.git.wen.yang@linux.dev>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Exporting `rv_register_reactor()` and `rv_unregister_reactor()` allows dynamically loaded modules to register reactors. However, `rv_unregister_reactor()` fails to detach the reactor from monitors currently using it, and `struct rv_reactor` lacks an `owner` field to pin the module in memory. This leads to a dangling pointer and use-after-free when a reactor module is unloaded.
--

commit f153a63763986ecb001f784d45c5262d45c8d0a5
Author: Wen Yang <wen.yang@linux.dev>
Subject: rv/reactors: export rv_register_reactor() and rv_unregister_reactor()

This commit exports rv_register_reactor() and rv_unregister_reactor() so
that dynamically loaded modules and KUnit tests can register and unregister
reactors without link-time errors.

> diff --git a/kernel/trace/rv/rv_reactors.c b/kernel/trace/rv/rv_reactors.c
> index afc97d0971091..606c530de2f04 100644
> --- a/kernel/trace/rv/rv_reactors.c
> +++ b/kernel/trace/rv/rv_reactors.c
> @@ -314,6 +314,7 @@ int rv_register_reactor(struct rv_reactor *reactor)
>  	guard(mutex)(&rv_interface_lock);
>  	return __rv_register_reactor(reactor);
>  }
> +EXPORT_SYMBOL_GPL(rv_register_reactor);

[ ... ]

> @@ -327,6 +328,7 @@ int rv_unregister_reactor(struct rv_reactor *reactor)
>  	list_del(&reactor->list);
>  	return 0;
>  }
> +EXPORT_SYMBOL_GPL(rv_unregister_reactor);

[Severity: High]
By exporting these functions, dynamic modules can now register and unregister
reactors. However, when a module is unloaded and calls rv_unregister_reactor(),
does this leave dangling pointers in monitors that are currently using it?

Looking at how monitors assign reactors, struct rv_reactor lacks an owner
field to pin the module in memory:

kernel/trace/rv/rv_reactors.c:monitor_swap_reactors_single() {
    ...
	mon->reactor = reactor;
	mon->react = reactor->react;
    ...
}

Since rv_unregister_reactor() only removes the reactor from the global list
without clearing active monitor references, won't rv_react() later execute a
dangling pointer when an event triggers?

kernel/trace/rv/rv_reactors.c:rv_react() {
    ...
	monitor->react(msg, args);
    ...
}

Could this result in a use-after-free pointing to unmapped module memory if
an authorized user unloads a reactor module that is still attached to an
active monitor?

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

  reply	other threads:[~2026-08-27 18:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-27 18:22 [PATCH v4 0/4] rv/reactors: fix lockdep warning and add KUnit tests wen.yang
2026-08-27 18:22 ` [PATCH v4 1/4] rv/reactors: use LD_WAIT_SPIN as the reactor lockdep wait type wen.yang
2026-08-27 18:36   ` sashiko-bot
2026-08-31  9:48   ` Gabriele Monaco
2026-08-27 18:22 ` [PATCH v4 2/4] rv/reactors: propagate rv_register_reactor() error from reactor init wen.yang
2026-08-27 18:22 ` [PATCH v4 3/4] rv/reactors: export rv_register_reactor() and rv_unregister_reactor() wen.yang
2026-08-27 18:48   ` sashiko-bot [this message]
2026-08-27 18:22 ` [PATCH v4 4/4] rv/reactors: add KUnit tests for reactor registration and dispatch wen.yang
2026-08-27 19:02   ` 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=20260827184851.E998D1F00A3A@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