syzbot


ID Workflow Result Correct Bug Created Started Finished Revision Error
d721cb12-dd45-492c-9e03-aeaac97bf82b repro KCSAN: data-race in sg_common_write / sg_finish_rem_req (6) 2026/03/08 01:03 2026/03/08 01:03 2026/03/08 01:11 31e9c887f7dc24e04b3ca70d0d54fc34141844b0


ReproOpts:
{Threaded:true, Collide:true, Repeat:true, Procs:1}


ReproSyz:
r0 = syz_open_dev(&(0x7f0000000000)='sg\x00', 0x0, 0x0)
ioctl$SG_IO(r0, 0x2285, &(0x7f0000000100)={0x53, 0xfffffffe, 0x6, 0x0, 0x0, 0x80, &(0x7f0000000200)=""/128, &(0x7f0000000300)='\x12\x00\x00\x00\x60\x00', &(0x7f0000000400)=""/32, 0x2710, 0x0, 0x0, 0x0})
ioctl$SG_IO(r0, 0x2285, &(0x7f0000000100)={0x53, 0xfffffffe, 0x6, 0x0, 0x0, 0x80, &(0x7f0000000200)=""/128, &(0x7f0000000300)='\x12\x00\x00\x00\x60\x00', &(0x7f0000000400)=""/32, 0x2710, 0x0, 0x0, 0x0})


SyzkallerCommit:
31e9c887f7dc24e04b3ca70d0d54fc34141844b0

Crash report:
==================================================================
BUG: KCSAN: data-race in sg_common_write / sg_finish_rem_req

write to 0xffff888117b7b31d of 1 bytes by task 3407 on cpu 1:
 sg_unlink_reserve drivers/scsi/sg.c:2062 [inline]
 sg_finish_rem_req+0x11f/0x270 drivers/scsi/sg.c:1844
 sg_rq_end_io_usercontext+0x38/0x1c0 drivers/scsi/sg.c:1303
 process_one_work kernel/workqueue.c:3275 [inline]
 process_scheduled_works+0x4de/0x9e0 kernel/workqueue.c:3358
 worker_thread+0x581/0x770 kernel/workqueue.c:3439
 kthread+0x22a/0x280 kernel/kthread.c:467
 ret_from_fork+0x150/0x360 arch/x86/kernel/process.c:158
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

read to 0xffff888117b7b31d of 1 bytes by task 5818 on cpu 0:
 sg_start_req drivers/scsi/sg.c:1784 [inline]
 sg_common_write+0x952/0xc80 drivers/scsi/sg.c:802
 sg_new_write+0x7e4/0x8c0 drivers/scsi/sg.c:769
 sg_ioctl_common drivers/scsi/sg.c:933 [inline]
 sg_ioctl+0xbf8/0x1350 drivers/scsi/sg.c:1158
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:597 [inline]
 __se_sys_ioctl+0xce/0x140 fs/ioctl.c:583
 __x64_sys_ioctl+0x43/0x50 fs/ioctl.c:583
 x64_sys_call+0x1563/0x3020 arch/x86/include/generated/asm/syscalls_64.h:17
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0x12c/0x370 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

value changed: 0x01 -> 0x00

Reported by Kernel Concurrency Sanitizer on:
CPU: 0 UID: 0 PID: 5818 Comm: syz.0.574 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2026
==================================================================

Trajectory:
Seq Timestamp Type Name Duration
0/0 2026/03/08 01:03 flow repro
7m Results:
map[ReproOpts:{Threaded:true, Collide:true, Repeat:true, Procs:1} ReproSyz:r0 = syz_open_dev(&(0x7f0000000000)='sg\x00', 0x0, 0x0)
ioctl$SG_IO(r0, 0x2285, &(0x7f0000000100)={0x53, 0xfffffffe, 0x6, 0x0, 0x0, 0x80, &(0x7f0000000200)=""/128, &(0x7f0000000300)='\x12\x00\x00\x00\x60\x00', &(0x7f0000000400)=""/32, 0x2710, 0x0, 0x0, 0x0})
ioctl$SG_IO(r0, 0x2285, &(0x7f0000000100)={0x53, 0xfffffffe, 0x6, 0x0, 0x0, 0x80, &(0x7f0000000200)=""/128, &(0x7f0000000300)='\x12\x00\x00\x00\x60\x00', &(0x7f0000000400)=""/32, 0x2710, 0x0, 0x0, 0x0})
 SyzkallerCommit:31e9c887f7dc24e04b3ca70d0d54fc34141844b0]

