From: sashiko-bot@kernel.org
To: "Markus Probst" <markus.probst@posteo.de>
Cc: linux-leds@vger.kernel.org, linux-pci@vger.kernel.org,
lee@kernel.org, ojeda@kernel.org
Subject: Re: [PATCH RESEND v23 1/3] rust: leds: add basic led classdev abstractions
Date: Wed, 19 Aug 2026 19:14:23 +0000 [thread overview]
Message-ID: <20260819191423.9B4931F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260819-rust_leds-v23-1-2716a4ef89a4@posteo.de>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] The `blink_set_callback` creates aliased mutable references if `delay_on` and `delay_off` point to the same memory location.
- [High] The lifetime bound `'bound: 'init` on `DeviceBuilder::build` is inverted, allowing the Device to outlive its borrowed C strings.
- [Medium] The commit message description is not capitalized after the subsystem prefix.
- [Low] Small functions in abstractions must be annotated with `#[inline]`.
--
--- Patch [1]: [PATCH RESEND v23 1/3] rust: leds: add basic led classdev abstractions ---
commit 0bee73d85d7c6052f28b0588d95b4632e4bdc662
Author: Markus Probst <markus.probst@posteo.de>
rust: leds: add basic led classdev abstractions
Implement the core abstractions needed for led class devices, including
the Device builder and LedOps trait.
> rust: leds: add basic led classdev abstractions
[Severity: Medium]
This isn't a bug, but the subsystem guidelines request capitalizing the
description after the subsystem prefix. Should this be "rust: leds: Add
basic led classdev abstractions" instead?
> diff --git a/rust/kernel/led.rs b/rust/kernel/led.rs
> index 596975e103b8b.....
> --- /dev/null
> +++ b/rust/kernel/led.rs
[ ... ]
> +impl TryFrom<u32> for Color {
> + type Error = Error;
> +
> + fn try_from(value: u32) -> core::result::Result<Self, Self::Error> {
[Severity: Low]
This isn't a bug, but the Rust subsystem guidelines specify that small
functions in abstractions should be annotated with #[inline]. Could we add
that attribute to this try_from() implementation?
> diff --git a/rust/kernel/led/normal.rs b/rust/kernel/led/normal.rs
> index 816db7c576894.....
> --- /dev/null
> +++ b/rust/kernel/led/normal.rs
[ ... ]
> +impl<'init, S: DeviceBuilderState> DeviceBuilder<'init, S> {
> + /// Registers a new [`Device`].
> + pub fn build<'bound: 'init, T: LedOps + 'bound>(
> + self,
> + parent: &'bound T::Bus,
> + ops: impl PinInit<T, Error> + 'init,
> + ) -> impl PinInit<Device<'bound, T>, Error> + 'init {
[Severity: High]
Is the lifetime bound 'bound: 'init inverted here?
DeviceBuilder captures string references with the 'init lifetime. If the
returned Device has a 'bound lifetime that outlives 'init, a caller could
create a Device that escapes the scope of the borrowed strings.
Since the underlying C led_classdev stores raw pointers to these strings,
could this lead to a use-after-free when accessed via sysfs if the strings
are dropped?
[ ... ]
> + unsafe extern "C" fn blink_set_callback(
> + led_cdev: *mut bindings::led_classdev,
> + delay_on: *mut usize,
> + delay_off: *mut usize,
> + ) -> i32 {
[ ... ]
> + classdev.ops.blink_set(
> + parent,
> + classdev,
> + // SAFETY: The function's contract guarantees that `delay_on` points to a `usize`
> + // and is exclusive for the period of this function.
> + unsafe { &mut *delay_on },
> + // SAFETY: The function's contract guarantees that `delay_off` points to a `usize`
> + // and is exclusive for the period of this function.
> + unsafe { &mut *delay_off },
> + )?;
[Severity: High]
Does this create aliased mutable references if the C subsystem passes the
same pointer for delay_on and delay_off?
The C LED subsystem explicitly permits and frequently passes the exact same
pointer for both arguments. For example, led_blink_set_oneshot() in
ledtrig-netdev.c passes identical pointers.
If both pointers are identical, converting them concurrently into two
&mut usize references triggers undefined behavior in Rust. Could we handle
this aliasing safely?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260819-rust_leds-v23-0-2716a4ef89a4@posteo.de?part=1
next prev parent reply other threads:[~2026-08-19 19:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-19 18:58 [PATCH RESEND v23 0/3] rust: leds: add led classdev abstractions Markus Probst
2026-08-19 18:58 ` [PATCH RESEND v23 1/3] rust: leds: add basic " Markus Probst
2026-08-19 19:14 ` sashiko-bot [this message]
2026-08-19 18:58 ` [PATCH RESEND v23 2/3] rust: leds: add Mode trait Markus Probst
2026-08-19 19:11 ` sashiko-bot
2026-08-19 18:58 ` [PATCH RESEND v23 3/3] rust: leds: add multicolor classdev abstractions Markus Probst
2026-08-19 19:10 ` sashiko-bot
-- strict thread matches above, loose matches on Subject: below --
2026-08-05 19:34 [PATCH RESEND v23 0/3] rust: leds: add led " Markus Probst via B4 Relay
2026-08-05 19:34 ` [PATCH RESEND v23 1/3] rust: leds: add basic " Markus Probst via B4 Relay
2026-08-05 19:34 ` Markus Probst
2026-08-05 20:33 ` 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=20260819191423.9B4931F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=lee@kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=markus.probst@posteo.de \
--cc=ojeda@kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.