On Fri, Aug 28, 2026 at 06:00:04PM +0800, Yang Zi wrote:
> gb_connection_recv() accepts a received message whose advertised size is
> smaller than struct gb_operation_msg_hdr. In particular, a header with a
> size of zero passes the incomplete-message check and reaches
> gb_operation_create_incoming().
Thanks for the fix.
Please shorten the commit summary (Subject) to something less verbose,
like:
greybus: operation: fix NULL-deref on short request
> This issue was found using a locally modified syzkaller. The
> analysis and fix were assisted by GPT-5.6.
This can go at the end of the commit message.
> The subtraction used to derive the request payload size then underflows.
> When gb_operation_message_alloc() adds the header size, the result wraps
> to zero, bypassing the maximum-buffer-size check. kzalloc(0) returns
> ZERO_SIZE_PTR and gb_operation_message_init() subsequently dereferences
> it.
>
> Reject advertised sizes smaller than the message header. Also check the
> payload size before adding the header size, so that the size calculation
> cannot wrap and bypass the buffer-size limit.
This is arguably two changes; a fix for the NULL-deref due to the
missing header sanity check and a hardening against any further bugs
like it.
But I guess they can go in together in one patch like you do here.
> Fixes: 87d208feb74f ("greybus: embed message buffer into message structure")
This is not the commit that introduced the issue. This should be:
Fixes: d90c25b0a279 ("greybus: let operation layer examine incoming data")
as that's the commit that started acting on the header size field
without first rejecting invalid headers (even if there was a WARN_ON()
at that time).
> Assisted-by: Codex:gpt-5.6
> Signed-off-by: Yang Zi <2959243019(a)qq.com>
> ---
> v2:
> - Add the syzkaller provenance and Assisted-by trailer.
> - Regenerate the patch for git-send-email.
> - Verify the received patch with git am and checkpatch.
>
> drivers/greybus/operation.c | 18 +++++++++++++++---
> 1 file changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/greybus/operation.c b/drivers/greybus/operation.c
> index 7e12ffb2dd60..c3d51176c373 100644
> --- a/drivers/greybus/operation.c
> +++ b/drivers/greybus/operation.c
> @@ -364,14 +364,21 @@ gb_operation_message_alloc(struct gb_host_device *hd, u8 type,
> {
> struct gb_message *message;
> struct gb_operation_msg_hdr *header;
> - size_t message_size = payload_size + sizeof(*header);
> + size_t message_size;
>
> - if (message_size > hd->buffer_size_max) {
> + /*
> + * Reject a payload size that would make the total message size
> + * overflow, before it wraps around and bypasses the maximum
> + * buffer size check.
> + */
I think you can drop the comment.
> + if (payload_size > hd->buffer_size_max - sizeof(*header)) {
> dev_warn(&hd->dev, "requested message size too big (%zu > %zu)\n",
And this should now say "payload size".
> - message_size, hd->buffer_size_max);
> + payload_size, hd->buffer_size_max - sizeof(*header));
> return NULL;
> }
>
> + message_size = payload_size + sizeof(*header);
> +
> /* Allocate the message structure and buffer. */
> message = kmem_cache_zalloc(gb_message_cache, gfp_flags);
> if (!message)
> @@ -1047,6 +1054,11 @@ void gb_connection_recv(struct gb_connection *connection,
> /* Use memcpy as data may be unaligned */
> memcpy(&header, data, sizeof(header));
> msg_size = le16_to_cpu(header.size);
> + if (msg_size < sizeof(header)) {
> + dev_err_ratelimited(dev, "%s: short message received (%zu < %zu)\n",
> + connection->name, msg_size, sizeof(header));
> + return;
> + }
> if (size < msg_size) {
> dev_err_ratelimited(dev,
> "%s: incomplete message 0x%04x of type 0x%02x received (%zu < %zu)\n",
Johan
Hello,
As part of the kernel research at ASU's SEFCOM
lab, we hit the crash below. Crash reports can be found here:
https://github.com/farhad-alemi/public_bug_reports/tree/main/165-warning-od…
ODEBUG: free active (active state 0) object: ffff888014747a70 object
type: timer_list hint: gb_operation_timeout+0x0/0x100
drivers/greybus/operation.c:1265
WARNING: lib/debugobjects.c:632 at
debug_check_no_obj_freed+0x3fd/0x540 lib/debugobjects.c:1156, CPU#1:
kworker/u8:3/10201
Call Trace:
kmem_cache_free+0xcb/0x4d0 mm/slub.c:6378
gb_operation_sync_timeout+0x1c7/0x270 drivers/greybus/operation.c:1172
gb_operation_sync include/linux/greybus/operation.h:203 [inline]
gb_svc_dme_peer_get+0x10a/0x250 drivers/greybus/svc.c:428
gb_interface_read_and_clear_init_status
drivers/greybus/interface.c:380 [inline]
gb_interface_enable+0x146/0x900 drivers/greybus/interface.c:1075
gb_module_register_interface drivers/greybus/module.c:162 [inline]
gb_module_add+0x1b3/0x3d0 drivers/greybus/module.c:209
Our reproducer.c is available upon request.
Happy to test a patch if that would help.
Regards,
Hello,
As part of the kernel research at ASU's SEFCOM
lab, we hit the crash below. Crash reports can be found here:
https://github.com/farhad-alemi/public_bug_reports/tree/main/167-warning-od…
greybus 3-svc: Resetting the greybus network, watch out!!!
ODEBUG: init active (active state 0) object: ffffffff92bbc2a0 object
type: timer_list hint: greybus_reset+0x0/0x50
WARNING: lib/debugobjects.c:632 at __debug_object_init+0x2a8/0x4a0
lib/debugobjects.c:790, CPU#0: kworker/0:4/11040
Call Trace:
debug_timer_init kernel/time/timer.c:788 [inline]
debug_init kernel/time/timer.c:836 [inline]
timer_init_key+0x34/0x1e0 kernel/time/timer.c:880
list_splice_tail_init include/linux/list.h:620 [inline]
do_work+0x19e/0x2b0 drivers/md/dm-kcopyd.c:664
process_one_work kernel/workqueue.c:3314 [inline]
process_scheduled_works+0x881/0x1170 kernel/workqueue.c:3397
worker_thread+0x988/0xde0 kernel/workqueue.c:3478
WARNING: kernel/workqueue.c:806 at insert_work+0x1f3/0x240
BUG: KASAN: slab-use-after-free in do_work+0x257/0x2b0
Our reproducer.c is available upon request.
Happy to test a patch if that would help.
Regards,
A Greybus network needs an SVC (Supervisory Controller) to bring
interfaces up, assign device IDs and connect CPorts to the AP. On a
UniPro network the SVC is a real entity on the bus. On transports that
merely carry Greybus messages - a UART, an I2C bus, a network link -
nothing on the wire plays that role, so the SVC has to be emulated
somewhere: in a user-space bridge (gbridge), in coprocessor firmware
(cc1352p7 in gb-beagleplay), or open-coded inside the host driver itself.
This series moves the emulation into the kernel and makes it shared.
This was discussed in a prior RFC as well [2], but to keep things short,
removing the need for an external SVC greatly simplifies the greybus
network setup when nodes are directly connected over common transports
such as UART, I2C etc.
gb-uart-node gb-softsvc greybus core
(transport, serdev) <-> (SVC + host device) <-> (bundles, protocols)
NodeOps module_insert()
submit_message() module_remove()
gb-softsvc registers itself as a Greybus host device and answers the
SVC-side operations the core expects during interface bring-up and
teardown. A host driver implements the NodeOps trait to push data
towards its node, calls module_insert() to announce a new node,
submit_message() to hand incoming Greybus messages back to the core,
and module_remove() on disconnect.
The first user is gb-uart-node, a driver for Greybus nodes attached over
a plain serial port. Framing is HDLC, with a one-byte address (0x01 for
Greybus) and control byte, followed by the 16-bit CPort ID and the
Greybus message. No SVC firmware is required on the far end, so the node
can be a bare microcontroller speaking Greybus - a BeagleConnect Freedom
over its serial link, in this case. The testing is performed with
greybus-zephyr [0] implementation.
Both drivers are written in Rust, which is why the middle of the series
is abstractions rather than drivers. Only the APIs these two drivers
need are covered: protocols.rs abstracts the SVC-facing parts of
greybus_protocols.h, and types such as Greybus Interface do not
implement AlwaysRefCounted yet. The intent is to grow this as more Rust
host drivers appear rather than to abstract the whole subsystem up
front.
Patches 1 and 2 are small C-side preparations to the Greybus core:
exporting gb_connection_get()/gb_connection_put() and adding
gb_connection_hd_find_by_intf(), a lookup by remote interface and CPort
id for callers that only know the far end of a connection. Patch 3 adds
a CRC-CCITT abstraction, needed for HDLC frame checks. Patch 4 adds the
Greybus abstractions, patches 5 and 6 the two drivers, and patch 7 the
device tree binding for BeagleConnect Freedom.
Open questions
***************
- gb-uart-node imports types from gb-softsvc, so the series carries the
Rust-to-Rust cross-module calling setup from nova-core [1]:
gb_softsvc_exports.c plus the Makefile plumbing that emits crate
metadata and generates the export list. This is a workaround for the
build system not supporting Rust cross-module dependencies natively,
and it should go away once that lands.
- Connection create/destroy and interface activate/resume in gb-softsvc
currently just acknowledge the request. Callbacks into NodeOps can be
added when a transport actually needs to act on them; I did not want
to invent an interface without a user.
- Zerocopy is currently not being used in grebeybus/protocols.rs. They
cannot be derived yet since types generated by bindgen do not have
them, and it seems explicitly forbindden to manually impl the traits.
So using old traits from transmute.
- The bindings are supposed to be created for actual device, but any MCU
that supports Zephyr, can run the greybus-zephyr firmware with UART
transport. So not sure if adding a beagle,beagleconnect-freedom
compatible is the correct choice here.
- The individual patches can be spun off into independent patch series
if required. The reason for this single patch series is to provide a
complete picture of usage.
- Since gb-softsvc currently is not being used from a C driver, no C API
is provided. However, if required, it can be added.
- Writing to UART from gb-uart-node is currently a bit broken. I am not
quite sure what the safe way is to go from a non-bound device to a
bound device. Any suggestions on this front are welcome.
- I am not sure if Rust abstractions should have a seperate entry in
MAINTAINERS with me as the maintainer, or if they should just be added
to the respective subsystem entries.
[0]: https://github.com/beagleboard/greybus-zephyr
[1]: https://lore.kernel.org/all/20260622-nova-exports-v5-0-6191773fc977@nvidia.…
[2]: https://lore.kernel.org/all/ecca8eb2-8e5a-4770-bcf6-3fb49773088b@beagleboar…
Signed-off-by: Ayush Singh <ayush(a)beagleboard.org>
---
Changes in v2:
- Fix possible null pointer dereference in
gb_connection_hd_find_by_intf. Flagged by sashiko-bot.
- Remove prompt CONFIG_RUST_CRC_CCITT_ABSTRACTIONS Kconfig symbol.
- Add CONFIG_RUST_GREYBUS_ABSTRACTIONS to ensure that greybus is
built-in for rust abstractions to work.
- Use gfp_mask in message_send callback.
- Only provide a Message reference in message_cancel callback.
- Add invariant comment for Registration.
- Call Registration->add directly in new, before constructing
Registration.
- Add Send and Sync bounds to T in Registration<T>
- Set endo_id as 0. Is not used anywhere.
- Fix module_insert intf_count. Was hardcoded to 1 by mistake. Flagged by
sashiko-bot.
- Check for empty intfs slice in Module::new.
- Remove module in serdev::Driver::unbind instead of on drop.
- Make gb_uart_node write atomic. Using temp buffer to build frame.
- Fix import style.
- Reorder beagleconnect-freedom dtbinding patch to be before gb_uart_node.
- Add vbat-supply and reg properties to beagleconnect-freedom dtbinding.
- Reference spi-peripheral-props in beagleconnect-freedom dtbinding.
- Link to v1: https://lore.kernel.org/r/20260820-gb-uart-transport-v1-0-282da14ab7b7@beag…
---
Ayush Singh (7):
greybus: connection: Export gb_connection_get() and gb_connection_put()
greybus: connection: Add gb_connection_hd_find_by_intf()
rust: crc_ccitt: add CRC-CCITT abstraction
rust: kernel: Add greybus abstractions
drivers: greybus: Add software SVC implementation
dt-bindings: beagle: Add BeagleConnect Freedom
greybus: Add Rust UART node driver
.../beagle/beagle,beagleconnect-freedom.yaml | 39 ++
MAINTAINERS | 15 +
drivers/greybus/.gitignore | 1 +
drivers/greybus/Kconfig | 34 ++
drivers/greybus/Makefile | 50 ++
drivers/greybus/connection.c | 29 +-
drivers/greybus/gb_softsvc.rs | 504 +++++++++++++++++++++
drivers/greybus/gb_softsvc_exports.c | 15 +
drivers/greybus/gb_uart_node.rs | 245 ++++++++++
include/linux/greybus/connection.h | 6 +
lib/crc/Kconfig | 7 +
rust/bindings/bindings_helper.h | 2 +
rust/kernel/alloc.rs | 5 +
rust/kernel/crc_ccitt.rs | 26 ++
rust/kernel/greybus/hd.rs | 333 ++++++++++++++
rust/kernel/greybus/mod.rs | 232 ++++++++++
rust/kernel/greybus/protocols.rs | 392 ++++++++++++++++
rust/kernel/lib.rs | 4 +
18 files changed, 1937 insertions(+), 2 deletions(-)
---
base-commit: 6b8c8af514d739d0335f5579b585e02babe8a727
change-id: 20260810-gb-uart-transport-9255d6557c4c
Best regards,
--
Ayush Singh <ayush(a)beagleboard.org>
A Greybus network needs an SVC (Supervisory Controller) to bring
interfaces up, assign device IDs and connect CPorts to the AP. On a
UniPro network the SVC is a real entity on the bus. On transports that
merely carry Greybus messages - a UART, an I2C bus, a network link -
nothing on the wire plays that role, so the SVC has to be emulated
somewhere: in a user-space bridge (gbridge), in coprocessor firmware
(cc1352p7 in gb-beagleplay), or open-coded inside the host driver itself.
This series moves the emulation into the kernel and makes it shared.
This was discussed in a prior RFC as well [2], but to keep things short,
removing the need for an external SVC greatly simplifies the greybus
network setup when nodes are directly connected over common transports
such as UART, I2C etc.
gb-uart-node gb-softsvc greybus core
(transport, serdev) <-> (SVC + host device) <-> (bundles, protocols)
NodeOps module_insert()
submit_message() module_remove()
gb-softsvc registers itself as a Greybus host device and answers the
SVC-side operations the core expects during interface bring-up and
teardown. A host driver implements the NodeOps trait to push data
towards its node, calls module_insert() to announce a new node,
submit_message() to hand incoming Greybus messages back to the core,
and module_remove() on disconnect.
The first user is gb-uart-node, a driver for Greybus nodes attached over
a plain serial port. Framing is HDLC, with a one-byte address (0x01 for
Greybus) and control byte, followed by the 16-bit CPort ID and the
Greybus message. No SVC firmware is required on the far end, so the node
can be a bare microcontroller speaking Greybus - a BeagleConnect Freedom
over its serial link, in this case. The testing is performed with
greybus-zephyr [0] implementation.
Both drivers are written in Rust, which is why the middle of the series
is abstractions rather than drivers. Only the APIs these two drivers
need are covered: protocols.rs abstracts the SVC-facing parts of
greybus_protocols.h, and types such as Greybus Interface do not
implement AlwaysRefCounted yet. The intent is to grow this as more Rust
host drivers appear rather than to abstract the whole subsystem up
front.
Patches 1 and 2 are small C-side preparations to the Greybus core:
exporting gb_connection_get()/gb_connection_put() and adding
gb_connection_hd_find_by_intf(), a lookup by remote interface and CPort
id for callers that only know the far end of a connection. Patch 3 adds
a CRC-CCITT abstraction, needed for HDLC frame checks. Patch 4 adds the
Greybus abstractions, patches 5 and 6 the two drivers, and patch 7 the
device tree binding for BeagleConnect Freedom.
Open questions
***************
- gb-uart-node imports types from gb-softsvc, so the series carries the
Rust-to-Rust cross-module calling setup from nova-core [1]:
gb_softsvc_exports.c plus the Makefile plumbing that emits crate
metadata and generates the export list. This is a workaround for the
build system not supporting Rust cross-module dependencies natively,
and it should go away once that lands.
- Connection create/destroy and interface activate/resume in gb-softsvc
currently just acknowledge the request. Callbacks into NodeOps can be
added when a transport actually needs to act on them; I did not want
to invent an interface without a user.
- Zerocopy is currently not being used in grebeybus/protocols.rs. They
cannot be derived yet since types generated by bindgen do not have
them, and it seems explicitly forbindden to manually impl the traits.
So using old traits from transmute.
- The bindings are supposed to be created for actual device, but any MCU
that supports Zephyr, can run the greybus-zephyr firmware with UART
transport. So not sure if adding a beagle,beagleconnect-freedom
compatible is the correct choice here.
- The individual patches can be spun off into independent patch series
if required. The reason for this single patch series is to provide a
complete picture of usage.
- Since gb-softsvc currently is not being used from a C driver, no C API
is provided. However, if required, it can be added.
- Writing to UART from gb-uart-node is currently a bit broken. I am not
quite sure what the safe way is to go from a non-bound device to a
bound device. Any suggestions on this front are welcome.
- I am not sure if Rust abstractions should have a seperate entry in
MAINTAINERS with me as the maintainer, or if they should just be added
to the respective subsystem entries.
[0]: https://github.com/beagleboard/greybus-zephyr
[1]: https://lore.kernel.org/all/20260622-nova-exports-v5-0-6191773fc977@nvidia.…
[2]: https://lore.kernel.org/all/ecca8eb2-8e5a-4770-bcf6-3fb49773088b@beagleboar…
Signed-off-by: Ayush Singh <ayush(a)beagleboard.org>
---
Ayush Singh (7):
greybus: connection: Export gb_connection_get() and gb_connection_put()
greybus: connection: Add gb_connection_hd_find_by_intf()
rust: crc_ccitt: add CRC-CCITT abstraction
rust: kernel: Add greybus abstractions
drivers: greybus: Add software SVC implementation
greybus: Add Rust UART node driver
dt-bindings: beagle: Add BeagleConnect Freedom
.../beagle/beagle,beagleconnect-freedom.yaml | 30 ++
MAINTAINERS | 15 +
drivers/greybus/.gitignore | 1 +
drivers/greybus/Kconfig | 27 ++
drivers/greybus/Makefile | 50 +++
drivers/greybus/connection.c | 28 +-
drivers/greybus/gb_softsvc.rs | 472 +++++++++++++++++++++
drivers/greybus/gb_softsvc_exports.c | 15 +
drivers/greybus/gb_uart_node.rs | 231 ++++++++++
include/linux/greybus/connection.h | 6 +
lib/crc/Kconfig | 7 +
rust/bindings/bindings_helper.h | 2 +
rust/kernel/crc_ccitt.rs | 26 ++
rust/kernel/greybus/hd.rs | 315 ++++++++++++++
rust/kernel/greybus/mod.rs | 230 ++++++++++
rust/kernel/greybus/protocols.rs | 392 +++++++++++++++++
rust/kernel/lib.rs | 4 +
17 files changed, 1849 insertions(+), 2 deletions(-)
---
base-commit: 6b8c8af514d739d0335f5579b585e02babe8a727
change-id: 20260810-gb-uart-transport-9255d6557c4c
Best regards,
--
Ayush Singh <ayush(a)beagleboard.org>
On Tue, Aug 25, 2026 at 05:23:09PM +0800, Yang Zi wrote:
> gb_connection_recv() reads msg_size from the received message header but
> only rejects it when it is larger than the received buffer
> ("size < msg_size"); it does not reject msg_size smaller than the message
> header itself. A malicious or corrupted header.size of 0 passes that
> check and is forwarded to gb_operation_create_incoming() with size 0.
>
> There, request_size = size - sizeof(struct gb_operation_msg_hdr)
> underflows to SIZE_MAX - 7, and in gb_operation_message_alloc()
> message_size = payload_size + sizeof(*header) wraps back around to 0.
> The "message_size > hd->buffer_size_max" check is therefore bypassed,
> kzalloc(0) returns ZERO_SIZE_PTR, and gb_operation_message_init() writes
> header->size to that pointer.
>
> KASAN report:
>
> BUG: KASAN: null-ptr-deref in gb_operation_message_init drivers/greybus/operation.c:340 [inline] [greybus]
> BUG: KASAN: null-ptr-deref in gb_operation_message_alloc+0xab4/0xdb0 drivers/greybus/operation.c:385 [greybus]
> Write of size 2 at addr 0000000000000010 by task syz.0.1/1100
>
> Fix this by rejecting messages whose claimed size is smaller than the
> message header in gb_connection_recv(), and additionally make
> gb_operation_message_alloc() overflow-safe by comparing the payload size
> against hd->buffer_size_max - sizeof(*header) before adding the header
> size.
>
> Signed-off-by: Yang Zi <2959243019(a)qq.com>
How was this issue found and fixed? Did you use an LLM and are missing
an Assisted-by tag?
Based on a quick glance, this look correct, but your patch is corrupt
and cannot be applied. (This appears to be the case with all the 30+
patches you sent out today.)
Please fix your mail setup and send a v2 (try sending it to yourself
first and make sure you can apply it and run checkpatch on it). You
should look into using git-send-email.
Johan