1/1 2026/03/08 01:03 action provide-var
0m Results:
map[DescriptionFiles:[acpi_thermal_rel.txt aio.txt auto.txt binfmt.txt bpf.txt bpf_prog.txt bpf_trace.txt cgroup.txt damon.txt dev_ashmem.txt dev_bifrost.txt dev_binder.txt dev_binderfs.txt dev_block.txt dev_bsg.txt dev_bus_usb.txt dev_camx.txt dev_cdrom.txt dev_cec.txt dev_char_usb.txt dev_comedi.txt dev_dma_heap.txt dev_dri.txt dev_dsp.txt dev_dvb_demux.txt dev_dvb_dvr.txt dev_dvb_frontend.txt dev_fb.txt dev_floppy.txt dev_hidraw.txt dev_i2c.txt dev_i915.txt dev_img_rogue.txt dev_infiniband_rdma.txt dev_infiniband_rdma_cm.txt dev_input.txt dev_iommu.txt dev_kvm.txt dev_kvm_amd64.txt dev_kvm_arm64.txt dev_kvm_extra.txt dev_kvm_riscv64.txt dev_loop.txt dev_mali.txt dev_media.txt dev_msm.txt dev_msr.txt dev_nbd.txt dev_net_tun.txt dev_panthor.txt dev_ppp.txt dev_ptmx.txt dev_ptp.txt dev_qat_adf_ctl.txt dev_qrtr_tun.txt dev_random.txt dev_rfkill.txt dev_rtc.txt dev_sequencer.txt dev_sg.txt dev_snapshot.txt dev_snd_control.txt dev_snd_hw.txt dev_snd_midi.txt dev_snd_pcm.txt dev_snd_seq.txt dev_snd_timer.txt dev_sr.txt dev_sw_sync.txt dev_tlk_device.txt dev_trusty.txt dev_udmabuf.txt dev_uhid.txt dev_uinput.txt dev_usb_hiddev.txt dev_usbmon.txt dev_userio.txt dev_vfio.txt dev_vga_arbiter.txt dev_vhci.txt dev_video4linux.txt dev_video4linux_vim2m.txt dev_virtual_nci.txt dev_vtpm.txt fanotify.txt filesystem.txt fs_9p.txt fs_fuse.txt fs_incfs.txt fs_ioctl.txt fs_ioctl_autofs.txt fs_ioctl_btrfs.txt fs_ioctl_ext4.txt fs_ioctl_f2fs.txt fs_ioctl_fat.txt fs_ioctl_fscrypt.txt fs_ioctl_fsverity.txt fs_ioctl_xfs.txt futex.txt hafnium.txt inotify.txt io_uring.txt ipc.txt key.txt kfuzztest.txt l2cap.txt landlock.txt lsm.txt namespaces.txt net_80211.txt netfilter.txt netfilter_arp.txt netfilter_bridge.txt netfilter_ipv4.txt netfilter_ipv6.txt netfilter_ipvs.txt netfilter_targets.txt pagemap_ioctl.txt perf.txt prctl.txt quotactl.txt seccomp.txt security_apparmor.txt security_selinux.txt security_smack.txt socket.txt socket_alg.txt socket_ax25.txt socket_bluetooth.txt socket_caif.txt socket_can.txt socket_ieee802154.txt socket_inet.txt socket_inet6.txt socket_inet_dccp.txt socket_inet_icmp.txt socket_inet_igmp.txt socket_inet_l2tp.txt socket_inet_sctp.txt socket_inet_tcp.txt socket_inet_udp.txt socket_ip_tunnel.txt socket_isdn.txt socket_kcm.txt socket_key.txt socket_llc.txt socket_netlink.txt socket_netlink_audit.txt socket_netlink_crypto.txt socket_netlink_generic.txt socket_netlink_generic_80211.txt socket_netlink_generic_batadv.txt socket_netlink_generic_devlink.txt socket_netlink_generic_ethtool.txt socket_netlink_generic_fou.txt socket_netlink_generic_gtp.txt socket_netlink_generic_mptcp.txt socket_netlink_generic_net_dm.txt socket_netlink_generic_netlabel.txt socket_netlink_generic_nfc.txt socket_netlink_generic_seg6.txt socket_netlink_generic_smc.txt socket_netlink_generic_team.txt socket_netlink_generic_wireguard.txt socket_netlink_netfilter.txt socket_netlink_netfilter_acct.txt socket_netlink_netfilter_conntrack.txt socket_netlink_netfilter_conntrack_exp.txt socket_netlink_netfilter_conntrack_helper.txt socket_netlink_netfilter_ipset.txt socket_netlink_netfilter_log.txt socket_netlink_netfilter_nft_compat.txt socket_netlink_netfilter_nftables.txt socket_netlink_netfilter_osf.txt socket_netlink_netfilter_queue.txt socket_netlink_netfilter_timeout.txt socket_netlink_rdma.txt socket_netlink_route.txt socket_netlink_route_sched.txt socket_netlink_route_sched_retired.txt socket_netlink_sock_diag.txt socket_netlink_xfrm.txt socket_netrom.txt socket_nfc.txt socket_nvme_of_tcp.txt socket_packet.txt socket_phonet.txt socket_pppox.txt socket_qipcrtr.txt socket_rds.txt socket_rose.txt socket_rxrpc.txt socket_tipc.txt socket_tipc_netlink.txt socket_unix.txt socket_vnet.txt socket_x25.txt socket_xdp.txt sys.txt uffd.txt usbip.txt vmw_vmci.txt vnet.txt vnet_mptcp.txt vusb.txt watch_queue.txt xattr.txt] SyzkallerCommit:31e9c887f7dc24e04b3ca70d0d54fc34141844b0]

