The firmware upload support calls crc32() in cc1352_prepare(), but
GREYBUS_BEAGLEPLAY does not select CRC32. When nothing else selects it,
the kernel fails to link:
ld: drivers/greybus/gb-beagleplay.o: in function `cc1352_prepare':
gb-beagleplay.c:(.text.unlikely+0x34b): undefined reference to `crc32_le'
This was reproduced with an x86 allnoconfig with BLOCK disabled and
GPIOLIB, SERIAL_DEV_BUS and the driver enabled. In most configurations
CRC32 is selected elsewhere (OF_FLATTREE on arm64, EFI_PARTITION with
BLOCK), which hides the problem.
Select CRC32, as the driver already does for CRC_CCITT.
Fixes: 0cf7befa3ea2 ("greybus: gb-beagleplay: Add firmware upload API")
Signed-off-by: Tomasz Unger <tomasz.unger(a)yahoo.pl>
---
An AI coding assistant (Claude) helped find the bug and draft the fix.
---
drivers/greybus/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/greybus/Kconfig b/drivers/greybus/Kconfig
index c3f056d28b01..9c08964dd8be 100644
--- a/drivers/greybus/Kconfig
+++ b/drivers/greybus/Kconfig
@@ -20,6 +20,7 @@ if GREYBUS
config GREYBUS_BEAGLEPLAY
tristate "Greybus BeaglePlay driver"
depends on SERIAL_DEV_BUS
+ select CRC32
select CRC_CCITT
select FW_LOADER
select FW_UPLOAD
---
base-commit: 4f618bb81ea5403c0922bda75411c4669b8a4641
change-id: 20261130-gb-beagleplay-select-crc32-f668391304f6
Best regards,
--
Tomasz Unger <tomasz.unger(a)yahoo.pl>
From: TAKANO Mitsuhiro <takano32(a)gmail.com>
In gbaudio_module_update() and find_gb_module(), sscanf() reads strings
using unbounded "%s" specifiers into stack buffers of size NAME_SIZE (32).
If the input string contains a token of 32 bytes or longer, sscanf()
overflows the stack buffer.
Limit the string conversion widths to 31 characters so they always fit
within NAME_SIZE including the terminating NUL byte.
Signed-off-by: TAKANO Mitsuhiro <takano32(a)gmail.com>
---
Verification: compile-tested on x86_64 with CONFIG_GREYBUS_AUDIO=m
(drivers/staging/greybus/audio_codec.o with W=1, 0 warnings;
drivers/staging/greybus/audio_topology.o default build, 0 warnings) and
checked with scripts/checkpatch.pl --strict. Checked against linux-next
(next-20261127) and lore.kernel.org for duplicates. Not runtime-tested on
Greybus hardware.
The change and the changelog text were produced with an AI coding
assistant (Gemini) working from the tree; I reviewed the diff and the
reasoning, and I am responsible for the submission.
---
drivers/staging/greybus/audio_codec.c | 2 +-
drivers/staging/greybus/audio_topology.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/greybus/audio_codec.c b/drivers/staging/greybus/audio_codec.c
index 9a4f6bca8..2b3d834bb 100644
--- a/drivers/staging/greybus/audio_codec.c
+++ b/drivers/staging/greybus/audio_codec.c
@@ -311,7 +311,7 @@ int gbaudio_module_update(struct gbaudio_codec_info *codec,
}
/* parse dai_id from AIF widget's stream_name */
- if (sscanf(w->sname, "%s %d %s", intf_name, &dai_id, dir) != 3) {
+ if (sscanf(w->sname, "%31s %d %31s", intf_name, &dai_id, dir) != 3) {
dev_err(codec->dev, "Error while parsing dai_id for %s\n", w->name);
return -EINVAL;
}
diff --git a/drivers/staging/greybus/audio_topology.c b/drivers/staging/greybus/audio_topology.c
index 82d6339b2..a69e5e348 100644
--- a/drivers/staging/greybus/audio_topology.c
+++ b/drivers/staging/greybus/audio_topology.c
@@ -28,7 +28,7 @@ static struct gbaudio_module_info *find_gb_module(struct gbaudio_codec_info *cod
if (!name)
return NULL;
- if (sscanf(name, "%s %d", begin, &dev_id) != 2)
+ if (sscanf(name, "%31s %d", begin, &dev_id) != 2)
return NULL;
dev_dbg(codec->dev, "%s:Find module#%d\n", __func__, dev_id);
---
base-commit: f93eb7cfc4bfa5d46340f360873726e3e77f2365
change-id: 20261128-b4-greybus-audio-sscanf-bounds-3091c62b06d9
Best regards,
--
TAKANO Mitsuhiro <takano32(a)gmail.com>
From: TAKANO Mitsuhiro <takano32(a)gmail.com>
The sysfs attribute for async is defined with
gb_dev_loopback_rw_attr(async, u), which uses "%u" in both
sysfs_emit() and sscanf(..., &gb->async). However, struct gb_loopback
declares async as int rather than an unsigned type.
Change async to u32 to match the "%u" format specifier and the other
unsigned attributes in struct gb_loopback.
Signed-off-by: TAKANO Mitsuhiro <takano32(a)gmail.com>
---
Verification: compile-tested on x86_64 with CONFIG_GREYBUS_LOOPBACK=m
(make W=1 drivers/staging/greybus/loopback.o; 0 warnings) and checked
with scripts/checkpatch.pl --strict. Checked against linux-next
(next-20261127) and lore.kernel.org for duplicates. Not runtime-tested on
Greybus hardware.
The change and the changelog text were produced with an AI coding
assistant (Gemini) working from the tree; I reviewed the diff and the
reasoning, and I am responsible for the submission.
---
drivers/staging/greybus/loopback.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c
index efc69c10c..02bd8261b 100644
--- a/drivers/staging/greybus/loopback.c
+++ b/drivers/staging/greybus/loopback.c
@@ -77,7 +77,7 @@ struct gb_loopback {
struct gb_loopback_stats gbphy_firmware_latency;
int type;
- int async;
+ u32 async;
int id;
u32 size;
u32 iteration_max;
---
base-commit: f93eb7cfc4bfa5d46340f360873726e3e77f2365
change-id: 20261128-b4-greybus-loopback-async-type-3881628ae7e4
Best regards,
--
TAKANO Mitsuhiro <takano32(a)gmail.com>
A request can complete after gb_message_send() returns but before its
timeout timer is armed. The completion worker then finds no timer to
delete, and the request path can leave an active timer in an operation
that is about to be freed.
Check the result and arm the timer while holding gb_operations_lock,
which also protects result updates. If completion has already happened,
leave the timer unarmed. Otherwise the completion worker will delete
the armed timer as before.
Reported-by: syzbot+61464b62b688791cc24c(a)syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=61464b62b688791cc24c
Reported-by: syzbot+a2e50fb40695811c2dab(a)syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=a2e50fb40695811c2dab
Fixes: dbec27298b0d ("staging: greybus: operation: add generic timeout support")
Link: https://lore.kernel.org/all/20261022134817.1703927-1-hackerowskiy@gmail.com/
Link: https://lore.kernel.org/all/20261103-gb-uart-transport-v5-3-f8e326d6561f@be…
Cc: stable(a)vger.kernel.org
Signed-off-by: linfordWu <linfordwu(a)163.com>
---
drivers/greybus/operation.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/greybus/operation.c b/drivers/greybus/operation.c
index 7e12ffb2dd6..7d4006f4bbd 100644
--- a/drivers/greybus/operation.c
+++ b/drivers/greybus/operation.c
@@ -725,6 +725,7 @@ int gb_operation_request_send(struct gb_operation *operation,
{
struct gb_connection *connection = operation->connection;
struct gb_operation_msg_hdr *header;
+ unsigned long flags;
unsigned int cycle;
int ret;
@@ -771,8 +772,12 @@ int gb_operation_request_send(struct gb_operation *operation,
goto err_put_active;
if (timeout) {
- operation->timer.expires = jiffies + msecs_to_jiffies(timeout);
- add_timer(&operation->timer);
+ spin_lock_irqsave(&gb_operations_lock, flags);
+ if (operation->errno == -EINPROGRESS) {
+ operation->timer.expires = jiffies + msecs_to_jiffies(timeout);
+ add_timer(&operation->timer);
+ }
+ spin_unlock_irqrestore(&gb_operations_lock, flags);
}
return 0;
--
2.43.0
reset_work is a file-scope delayed work shared by all SVC watchdogs, but
do_work() calls INIT_DELAYED_WORK() on it every time a ping fails, right
before scheduling it to run half a second later. With two host devices,
the watchdog of the second SVC can see its ping fail while the work
scheduled by the first one is still pending. INIT_DELAYED_WORK() then
reinitializes a timer that is still enqueued, and debugobjects reports:
greybus 1-svc: Resetting the greybus network, watch out!!!
greybus 2-svc: Resetting the greybus network, watch out!!!
ODEBUG: init active (active state 0) object: ffffffff9bda1f68 object type: timer_list hint: greybus_reset+0x0/0x50
WARNING: lib/debugobjects.c:629 at debug_print_object+0x198/0x2b0
Workqueue: events do_work
Call Trace:
__debug_object_init
timer_init_key
do_work drivers/greybus/svc_watchdog.c:92
process_one_work
Without CONFIG_DEBUG_OBJECTS_TIMERS nothing catches this and the timer
is added to the timer wheel a second time while it is still linked there.
Initialize reset_work once with DECLARE_DELAYED_WORK() and only schedule
it from do_work(). schedule_delayed_work() does nothing when the work is
already pending, which is what is wanted here: greybus_reset() resets the
whole greybus network, so one run serves both watchdogs.
Fixes: ed7279ae31b0 ("greybus: svc: add a "watchdog" to check the network health")
Reported-by: syzbot+e6bea924b5ee24f7cb98(a)syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=e6bea924b5ee24f7cb98
Link: https://lore.kernel.org/r/CA+0ovCiyBFo_gx4UaRN095=MdWaBgKm=TqA1uYdOu-hb_BPt…
Signed-off-by: Jiayi Zhang <zhangjiayi1014(a)gmail.com>
---
Compile tested only (allmodconfig, W=1); syzbot has no reproducer for
this report.
AI tools assisted with the analysis, the code and the changelog.
drivers/greybus/svc_watchdog.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/greybus/svc_watchdog.c b/drivers/greybus/svc_watchdog.c
index b318eb34bcca..11eb7c961b06 100644
--- a/drivers/greybus/svc_watchdog.c
+++ b/drivers/greybus/svc_watchdog.c
@@ -20,8 +20,6 @@ struct gb_svc_watchdog {
struct notifier_block pm_notifier;
};
-static struct delayed_work reset_work;
-
static int svc_watchdog_pm_notifier(struct notifier_block *notifier,
unsigned long pm_event, void *unused)
{
@@ -61,6 +59,8 @@ static void greybus_reset(struct work_struct *work)
call_usermodehelper(start_path, argv, envp, UMH_WAIT_EXEC);
}
+static DECLARE_DELAYED_WORK(reset_work, greybus_reset);
+
static void do_work(struct work_struct *work)
{
struct gb_svc_watchdog *watchdog;
@@ -89,7 +89,6 @@ static void do_work(struct work_struct *work)
} else if (svc->action == GB_SVC_WATCHDOG_BITE_RESET_UNIPRO) {
dev_err(&svc->dev, "Resetting the greybus network, watch out!!!\n");
- INIT_DELAYED_WORK(&reset_work, greybus_reset);
schedule_delayed_work(&reset_work, HZ / 2);
/*
base-commit: 9437ee8b6cf607e883b36e44bd755968daaebd48
--
2.53.0
Hi,
While reading drivers/staging/greybus/loopback.c in current mainline
(4dce97c), I found what looks like an out-of-bounds read.
In gb_loopback_request_handler(), case GB_LOOPBACK_TYPE_TRANSFER:
len = le32_to_cpu(request->len);
if (len > gb_dev.size_max) { ... return -EINVAL; }
...
memcpy(response->data, request->data, len);
'len' comes from the remote device and is only checked against
gb_dev.size_max (the maximum payload size of the connection). It is never
checked against the size of the payload that was actually received. A
device can send a small request with a large 'len', and the kernel will
copy bytes from beyond the end of the request buffer into the response,
which is then sent back to the device. This is a heap over-read and a
possible information leak.
raw.c in the same driver already validates len against payload_size in the
equivalent place.
Untested suggested fix (not compiled or run on hardware):
--- a/drivers/staging/greybus/loopback.c
+++ b/drivers/staging/greybus/loopback.c
@@ -650,6 +650,12 @@ static int gb_loopback_request_handler(struct
gb_operation *operation)
len, gb_dev.size_max);
return -EINVAL;
}
+ if (len > operation->request->payload_size - sizeof(*request)) {
+ dev_err(dev, "transfer request length exceeds payload (%zu > %zu)\n",
+ len,
+ operation->request->payload_size - sizeof(*request));
+ return -EINVAL;
+ }
if (!gb_operation_response_alloc(operation,
len + sizeof(*response),
The subtraction is safe because payload_size >= sizeof(*request) is already
checked a few lines earlier.
Thanks,
Sahanur Molla