From: sashiko-bot@kernel.org
To: "Ayush Singh" <ayush@beagleboard.org>
Cc: conor+dt@kernel.org, robh@kernel.org, ojeda@kernel.org,
devicetree@vger.kernel.org
Subject: Re: [PATCH v2 5/7] drivers: greybus: Add software SVC implementation
Date: Thu, 27 Aug 2026 08:09:21 +0000 [thread overview]
Message-ID: <20260827080921.B2A511F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260827-gb-uart-transport-v2-5-a03bb1f5fbd1@beagleboard.org>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] `Msg<P>` unsoundly implements `AsBytes` for an unconstrained `P`, allowing types with pointers, padding, or interior mutability to be read as bytes.
- [High] Kconfig `GREYBUS_SOFTSVC` relies on the `kernel::greybus` Rust module but lacks a dependency on `RUST_GREYBUS_ABSTRACTIONS`.
- [High] The `message_send` function calls `intf_by_id`, which acquires a `Mutex` (`self.intf_map.lock()`), but `message_send` can be called from atomic contexts.
- [Medium] Integer underflow panic in `Svc::intf_by_id` if `id` is 0.
--
commit 7f12c32b073d73645edd3aaf941609c3637db70d
Author: Ayush Singh <ayush@beagleboard.org>
drivers: greybus: Add software SVC implementation
This commit adds gb-softsvc, a Rust implementation of the Greybus SVC
(Supervisory Controller) that lives in the kernel. It provides an SVC
emulation for host drivers on transports without a native SVC.
Link: https://lore.kernel.org/all/20260622-nova-exports-v5-0-6191773fc977@nvidia.com/
> diff --git a/drivers/greybus/Kconfig b/drivers/greybus/Kconfig
> index 3bf3b86914423..381d1a6ee135c 100644
> --- a/drivers/greybus/Kconfig
> +++ b/drivers/greybus/Kconfig
[ ... ]
> @@ -48,5 +48,17 @@ config GREYBUS_ES2
> To compile this code as a module, choose M here: the module
> will be called gb-es2.ko
>
> +config GREYBUS_SOFTSVC
> + tristate "Greybus software SVC"
> + depends on RUST
[Severity: High]
Will this fail to build if RUST_GREYBUS_ABSTRACTIONS is disabled?
Since this driver relies on the kernel::greybus Rust module, it seems it
needs a dependency on RUST_GREYBUS_ABSTRACTIONS to ensure the abstractions
are compiled in.
> + help
> + Select this option to enable a software implementation of the
> + Greybus SVC (Supervisory Controller) running in the kernel. It can
[ ... ]
> diff --git a/drivers/greybus/gb_softsvc.rs b/drivers/greybus/gb_softsvc.rs
> new file mode 100644
> index 0000000000000..79e2752e42ba0
> --- /dev/null
> +++ b/drivers/greybus/gb_softsvc.rs
[ ... ]
> +#[repr(C, packed)]
> +struct Msg<P> {
> + hdr: protocols::GbOperationMsgHdr,
> + payload: P,
> +}
> +
> +// SAFETY: `Msg` is a POD type with no padding and no interior mutability.
> +unsafe impl<P> kernel::transmute::AsBytes for Msg<P> {}
[Severity: High]
Does this implementation allow unsound transmutations for unconstrained types?
Because P is generic and lacks bounds, any type could be instantiated here,
including types with pointers, padding, or interior mutability. Should this
implementation require P: kernel::transmute::AsBytes to ensure the type
is actually safe to read as bytes?
[ ... ]
> +#[pin_data]
> +struct Svc {
> + #[pin]
> + svc_operation_id: SpinLock<IdPool>,
> + // Pos 0 = INTF_ID_START
> + #[pin]
> + intf_map: Mutex<[Option<Arc<dyn InterfaceOps>>; INTF_MAP_LEN]>,
> +}
[ ... ]
> + fn intf_by_id(&self, id: u8) -> Result<Arc<dyn InterfaceOps>> {
> + let id = id - INTF_ID_START;
[Severity: Medium]
Can this subtraction underflow and cause a kernel panic?
If a malformed message or core bug routes a message to the AP interface
(where id is 0), id - INTF_ID_START will underflow since INTF_ID_START
is 1.
> + let guard = self.intf_map.lock();
> +
> + guard
> + .get(usize::from(id))
> + .ok_or(code::ENODEV)?
> + .as_ref()
> + .ok_or(code::ENODEV)
> + .cloned()
> + }
[ ... ]
> +#[vtable]
> +impl hd::HdDriver for GbHdDriver {
> + fn message_send(
> + data: &Self,
> + dest_cport_id: u16,
> + msg: &greybus::Message,
> + gfp_mask: Flags,
> + ) -> Result {
> + if dest_cport_id == protocols::GB_SVC_CPORT_ID {
> + data.0.handler(msg)
> + } else {
> + let conn = msg.operation().connection();
> + let intf = data.0.intf_by_id(conn.interface().unwrap().id())?;
[Severity: High]
Can this lead to a scheduling-while-atomic oops?
The Greybus core can call message_send() from atomic contexts (which is why
it passes a gfp_mask). However, intf_by_id() acquires intf_map.lock(), which
is a sleepable Mutex. Should intf_map use a SpinLock instead to prevent
sleeping in atomic context?
> +
> + let mut buf = KVec::with_capacity(msg.header().size().into(), gfp_mask)?;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260827-gb-uart-transport-v2-0-a03bb1f5fbd1@beagleboard.org?part=5
next prev parent reply other threads:[~2026-08-27 8:09 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 7:54 [PATCH v2 0/7] Add Greybus Sotfsvc and UART Node drivers Ayush Singh
2026-08-27 7:54 ` [PATCH v2 1/7] greybus: connection: Export gb_connection_get() and gb_connection_put() Ayush Singh
2026-08-27 7:54 ` [PATCH v2 2/7] greybus: connection: Add gb_connection_hd_find_by_intf() Ayush Singh
2026-08-27 8:13 ` sashiko-bot
2026-08-27 7:54 ` [PATCH v2 3/7] rust: crc_ccitt: add CRC-CCITT abstraction Ayush Singh
2026-08-27 7:54 ` [PATCH v2 4/7] rust: kernel: Add greybus abstractions Ayush Singh
2026-08-27 8:12 ` sashiko-bot
2026-08-27 7:54 ` [PATCH v2 5/7] drivers: greybus: Add software SVC implementation Ayush Singh
2026-08-27 8:09 ` sashiko-bot [this message]
2026-08-27 7:54 ` [PATCH v2 6/7] dt-bindings: beagle: Add BeagleConnect Freedom Ayush Singh
2026-08-27 8:02 ` sashiko-bot
2026-08-27 16:06 ` Conor Dooley
2026-08-27 7:54 ` [PATCH v2 7/7] greybus: Add Rust UART node driver Ayush Singh
2026-08-27 8:13 ` sashiko-bot
2026-09-03 20:49 ` Markus Probst
2026-09-04 5:18 ` Ayush Singh
2026-09-06 17:39 ` Markus Probst
2026-09-06 19:00 ` Gary Guo
2026-09-06 19:19 ` Markus Probst
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=20260827080921.B2A511F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=ayush@beagleboard.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=robh@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.