KASAN: slab-out-of-bounds Read in gb_svc_request_handler

Status: upstream: reported C repro on 2026/11/05 11:09
Subsystems: greybus usb
Labels: prio:high
[Documentation on labels]
Reported-by: syzbot+693652ded53d3eb9cb91@syzkaller.appspotmail.com
First crash: 19d, last: 2d20h
✨ AI cause bisection: introduced by (AI job) :
commit cfa79699cdef2e006f8414587c0e4d62209e4897
Author: Johan Hovold <johan@hovoldconsulting.com>
Date: Fri Mar 27 11:41:18 2015 +0000

  greybus: operation: fix incoming request payload size

✨ AI-generated root cause summary:

In drivers/greybus/operation.c, gb_connection_recv() verifies that the received buffer length is at least sizeof(header) and that size >= msg_size, but fails to check whether msg_size (from header.size) is at least sizeof(header). When an incoming message has header.size < sizeof(struct gb_operation_msg_hdr), gb_operation_create_incoming() computes request_size = size - sizeof(struct gb_operation_msg_hdr), causing an unsigned size_t underflow to SIZE_MAX. While gb_operation_message_alloc() wraps the allocation size back to the short msg_size (allocating e.g. 7 bytes), gb_operation_message_init() sets payload_size to SIZE_MAX and sets payload to header + 1 (offset 8, past the end of the buffer). Consequently, request handlers like gb_svc_version_request() pass the payload_size validation and perform out-of-bounds heap reads on op->request->payload.

▶ ▼ ✨ Full AI root cause analysis
Based on kernel commit 6628e7d4c6b2:

Root Cause Analysis

1. Relevant Files, Functions, and Data Structures


2. Detailed Technical Mechanism

When a Greybus host device receives incoming data over its transport layer (such as USB/ES2 via cport_in_callback() in drivers/greybus/es2.c), it passes the data buffer and received length to greybus_data_rcvd(), which calls gb_connection_recv().

In gb_connection_recv():

	if (size < sizeof(header)) {
		dev_err_ratelimited(dev, "%s: short message received\n",
				    connection->name);
		return;
	}

	/* Use memcpy as data may be unaligned */
	memcpy(&header, data, sizeof(header));
	msg_size = le16_to_cpu(header.size);
	if (size < msg_size) {
		dev_err_ratelimited(dev, ...);
		return;
	}

	if (header.type & GB_MESSAGE_TYPE_RESPONSE) {
		gb_connection_recv_response(connection, &header, data, msg_size);
	} else {
		gb_connection_recv_request(connection, &header, data, msg_size);
	}

The function checks:

  1. size < sizeof(header): Ensures that the raw received buffer contains at least 8 bytes (sizeof(struct gb_operation_msg_hdr)).
  2. size < msg_size: Ensures that the raw buffer has enough bytes to hold the total message length indicated in header.size.

However, it fails to validate that msg_size >= sizeof(header).

In a well-formed Greybus frame, every message contains at least a full struct gb_operation_msg_hdr (8 bytes), so header.size must be $\ge 8$. If an incoming packet specifies a header size smaller than the header itself (e.g., header.size = 7 while the received frame size is $\ge 8$):

  1. size < sizeof(header) is false.
  2. size < msg_size is false (e.g. $8 < 7$ is false).
  3. gb_connection_recv() invokes gb_connection_recv_request(..., data, msg_size) passing size = 7.

In gb_connection_recv_request(), gb_operation_create_incoming() is called with size = 7:

