general protection fault in upd78f0730_tiocmset

Status: moderation: reported on 2026/11/16 20:14
Subsystems: usb
Labels: prio:high
[Documentation on labels]
Reported-by: syzbot+c95f70fb4cf2bb11b221@syzkaller.appspotmail.com
First crash: 1h38m, last: 1h37m
✨ AI cause bisection: introduced by (AI job) :
commit ea534e0b404762894ac55ee416c0ac9f5cd5045a
Author: Maksim Salau <maksim.salau@gmail.com>
Date: Wed Jan 25 20:40:40 2017 +0000

  USB: serial: add uPD78F0730 USB to Serial Adaptor Driver

  
✨ AI-generated root cause summary:

In drivers/usb/serial/upd78f0730.c, upd78f0730_dtr_rts() attempts to obtain the tty_struct from port->port.tty and pass it to upd78f0730_tiocmset(tty, set, clear). However, during a tty hangup (such as when the USB device is disconnected while open), tty_port_hangup() clears port->tty = NULL before calling tty_port_shutdown_locked(). When C_HUPCL is set on the port, tty_port_shutdown_locked() invokes tty_port_lower_dtr_rts(), calling into upd78f0730_dtr_rts() with port->port.tty already set to NULL. Consequently, upd78f0730_tiocmset() dereferences tty->driver_data (offset 0x620) on a NULL tty pointer, leading to a general protection fault / NULL-pointer dereference crash.

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

Technical Analysis of the Root Cause

1. Vulnerability Mechanism and Files Involved

The bug is located in drivers/usb/serial/upd78f0730.c in the implementation of the dtr_rts USB serial driver callback:

  • File: drivers/usb/serial/upd78f0730.c
  • Functions: upd78f0730_dtr_rts() (lines 268–280) and upd78f0730_tiocmset() (lines 204–239)
  • Structs/Fields: struct usb_serial_port::port (struct tty_port::tty) and struct tty_struct::driver_data (at byte offset 0x620 / 1568 bytes).

In upd78f0730.c:

static int upd78f0730_tiocmset(struct tty_struct *tty,
			unsigned int set, unsigned int clear)
{
	struct usb_serial_port *port = tty->driver_data;
    ...
}

static void upd78f0730_dtr_rts(struct usb_serial_port *port, int on)
{
	struct tty_struct *tty = port->port.tty;
	unsigned int set = 0;
	unsigned int clear = 0;

	if (on)
		set = TIOCM_DTR | TIOCM_RTS;
	else
		clear = TIOCM_DTR | TIOCM_RTS;

	upd78f0730_tiocmset(tty, set, clear);
}

The dtr_rts callback of struct usb_serial_driver takes struct usb_serial_port *port directly (void (*dtr_rts)(struct usb_serial_port *port, int on)). In upd78f0730_dtr_rts(), the function attempts to retrieve port->port.tty solely to forward it to upd78f0730_tiocmset(tty, ...). Inside upd78f0730_tiocmset(), tty is only used to unpack tty->driver_data back into struct usb_serial_port *port.

2. Triggering Sequence and Lifecycle Invariant Violation

When a USB serial port is opened and subsequently disconnected, or when an open tty port is hung up:

  1. usb_serial_disconnect() invokes tty_port_tty_vhangup(&port->port).
  2. tty_port_tty_vhangup() initiates a synchronous hangup (tty_vhangup() -> __tty_hangup()).
  3. __tty_hangup() invokes the driver's hangup callback (serial_hangup() in drivers/usb/serial/usb-serial.c), which calls tty_port_hangup(&port->port).
  4. In tty_port_hangup() (drivers/tty/tty_port.c:395–406):
    scoped_guard(mutex, &port->mutex) {
        scoped_guard(spinlock_irqsave, &port->lock) {
            port->count = 0;
            tty = port->tty;
            if (tty)
                set_bit(TTY_IO_ERROR, &tty->flags);
            port->tty = NULL;   /* <--- port->tty explicitly set to NULL */
        }
    
        tty_port_set_active(port, false);
        tty_port_shutdown_locked(port, tty);
    }
    
    port->tty is cleared to NULL.
  5. tty_port_shutdown_locked() receives the saved local pointer tty. If the terminal flags have C_HUPCL(tty) set (hangup on close/drop lines), tty_port_shutdown_locked() calls:
    if (tty && C_HUPCL(tty))
        tty_port_lower_dtr_rts(port);
    
  6. tty_port_lower_dtr_rts(port) invokes port->ops->dtr_rts(port, false) -> serial_port_dtr_rts() -> upd78f0730_dtr_rts(port, 0).
  7. upd78f0730_dtr_rts() reads port->port.tty, which is now NULL.
  8. upd78f0730_dtr_rts() calls upd78f0730_tiocmset(NULL, 0, TIOCM_DTR | TIOCM_RTS).
  9. upd78f0730_tiocmset() attempts to access tty->driver_data at offset 0x620 from NULL (0x0000000000000620). In KASAN-instrumented kernels, the shadow memory check for 0x620 (0xdffffc0000000000 + (0x620 >> 3) == 0xdffffc00000000c4) fails, generating the reported GPF null-ptr-deref.