2/1 2026/03/08 01:03 action kernel-checkouter
0m Results:
map[KernelSrc:/usr/local/google/home/dvyukov/syzkaller/agent/workdir/cache/src/beff1935402a9eb363ce2a098524cfd0aa19e458]

3/1 2026/03/08 01:04 action kernel-builder
4m Results:
map[KernelObj:/usr/local/google/home/dvyukov/syzkaller/agent/workdir/cache/build/8f42668c8fda070e265441020f8cf0f93823a9d5]

4/1 2026/03/08 01:08 agent crash-repro-finder
2m Model:
gemini-3-pro-preview

Results:
map[ReproOpts:{Threaded:true, Collide:true, Repeat:true, Procs:1}]

Instruction:
You are an expert in linux kernel fuzzing. Your goal is to write a syzkaller program to trigger a specific bug.
Print only the syz program that could be executed directly, without backticks.




Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.

Prompt:
Bug Title: KCSAN: data-race in sg_common_write / sg_finish_rem_req

Original Crash Report:
==================================================================
BUG: KCSAN: data-race in sg_common_write / sg_finish_rem_req

write to 0xffff888117b7b31d of 1 bytes by task 3407 on cpu 1:
 sg_unlink_reserve drivers/scsi/sg.c:2062 [inline]
 sg_finish_rem_req+0x11f/0x270 drivers/scsi/sg.c:1844
 sg_rq_end_io_usercontext+0x38/0x1c0 drivers/scsi/sg.c:1303
 process_one_work kernel/workqueue.c:3275 [inline]
 process_scheduled_works+0x4de/0x9e0 kernel/workqueue.c:3358
 worker_thread+0x581/0x770 kernel/workqueue.c:3439
 kthread+0x22a/0x280 kernel/kthread.c:467
 ret_from_fork+0x150/0x360 arch/x86/kernel/process.c:158
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