static struct gb_operation *
gb_operation_create_incoming(struct gb_connection *connection, u16 id,
			     u8 type, void *data, size_t size)
{
	...
	/* Caller has made sure we at least have a message header. */
	request_size = size - sizeof(struct gb_operation_msg_hdr);

gb_operation_create_incoming() relies on its caller having verified size >= sizeof(struct gb_operation_msg_hdr). Because size is 7 and sizeof(header) is 8, the subtraction underflows unsigned size_t: $$\text{request_size} = 7 - 8 = \text{SIZE_MAX} ; (\text{0xffffffffffffffff})$$

gb_operation_create_common() then calls gb_operation_message_alloc() with payload_size = request_size:

	size_t message_size = payload_size + sizeof(*header);

Due to standard integer wrapping, $\text{SIZE_MAX} + 8 = 7$. message->buffer = kzalloc(message_size, gfp_flags) allocates only a 7-byte buffer (from the kmalloc-8 slab cache).

Next, gb_operation_message_init() initializes message fields:

	header = message->buffer;
	message->header = header;
	message->payload = payload_size ? header + 1 : NULL;
	message->payload_size = payload_size;

Because payload_size is non-zero (SIZE_MAX), message->payload is set to header + 1 (offset 8), which is 1 byte past the end of the allocated 7-byte buffer [buffer, buffer + 7). Furthermore, message->payload_size remains SIZE_MAX.

gb_operation_create_incoming() copies the received header data via memcpy(operation->request->header, data, 7) and queues the operation for asynchronous execution via gb_operation_work().


3. Manifestation in gb_svc_version_request()

When the worker thread executes gb_operation_work(), it calls gb_operation_request_handle() which dispatches the incoming request to gb_svc_request_handler(), calling gb_svc_version_request(op):

	if (op->request->payload_size < sizeof(*request)) {
		dev_err(&svc->dev, "short version request (%zu < %zu)\n",
			op->request->payload_size,
			sizeof(*request));
		return -EINVAL;
	}

	request = op->request->payload;

	if (request->major > GB_SVC_VERSION_MAJOR) { ... }

Because op->request->payload_size is SIZE_MAX, the check op->request->payload_size < sizeof(*request) passes. Dereferencing request->major attempts to read byte 0 of request at op->request->payload, which is offset 8 of op->request->buffer (address ffff88811f35f368, exactly 1 byte past the 7-byte allocated buffer ffff88811f35f360 in kmalloc-8). KASAN immediately detects this slab-out-of-bounds read and reports the crash.

Note that a similar underflow vulnerability exists in gb_connection_recv_response() if size < sizeof(*header) when computing message->payload_size = size - sizeof(*header).

▶ ▼ ✨ AI Jobs (2)
ID Workflow Result Correct Bug Created Started Finished Revision
fae67638 bisect-cause IsRelease: ❌ ❓ KASAN: slab-out-of-bounds Read in gb_svc_request_handler 2026/11/22 11:12 2026/11/22 11:12 2026/11/22 11:50 b2c69459
d24d3ab2 assessment-security DenialOfService: ✅ Exploitable: ✅ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ✅ RemoteTrigger: ❌ Unprivileged: ❌ UserNamespace: ❌ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ KASAN: slab-out-of-bounds Read in gb_svc_request_handler 2026/11/04 12:53 2026/11/04 12:53 2026/11/04 13:20 5af5b6c6
▶ ▼ Discussions (3)
Title Replies (including bot) Last reply
[PATCH] greybus: reject messages with claimed size smaller than header 4 (4) 2026/11/09 14:43
[syzbot] [greybus?] [usb?] KASAN: slab-out-of-bounds Read in gb_svc_request_handler 3 (4) 2026/11/09 14:28
[PATCH] greybus: operation: fix OOB Read in gb_svc_request_handler 1 (1) 2026/11/06 09:43

Sample crash report:
==================================================================
BUG: KASAN: slab-out-of-bounds in gb_svc_version_request drivers/greybus/svc.c:658 [inline]
BUG: KASAN: slab-out-of-bounds in gb_svc_request_handler+0x10de/0x1250 drivers/greybus/svc.c:1271
Read of size 1 at addr ffff888044c4a9a8 by task kworker/u32:3/5850

CPU: 0 UID: 0 PID: 5850 Comm: kworker/u32:3 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
Workqueue: greybus1:0 gb_operation_work
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x100/0x190 lib/dump_stack.c:120
 print_address_description mm/kasan/report.c:378 [inline]
 print_report+0x13d/0x4b0 mm/kasan/report.c:482
 kasan_report+0xdf/0x1c0 mm/kasan/report.c:595
 gb_svc_version_request drivers/greybus/svc.c:658 [inline]
 gb_svc_request_handler+0x10de/0x1250 drivers/greybus/svc.c:1271
 gb_operation_request_handle drivers/greybus/operation.c:243 [inline]
 gb_operation_work+0xb7/0x990 drivers/greybus/operation.c:280
 process_one_work+0xac7/0x1b10 kernel/workqueue.c:3495
 process_scheduled_works kernel/workqueue.c:3578 [inline]
 worker_thread+0x5ef/0xe50 kernel/workqueue.c:3659
 kthread+0x373/0x450 kernel/kthread.c:436
 ret_from_fork+0x730/0xd60 arch/x86/kernel/process.c:158
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
 </TASK>

Allocated by task 0:
 kasan_save_stack+0x30/0x50 mm/kasan/common.c:57
 kasan_save_track+0x14/0x40 mm/kasan/common.c:79
 poison_kmalloc_redzone mm/kasan/common.c:412 [inline]
 __kasan_kmalloc+0xaa/0xb0 mm/kasan/common.c:429
 kasan_kmalloc include/linux/kasan.h:267 [inline]
 __do_kmalloc_node mm/slub.c:5531 [inline]
 __kmalloc_noprof+0x32f/0x840 mm/slub.c:5556
 _kmalloc_noprof include/linux/slab.h:995 [inline]
 _kzalloc_noprof include/linux/slab.h:1312 [inline]
 gb_operation_message_alloc+0x9b/0x2c0 drivers/greybus/operation.c:380
 gb_operation_create_common+0x9f/0x710 drivers/greybus/operation.c:532
 gb_operation_create_incoming drivers/greybus/operation.c:644 [inline]
 gb_connection_recv_request drivers/greybus/operation.c:926 [inline]
 gb_connection_recv+0x1dc/0x1050 drivers/greybus/operation.c:1063
 greybus_data_rcvd+0x244/0x600 drivers/greybus/connection.c:89
 cport_in_callback+0x1fb/0x280 drivers/greybus/es2.c:840
 __usb_hcd_giveback_urb+0x38e/0x610 drivers/usb/core/hcd.c:1657
 usb_hcd_giveback_urb+0x3ca/0x4a0 drivers/usb/core/hcd.c:1741
 dummy_timer+0xdb5/0x3840 drivers/usb/gadget/udc/dummy_hcd.c:2051
 __run_hrtimer kernel/time/hrtimer.c:2079 [inline]
 __hrtimer_run_queues+0x448/0x9a0 kernel/time/hrtimer.c:2136
 hrtimer_run_softirq+0x1ca/0x360 kernel/time/hrtimer.c:2153
 handle_softirqs+0x216/0xa20 kernel/softirq.c:669
 __do_softirq kernel/softirq.c:703 [inline]
 invoke_softirq kernel/softirq.c:542 [inline]
 __irq_exit_rcu+0x178/0x220 kernel/softirq.c:786
 irq_exit_rcu+0x9/0x30 kernel/softirq.c:809
 instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1062 [inline]
 sysvec_apic_timer_interrupt+0xa3/0xc0 arch/x86/kernel/apic/apic.c:1062
 asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:674

The buggy address belongs to the object at ffff888044c4a9a0
 which belongs to the cache kmalloc-8 of size 8
The buggy address is located 1 bytes to the right of
 allocated 7-byte region [ffff888044c4a9a0, ffff888044c4a9a7)

The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x44c4a
flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000000 ffff88801d442500 dead000000000100 dead000000000122
raw: 0000000000000000 0000000000800080 00000000f5000000 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0xd2cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 5855, tgid 5855 (syz-executor), ts 40203846744
 set_page_owner include/linux/page_owner.h:33 [inline]
 post_alloc_hook+0xfd/0x120 mm/page_alloc.c:1873
 prep_new_page mm/page_alloc.c:1881 [inline]
 get_page_from_freelist+0xdae/0x2c80 mm/page_alloc.c:3963
 __alloc_frozen_pages_noprof+0x2ad/0x31e0 mm/page_alloc.c:5505
 alloc_slab_page mm/slub.c:3384 [inline]
 allocate_slab mm/slub.c:3499 [inline]
 new_slab+0xb1/0x6d0 mm/slub.c:3550
 refill_objects+0xe3/0x410 mm/slub.c:7546
 refill_sheaf mm/slub.c:2917 [inline]
 __pcs_replace_empty_main+0x35e/0x650 mm/slub.c:4811
 alloc_from_pcs mm/slub.c:4887 [inline]
 slab_alloc_node mm/slub.c:5021 [inline]
 __do_kmalloc_node mm/slub.c:5530 [inline]
 __kmalloc_node_track_caller_noprof+0x6a3/0x870 mm/slub.c:5662
 __kmemdup_nul mm/util.c:64 [inline]
 kstrdup+0x51/0xe0 mm/util.c:84
 kstrdup_const+0x63/0x80 mm/util.c:104
 __kernfs_new_node+0x9b/0xa10 fs/kernfs/dir.c:663
 kernfs_new_node+0x194/0x200 fs/kernfs/dir.c:759
 __kernfs_create_file+0x53/0x350 fs/kernfs/file.c:1071
 sysfs_add_file_mode_ns+0x207/0x3c0 fs/sysfs/file.c:316
 create_files fs/sysfs/group.c:82 [inline]
 internal_create_group+0x593/0xfb0 fs/sysfs/group.c:189
 internal_create_groups+0x9d/0x150 fs/sysfs/group.c:229
 setup_gid_attrs drivers/infiniband/core/sysfs.c:1123 [inline]
 ib_setup_port_attrs+0x41f/0x600 drivers/infiniband/core/sysfs.c:1399
page last free pid 5791 tgid 5791 ts 38529358689 stack trace:
 reset_page_owner include/linux/page_owner.h:26 [inline]
 __free_pages_prepare mm/page_alloc.c:1415 [inline]
 free_pages_prepare+0x586/0xe00 mm/page_alloc.c:1460
 __free_contig_range_common+0x14f/0x250 mm/page_alloc.c:7136
 __free_contig_range mm/page_alloc.c:7181 [inline]
 free_pages_bulk+0x125/0x1f0 mm/page_alloc.c:5389
 vm_area_free_pages+0xb2/0x2a0 mm/vmalloc.c:3498
 vfree mm/vmalloc.c:3547 [inline]
 vfree+0xfc/0x850 mm/vmalloc.c:3521
 kcov_put kernel/kcov.c:467 [inline]
 kcov_put kernel/kcov.c:463 [inline]
 kcov_close+0x34/0x60 kernel/kcov.c:574
 __fput+0x3fb/0xb50 fs/file_table.c:512
 fput_close_sync+0x118/0x250 fs/file_table.c:618
 filp_close_sync+0x75/0xa0 fs/open.c:1574
 close_files fs/file.c:572 [inline]
 put_files_struct fs/file.c:584 [inline]
 put_files_struct+0x1f7/0x390 fs/file.c:581
 switch_files_struct fs/file.c:598 [inline]
 exit_files+0x85/0xb0 fs/file.c:604
 do_exit+0x896/0x2a00 kernel/exit.c:977
 do_group_exit+0xd5/0x2a0 kernel/exit.c:1123
 get_signal+0x1f58/0x22e0 kernel/signal.c:3113
 arch_do_signal_or_restart+0x91/0x7e0 arch/x86/kernel/signal.c:337
 __exit_to_user_mode_loop kernel/entry/common.c:66 [inline]
 exit_to_user_mode_loop+0x139/0x700 kernel/entry/common.c:101

Memory state around the buggy address:
 ffff888044c4a880: fa fc fc fc fa fc fc fc fa fc fc fc fa fc fc fc
 ffff888044c4a900: fa fc fc fc fa fc fc fc fa fc fc fc fa fc fc fc
>ffff888044c4a980: fa fc fc fc 07 fc fc fc fa fc fc fc 06 fc fc fc
                                  ^
 ffff888044c4aa00: 06 fc fc fc 06 fc fc fc 06 fc fc fc 06 fc fc fc
 ffff888044c4aa80: fa fc fc fc fa fc fc fc fa fc fc fc fa fc fc fc
==================================================================

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/11/21 10:28 upstream 5f22fb20497f b2c69459 .config console log report syz / log C [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream KASAN: slab-out-of-bounds Read in gb_svc_request_handler
2026/11/04 14:31 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing 6628e7d4c6b2 5af5b6c6 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-upstream-usb KASAN: slab-out-of-bounds Read in gb_svc_request_handler
2026/11/19 11:36 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing f11fe7603df0 f138241c .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-usb KASAN: slab-out-of-bounds Read in gb_svc_request_handler
2026/11/04 12:53 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing 6628e7d4c6b2 5af5b6c6 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-usb KASAN: slab-out-of-bounds Read in gb_svc_request_handler
* Struck through repros no longer work on HEAD.