Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

comedi: dt2815: add hardware detection to prevent crash

The dt2815 driver crashes when attached to I/O ports without actual
hardware present. This occurs because syzkaller or users can attach
the driver to arbitrary I/O addresses via COMEDI_DEVCONFIG ioctl.

When no hardware exists at the specified port, inb() operations return
0xff (floating bus), but outb() operations can trigger page faults due
to undefined behavior, especially under race conditions:

BUG: unable to handle page fault for address: 000000007fffff90
#PF: supervisor write access in kernel mode
#PF: error_code(0x0002) - not-present page
RIP: 0010:dt2815_attach+0x6e0/0x1110

Add hardware detection by reading the status register before attempting
any write operations. If the read returns 0xff, assume no hardware is
present and fail the attach with -ENODEV. This prevents crashes from
outb() operations on non-existent hardware.

Reported-by: syzbot+72f94b474d6e50b71ffc@syzkaller.appspotmail.com
Cc: stable <stable@kernel.org>
Closes: https://syzkaller.appspot.com/bug?extid=72f94b474d6e50b71ffc
Tested-by: syzbot+72f94b474d6e50b71ffc@syzkaller.appspotmail.com
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
Link: [https://lore.kernel.org/all/20260126070458.10974-1-kartikey406@gmail.com/T/]
Link: [https://lore.kernel.org/all/20260126070458.10974-1-kartikey406@gmail.com/T/
Link: https://patch.msgid.link/20260309104859.503529-1-kartikey406@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Deepanshu Kartikey and committed by
Greg Kroah-Hartman
93853512 29f644f1

+12
+12
drivers/comedi/drivers/dt2815.c
··· 175 175 ? current_range_type : voltage_range_type; 176 176 } 177 177 178 + /* 179 + * Check if hardware is present before attempting any I/O operations. 180 + * Reading 0xff from status register typically indicates no hardware 181 + * on the bus (floating bus reads as all 1s). 182 + */ 183 + if (inb(dev->iobase + DT2815_STATUS) == 0xff) { 184 + dev_err(dev->class_dev, 185 + "No hardware detected at I/O base 0x%lx\n", 186 + dev->iobase); 187 + return -ENODEV; 188 + } 189 + 178 190 /* Init the 2815 */ 179 191 outb(0x00, dev->iobase + DT2815_STATUS); 180 192 for (i = 0; i < 100; i++) {