read to 0xffff888117b7b31d of 1 bytes by task 5818 on cpu 0:
 sg_start_req drivers/scsi/sg.c:1784 [inline]
 sg_common_write+0x952/0xc80 drivers/scsi/sg.c:802
 sg_new_write+0x7e4/0x8c0 drivers/scsi/sg.c:769
 sg_ioctl_common drivers/scsi/sg.c:933 [inline]
 sg_ioctl+0xbf8/0x1350 drivers/scsi/sg.c:1158
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:597 [inline]
 __se_sys_ioctl+0xce/0x140 fs/ioctl.c:583
 __x64_sys_ioctl+0x43/0x50 fs/ioctl.c:583
 x64_sys_call+0x1563/0x3020 arch/x86/include/generated/asm/syscalls_64.h:17
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0x12c/0x370 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

value changed: 0x01 -> 0x00

Reported by Kernel Concurrency Sanitizer on:
CPU: 0 UID: 0 PID: 5818 Comm: syz.0.574 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2026
==================================================================


The list of existing description files:
acpi_thermal_rel.txt
aio.txt
auto.txt
binfmt.txt
bpf.txt
bpf_prog.txt
bpf_trace.txt
cgroup.txt
damon.txt
dev_ashmem.txt
dev_bifrost.txt
dev_binder.txt
dev_binderfs.txt
dev_block.txt
dev_bsg.txt
dev_bus_usb.txt
dev_camx.txt
dev_cdrom.txt
dev_cec.txt
dev_char_usb.txt
dev_comedi.txt
dev_dma_heap.txt
dev_dri.txt
dev_dsp.txt
dev_dvb_demux.txt
dev_dvb_dvr.txt
dev_dvb_frontend.txt
dev_fb.txt
dev_floppy.txt
dev_hidraw.txt
dev_i2c.txt
dev_i915.txt
dev_img_rogue.txt
dev_infiniband_rdma.txt
dev_infiniband_rdma_cm.txt
dev_input.txt
dev_iommu.txt
dev_kvm.txt
dev_kvm_amd64.txt
dev_kvm_arm64.txt
dev_kvm_extra.txt
dev_kvm_riscv64.txt
dev_loop.txt
dev_mali.txt
dev_media.txt
dev_msm.txt
dev_msr.txt
dev_nbd.txt
dev_net_tun.txt
dev_panthor.txt
dev_ppp.txt
dev_ptmx.txt
dev_ptp.txt
dev_qat_adf_ctl.txt
dev_qrtr_tun.txt
dev_random.txt
dev_rfkill.txt
dev_rtc.txt
dev_sequencer.txt
dev_sg.txt
dev_snapshot.txt
dev_snd_control.txt
dev_snd_hw.txt
dev_snd_midi.txt
dev_snd_pcm.txt
dev_snd_seq.txt
dev_snd_timer.txt
dev_sr.txt
dev_sw_sync.txt
dev_tlk_device.txt
dev_trusty.txt
dev_udmabuf.txt
dev_uhid.txt
dev_uinput.txt
dev_usb_hiddev.txt
dev_usbmon.txt
dev_userio.txt
dev_vfio.txt
dev_vga_arbiter.txt
dev_vhci.txt
dev_video4linux.txt
dev_video4linux_vim2m.txt
dev_virtual_nci.txt
dev_vtpm.txt
fanotify.txt
filesystem.txt
fs_9p.txt
fs_fuse.txt
fs_incfs.txt
fs_ioctl.txt
fs_ioctl_autofs.txt
fs_ioctl_btrfs.txt
fs_ioctl_ext4.txt
fs_ioctl_f2fs.txt
fs_ioctl_fat.txt
fs_ioctl_fscrypt.txt
fs_ioctl_fsverity.txt
fs_ioctl_xfs.txt
futex.txt
hafnium.txt
inotify.txt
io_uring.txt
ipc.txt
key.txt
kfuzztest.txt
l2cap.txt
landlock.txt
lsm.txt
namespaces.txt
net_80211.txt
netfilter.txt
netfilter_arp.txt
netfilter_bridge.txt
netfilter_ipv4.txt
netfilter_ipv6.txt
netfilter_ipvs.txt
netfilter_targets.txt
pagemap_ioctl.txt
perf.txt
prctl.txt
quotactl.txt
seccomp.txt
security_apparmor.txt
security_selinux.txt
security_smack.txt
socket.txt
socket_alg.txt
socket_ax25.txt
socket_bluetooth.txt
socket_caif.txt
socket_can.txt
socket_ieee802154.txt
socket_inet.txt
socket_inet6.txt
socket_inet_dccp.txt
socket_inet_icmp.txt
socket_inet_igmp.txt
socket_inet_l2tp.txt
socket_inet_sctp.txt
socket_inet_tcp.txt
socket_inet_udp.txt
socket_ip_tunnel.txt
socket_isdn.txt
socket_kcm.txt
socket_key.txt
socket_llc.txt
socket_netlink.txt
socket_netlink_audit.txt
socket_netlink_crypto.txt
socket_netlink_generic.txt
socket_netlink_generic_80211.txt
socket_netlink_generic_batadv.txt
socket_netlink_generic_devlink.txt
socket_netlink_generic_ethtool.txt
socket_netlink_generic_fou.txt
socket_netlink_generic_gtp.txt
socket_netlink_generic_mptcp.txt
socket_netlink_generic_net_dm.txt
socket_netlink_generic_netlabel.txt
socket_netlink_generic_nfc.txt
socket_netlink_generic_seg6.txt
socket_netlink_generic_smc.txt
socket_netlink_generic_team.txt
socket_netlink_generic_wireguard.txt
socket_netlink_netfilter.txt
socket_netlink_netfilter_acct.txt
socket_netlink_netfilter_conntrack.txt
socket_netlink_netfilter_conntrack_exp.txt
socket_netlink_netfilter_conntrack_helper.txt
socket_netlink_netfilter_ipset.txt
socket_netlink_netfilter_log.txt
socket_netlink_netfilter_nft_compat.txt
socket_netlink_netfilter_nftables.txt
socket_netlink_netfilter_osf.txt
socket_netlink_netfilter_queue.txt
socket_netlink_netfilter_timeout.txt
socket_netlink_rdma.txt
socket_netlink_route.txt
socket_netlink_route_sched.txt
socket_netlink_route_sched_retired.txt
socket_netlink_sock_diag.txt
socket_netlink_xfrm.txt
socket_netrom.txt
socket_nfc.txt
socket_nvme_of_tcp.txt
socket_packet.txt
socket_phonet.txt
socket_pppox.txt
socket_qipcrtr.txt
socket_rds.txt
socket_rose.txt
socket_rxrpc.txt
socket_tipc.txt
socket_tipc_netlink.txt
socket_unix.txt
socket_vnet.txt
socket_x25.txt
socket_xdp.txt
sys.txt
uffd.txt
usbip.txt
vmw_vmci.txt
vnet.txt
vnet_mptcp.txt
vusb.txt
watch_queue.txt
xattr.txt


