linux/drivers/comedi
Deepanshu Kartikey 93853512f5 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>
2026-04-02 14:40:27 +02:00
..
drivers comedi: dt2815: add hardware detection to prevent crash 2026-04-02 14:40:27 +02:00
kcomedilib comedi: kcomedilib: Add loop checking variants of open and close 2025-11-26 14:20:10 +01:00
Kconfig comedi: Add new driver for ADLink PCI-7250 series 2025-09-06 16:03:25 +02:00
Makefile
TODO
comedi_buf.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
comedi_fops.c comedi: runflags cannot determine whether to reclaim chanlist 2026-04-02 14:39:58 +02:00
comedi_internal.h comedi: Use reference count for asynchronous command functions 2025-11-26 14:19:41 +01:00
comedi_pci.c
comedi_pcmcia.c
comedi_usb.c
drivers.c comedi: Reinit dev->spinlock between attachments to low-level drivers 2026-04-02 14:39:39 +02:00
proc.c
range.c comedi: Fix getting range information for subdevices 16 to 255 2026-01-16 16:42:15 +01:00