[syzbot] [kernel?] UBSAN: shift-out-of-bounds in das16m1_attach

13 views
Skip to first unread message

syzbot

unread,
Jul 4, 2025, 12:20:31 PM7/4/25
to abb...@mev.co.uk, hswe...@visionengravers.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 4c06e63b9203 Merge tag 'for-6.16-rc4-tag' of git://git.ker..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=102c73d4580000
kernel config: https://syzkaller.appspot.com/x/.config?x=5ba6cef8f153bfeb
dashboard link: https://syzkaller.appspot.com/bug?extid=c52293513298e0fd9a94
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=166c6c8c580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=142c73d4580000

Downloadable assets:
disk image (non-bootable): https://storage.googleapis.com/syzbot-assets/d900f083ada3/non_bootable_disk-4c06e63b.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/15f2393c96b6/vmlinux-4c06e63b.xz
kernel image: https://storage.googleapis.com/syzbot-assets/44c28e8ae1a0/bzImage-4c06e63b.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+c52293...@syzkaller.appspotmail.com

UBSAN: shift-out-of-bounds in drivers/comedi/drivers/das16m1.c:525:9
shift exponent 67108867 is too large for 32-bit type 'int'
CPU: 0 UID: 0 PID: 6101 Comm: syz.0.16 Not tainted 6.16.0-rc4-syzkaller-00123-g4c06e63b9203 #0 PREEMPT(full)
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:94 [inline]
dump_stack_lvl+0x16c/0x1f0 lib/dump_stack.c:120
ubsan_epilogue lib/ubsan.c:233 [inline]
__ubsan_handle_shift_out_of_bounds+0x27f/0x420 lib/ubsan.c:494
das16m1_attach.cold+0x19/0x1e drivers/comedi/drivers/das16m1.c:525
comedi_device_attach+0x3b3/0x900 drivers/comedi/drivers.c:996
do_devconfig_ioctl+0x1a7/0x580 drivers/comedi/comedi_fops.c:855
comedi_unlocked_ioctl+0x15bb/0x2e90 drivers/comedi/comedi_fops.c:2136
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:907 [inline]
__se_sys_ioctl fs/ioctl.c:893 [inline]
__x64_sys_ioctl+0x18b/0x210 fs/ioctl.c:893
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xcd/0x4c0 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f1d8718e929
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffe20aa5098 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f1d873b5fa0 RCX: 00007f1d8718e929
RDX: 0000200000000080 RSI: 0000000040946400 RDI: 0000000000000003
RBP: 00007f1d87210b39 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f1d873b5fa0 R14: 00007f1d873b5fa0 R15: 0000000000000003
</TASK>
---[ end trace ]---


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

Kohei Enju

unread,
Jul 4, 2025, 2:11:21 PM7/4/25
to syzbot+c52293...@syzkaller.appspotmail.com, abb...@mev.co.uk, hswe...@visionengravers.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
> [...]

A quick grep found similar patterns that could have the same issue.
I think we should validate it->options[1] before shifting, right?

$ grep -nrIF "<< it->options[1]" ./drivers/comedi
./drivers/comedi/drivers/aio_iiro_16.c:180: if ((1 << it->options[1]) & 0xdcfc) {
./drivers/comedi/drivers/das16m1.c:526: (1 << it->options[1]) & 0xdcfc) {
./drivers/comedi/drivers/das6402.c:570: if ((1 << it->options[1]) & 0x8cec) {
./drivers/comedi/drivers/pcl726.c:331: if (it->options[1] && (board->irq_mask & (1 << it->options[1]))) {
./drivers/comedi/drivers/pcl812.c:1152: if ((1 << it->options[1]) & board->irq_bits) {

#syz test

diff --git a/drivers/comedi/drivers/das16m1.c b/drivers/comedi/drivers/das16m1.c
index b8ea737ad3d1..1b638f5b5a4f 100644
--- a/drivers/comedi/drivers/das16m1.c
+++ b/drivers/comedi/drivers/das16m1.c
@@ -522,7 +522,8 @@ static int das16m1_attach(struct comedi_device *dev,
devpriv->extra_iobase = dev->iobase + DAS16M1_8255_IOBASE;

/* only irqs 2, 3, 4, 5, 6, 7, 10, 11, 12, 14, and 15 are valid */
- if ((1 << it->options[1]) & 0xdcfc) {
+ if (it->options[1] >= 2 && it->options[1] <= 15 &&
+ (1 << it->options[1]) & 0xdcfc) {
ret = request_irq(it->options[1], das16m1_interrupt, 0,
dev->board_name, dev);
if (ret == 0)

syzbot

unread,
Jul 4, 2025, 3:00:05 PM7/4/25
to abb...@mev.co.uk, en...@amazon.com, hswe...@visionengravers.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-by: syzbot+c52293...@syzkaller.appspotmail.com
Tested-by: syzbot+c52293...@syzkaller.appspotmail.com

Tested on:

commit: c435a4f4 Merge tag 'riscv-for-linus-6.16-rc5' of git:/..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=139d4582580000
kernel config: https://syzkaller.appspot.com/x/.config?x=5ba6cef8f153bfeb
dashboard link: https://syzkaller.appspot.com/bug?extid=c52293513298e0fd9a94
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=149e6c8c580000

Note: testing is done by a robot and is best-effort only.

Ian Abbott

unread,
Jul 7, 2025, 6:18:32 AM7/7/25
to Kohei Enju, syzbot+c52293...@syzkaller.appspotmail.com, hswe...@visionengravers.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Thanks.

That looks fine. If you plan to submit an official patch, please Cc it
to Greg KH because I do not have commit access to any pulled git repos.

The Fixes: line for this is as follows:

Fixes: 729988507680 ("staging: comedi: das16m1: tidy up the irq support
in das16m1_attach()"

Can also add:

Cc: <sta...@vger.kernel.org> # 5.13+

(Comedi moved out of staging in 5.13, so a backport is required for
earlier longterm series.)

If you don't want to deal with it, let me know, and I'll send the patch
and credit you with a 'Suggested-by' tag, or something more explicit
with your permission.

--
-=( Ian Abbott <abb...@mev.co.uk> || MEV Ltd. is a company )=-
-=( registered in England & Wales. Regd. number: 02862268. )=-
-=( Regd. addr.: S11 & 12 Building 67, Europa Business Park, )=-
-=( Bird Hall Lane, STOCKPORT, SK3 0XA, UK. || www.mev.co.uk )=-

Enju, Kohei

unread,
Jul 7, 2025, 7:36:10 AM7/7/25
to Ian Abbott, syzbot+c52293...@syzkaller.appspotmail.com, hswe...@visionengravers.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Thank you for taking a look and suggesting appropriate tags.

Unfortunately I don't have the bandwidth to prepare an official patch at the
moment, so would you (or anyone else) be able to handle it? I would appreciate
it if you could add a `Suggested-by` tag.

(To be honest, I think someone who knows this driver better than me would
write a superior patch.)

>--
>-=( Ian Abbott <abb...@mev.co.uk> || MEV Ltd. is a company )=-
>-=( registered in England & Wales. Regd. number: 02862268. )=-
>-=( Regd. addr.: S11 & 12 Building 67, Europa Business Park, )=-
>-=( Bird Hall Lane, STOCKPORT, SK3 0XA, UK. || www.mev.co.uk )=-

Thanks,
Kohei.

Reply all
Reply to author
Forward
0 new messages