Reply:
r0 = syz_open_dev(&(0x7f0000000000)='sg\x00', 0x0, 0x0)
ioctl$SG_IO(r0, 0x2285, &(0x7f0000000100)={0x53, 0xfffffffe, 0x6, 0x0, 0x0, 0x80, &(0x7f0000000200)=""/128, &(0x7f0000000300)='\x12\x00\x00\x00\x60\x00', &(0x7f0000000400)=""/32, 0x2710, 0x0, 0x0, 0x0})
ioctl$SG_IO(r0, 0x2285, &(0x7f0000000100)={0x53, 0xfffffffe, 0x6, 0x0, 0x0, 0x80, &(0x7f0000000200)=""/128, &(0x7f0000000300)='\x12\x00\x00\x00\x60\x00', &(0x7f0000000400)=""/32, 0x2710, 0x0, 0x0, 0x0})

5/2 2026/03/08 01:08 llm crash-repro-finder
2m Model:
gemini-3-pro-preview

Tokens:
							input: 2696
							output: 37
							thoughts: 17385
						

Thoughts:
**Reproducing the KCSAN Data Race in sg_common_write / sg_finish_rem_req**

Okay, here's what I'm thinking to tackle this KCSAN data race in the SCSI Generic driver: The crash report indicates a race between the `sg_finish_rem_req` function (as part of a workqueue, likely triggered by asynchronous I/O completion) and `sg_common_write`, which is called within an `ioctl` context related to `SG_IO` operations. The race specifically targets a single byte, possibly related to request buffer management (`sg_unlink_reserve` vs. `sg_start_req`).