3. Resolution

upd78f0730.c should not rely on port->port.tty. Instead, like other USB serial drivers (e.g. xr_serial.c, cp210x.c), modem control line updates should be factored into a helper function operating directly on struct usb_serial_port *port (e.g. upd78f0730_tiocmset_port(port, set, clear)). Both upd78f0730_tiocmset() and upd78f0730_dtr_rts() should call this helper, allowing upd78f0730_dtr_rts() to update DTR/RTS without ever referencing tty_struct.

▶ ▼ ✨ AI Jobs (3)
ID Workflow Result Correct Bug Created Started Finished Revision
8a4e5669 bisect-cause ❓ general protection fault in upd78f0730_tiocmset 2026/11/16 19:08 2026/11/16 19:08 2026/11/16 20:30 f5be7dee
4a94c27a assessment-security DenialOfService: ✅ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ✅ RemoteTrigger: ❌ Unprivileged: ❌ UserNamespace: ❌ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ general protection fault in upd78f0730_tiocmset 2026/11/16 19:08 2026/11/16 19:08 2026/11/16 20:06 f5be7dee
282280f4 assessment-security DenialOfService: ✅ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ❌ UserNamespace: ❌ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ general protection fault in upd78f0730_tiocmset 2026/11/16 19:08 2026/11/16 19:08 2026/11/16 20:06 f5be7dee