The `sg` driver's design supports both synchronous and asynchronous SCSI command execution. The `SG_IO` `ioctl` provides synchronous behavior where the calling thread blocks until the command completes, and `write` for asynchronous operation. Based on the report, we're likely dealing with `SG_IO` calls that involve the "reserve buffer" mechanism per file descriptor. It appears that one thread is in the process of freeing the reserve buffer (`sg_unlink_reserve`), which occurs when a request completes, while another thread is trying to initiate a new request and is subsequently attempting to check if the reserve buffer is available (`sg_start_req`).

The specific variable targeted in the race seems to be either `k_malloc_chunks` or `dio_in_use` within the `sg_scatter_hold` structure, and it looks like a change from `0x01` to `0x00`. So, that 1-byte value signifies the allocation mode of the reserve buffer; either allocated with `get_free_pages` (`0x01`) or with `kmalloc` (`0x00`).

To trigger this, I need to create a situation where a request that uses the reserve buffer is completing, and a new request is starting concurrently on the same file descriptor.

To construct a syzkaller program, I'll need to leverage `syz_open_dev` to get a file descriptor for an `sg` device, probably `/dev/sg0`, then use `ioctl$SG_IO` calls to send SCSI commands. The plan is to create *two* `ioctl$SG_IO` calls in the program, targeting the *same* file descriptor to share the "reserve buffer", because the race happens only when the requests are on the same FD. I'll use `INQUIRY` command (`0x12`), or another small transfer command. I need to make sure `dxfer_len` is less than 32KB. The key will be to use the `collide=true` flag. This will force syzkaller's execution engine to schedule the two `ioctl` calls to run in parallel in separate threads, and therefore increase chances for the race to trigger. Specifically, the race depends on the workqueue and IO completion timings, which is hard to predict. Thus, collision is necessary.

I need to initialize the `sg_io_hdr` structure correctly, making sure the relevant fields like `interface_id`, `dxfer_direction`, `cmd_len`, `dxfer_len` are properly set. Also, `flags` is critical. If `SG_FLAG_DIRECT_IO` is set, we skip the reserve buffer entirely. So it must remain 0.

So, I will generate a syzkaller program with two `ioctl$SG_IO` syscalls to the *same* file descriptor. The program will be launched with a `ReproOpts` string to enable threading and collision, to execute them concurrently on the same fd.

The program should look something like:

```
r0 = syz_open_dev(&(0x7f0000000000)='sg\x00', 0x0, 0x0)
ioctl$SG_IO(r0, 0x2285, &(0x7f0000000100)={0x53, 0xfffffffe, 0x6, 0x0, 0x0, 0x80, &(0x7f0000000200)=""/128, &(0x7f0000000300)='\x12\x00\x00\x00\x60\x00', &(0x7f0000000400)=""/32, 0x2710, 0x0, 0x0, 0x0})
ioctl$SG_IO(r0, 0x2285, &(0x7


6/2 2026/03/08 01:11 tool set-results
0m Args:
map[ReproOpts:{Threaded:true, Collide:true, Repeat:true, Procs:1}]

Results:
map[ReproOpts:{Threaded:true, Collide:true, Repeat:true, Procs:1}]

7/2 2026/03/08 01:11 llm crash-repro-finder
0m Model:
gemini-3-pro-preview

Tokens:
							input: 21177
							output: 391
							thoughts: 0
						

LLM Calls Summary:
Total Calls Total Tokens Avg Tokens Total Duration (Seconds) Avg Duration (Seconds)
Tool Calls Summary:
Total Calls Total Duration (Seconds) Avg Duration (Seconds)