Sample crash report:
usb 5-1: USB disconnect, device number 2
Oops: general protection fault, probably for non-canonical address 0xdffffc00000000c4: 0000 [#1] SMP KASAN NOPTI
KASAN: null-ptr-deref in range [0x0000000000000620-0x0000000000000627]
CPU: 0 UID: 0 PID: 10 Comm: kworker/0:0 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: usb_hub_wq hub_event
RIP: 0010:upd78f0730_tiocmset+0x86/0x4a0 drivers/usb/serial/upd78f0730.c:207
Code: 48 c1 e9 03 48 b8 f1 f1 f1 f1 f8 f3 f3 f3 48 89 4c 24 18 4a 89 04 31 e8 38 14 fd f9 48 81 c3 20 06 00 00 48 89 d8 48 c1 e8 03 <42> 80 3c 30 00 74 08 48 89 df e8 6b 7a 76 fa 48 8b 1b 48 b9 00 00
RSP: 0018:ffffc9000023f1e0 EFLAGS: 00010202
RAX: 00000000000000c4 RBX: 0000000000000620 RCX: ffff88801d7b2580
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: ffffc9000023f2a0 R08: ffff88804404023f R09: 1ffff11008808047
R10: dffffc0000000000 R11: ffffffff87cc2770 R12: dffffc0000000000
R13: 0000000000000000 R14: dffffc0000000000 R15: 0000000000000006
FS:  0000000000000000(0000) GS:ffff88808a9f1000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fa47cc3ffe8 CR3: 0000000045753000 CR4: 0000000000352ef0
Call Trace:
 <TASK>
 tty_port_lower_dtr_rts drivers/tty/tty_port.c:500 [inline]
 tty_port_shutdown_locked+0x1b5/0x290 drivers/tty/tty_port.c:359
 tty_port_hangup+0xf9/0x180 drivers/tty/tty_port.c:405
 __tty_hangup+0x5ec/0x6a0 drivers/tty/tty_io.c:646
 tty_port_tty_vhangup+0xc1/0x120 drivers/tty/tty_port.c:442
 usb_serial_disconnect+0x134/0x580 drivers/usb/serial/usb-serial.c:1244
 usb_unbind_interface+0x295/0x9c0 drivers/usb/core/driver.c:460
 device_remove drivers/base/dd.c:619 [inline]
 __device_release_driver drivers/base/dd.c:1357 [inline]
 device_release_driver_internal+0x48d/0x7d0 drivers/base/dd.c:1380
 bus_remove_device+0x444/0x560 drivers/base/bus.c:678
 device_del+0x524/0x8f0 drivers/base/core.c:3967
 usb_disable_device+0x3d4/0x8d0 drivers/usb/core/message.c:1484
 usb_disconnect+0x346/0x9a0 drivers/usb/core/hub.c:2355
 hub_port_connect drivers/usb/core/hub.c:5425 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5725 [inline]
 port_event drivers/usb/core/hub.c:5889 [inline]
 hub_event+0x1bbb/0x4d30 drivers/usb/core/hub.c:5971
 process_one_work kernel/workqueue.c:3495 [inline]
 process_scheduled_works+0xc3d/0x1630 kernel/workqueue.c:3578
 worker_thread+0xa47/0xfb0 kernel/workqueue.c:3659
 kthread+0x38b/0x480 kernel/kthread.c:436
 ret_from_fork+0x514/0xb70 arch/x86/kernel/process.c:158
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
 </TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:upd78f0730_tiocmset+0x86/0x4a0 drivers/usb/serial/upd78f0730.c:207
Code: 48 c1 e9 03 48 b8 f1 f1 f1 f1 f8 f3 f3 f3 48 89 4c 24 18 4a 89 04 31 e8 38 14 fd f9 48 81 c3 20 06 00 00 48 89 d8 48 c1 e8 03 <42> 80 3c 30 00 74 08 48 89 df e8 6b 7a 76 fa 48 8b 1b 48 b9 00 00
RSP: 0018:ffffc9000023f1e0 EFLAGS: 00010202
RAX: 00000000000000c4 RBX: 0000000000000620 RCX: ffff88801d7b2580
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: ffffc9000023f2a0 R08: ffff88804404023f R09: 1ffff11008808047
R10: dffffc0000000000 R11: ffffffff87cc2770 R12: dffffc0000000000
R13: 0000000000000000 R14: dffffc0000000000 R15: 0000000000000006
FS:  0000000000000000(0000) GS:ffff88808a9f1000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00005625c6d51fb0 CR3: 0000000045753000 CR4: 0000000000352ef0
----------------
Code disassembly (best guess):
   0:	48 c1 e9 03          	shr    $0x3,%rcx
   4:	48 b8 f1 f1 f1 f1 f8 	movabs $0xf3f3f3f8f1f1f1f1,%rax
   b:	f3 f3 f3
   e:	48 89 4c 24 18       	mov    %rcx,0x18(%rsp)
  13:	4a 89 04 31          	mov    %rax,(%rcx,%r14,1)
  17:	e8 38 14 fd f9       	call   0xf9fd1454
  1c:	48 81 c3 20 06 00 00 	add    $0x620,%rbx
  23:	48 89 d8             	mov    %rbx,%rax
  26:	48 c1 e8 03          	shr    $0x3,%rax
* 2a:	42 80 3c 30 00       	cmpb   $0x0,(%rax,%r14,1) <-- trapping instruction
  2f:	74 08                	je     0x39
  31:	48 89 df             	mov    %rbx,%rdi
  34:	e8 6b 7a 76 fa       	call   0xfa767aa4
  39:	48 8b 1b             	mov    (%rbx),%rbx
  3c:	48                   	rex.W
  3d:	b9                   	.byte 0xb9

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/11/16 19:08 upstream aebb72744764 31830773 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root general protection fault in upd78f0730_tiocmset
2026/11/16 19:08 upstream aebb72744764 31830773 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root general protection fault in upd78f0730_tiocmset
* Struck through repros no longer work on HEAD.