syzbot


panic: unix: lock not held

Status: fixed on 2024/04/05 18:25
Reported-by: syzbot+00450333592fcd38c6fe@syzkaller.appspotmail.com
Fix commit: e679c1f37540 Allow listen(2) only on sockets of type SOCK_STREAM or SOCK_SEQPACKET. listen(2) man(1) page clearly prohibits sockets of other types.
First crash: 236d, last: 236d

Sample crash report:
panic: unix: lock not held
Stopped at      db_enter+0x1c:  addq    $0x8,%rsp
    TID    PID    UID     PRFLAGS     PFLAGS  CPU  COMMAND
*215936  26110      0   0x8000002          0    0  syz-executor1534187535
db_enter() at db_enter+0x1c sys/arch/amd64/amd64/db_interface.c:437
panic(ffffffff82865988) at panic+0x165 sys/kern/subr_prf.c:198
rw_assert_wrlock(fffffd806ed125c8) at rw_assert_wrlock+0xb7 sys/kern/kern_rwlock.c:387
filt_soread(fffffd807474bbb8,0) at filt_soread+0x123 sys/kern/uipc_socket.c:2237
knote_locked(fffffd806ed126e0,0) at knote_locked+0x78 filter_event sys/kern/kern_event.c:778 [inline]
knote_locked(fffffd806ed126e0,0) at knote_locked+0x78 sys/kern/kern_event.c:1845
sowakeup(fffffd806ed125c0,fffffd806ed12670) at sowakeup+0x82 sys/kern/uipc_socket2.c:611
sorwakeup(fffffd806ed125c0) at sorwakeup+0xfb sys/kern/uipc_socket.c:1791
uipc_dgram_send(fffffd80760e8b88,fffffd806d281e00,fffffd806d281300,0) at uipc_dgram_send+0x1b7 sys/kern/uipc_usrreq.c:585
sosend(fffffd80760e8b88,fffffd806d281300,ffff80002a61ce48,0,0,0) at sosend+0x663
sendit(ffff80002a5d72a0,5,ffff80002a61cfc0,0,ffff80002a61d070) at sendit+0x555 sys/kern/uipc_syscalls.c:786
sys_sendmsg(ffff80002a5d72a0,ffff80002a61d120,ffff80002a61d070) at sys_sendmsg+0x19e sys/kern/uipc_syscalls.c:604
syscall(ffff80002a61d120) at syscall+0x538 sys/arch/amd64/amd64/trap.c:577
Xsyscall() at Xsyscall+0x128
end of kernel
end trace frame: 0x70c00c0ee8b0, count: 2
https://www.openbsd.org/ddb.html describes the minimum info required in bug
reports.  Insufficient info makes it difficult to find and fix bugs.
ddb> 
ddb> set $lines = 0
ddb> set $maxwidth = 0
ddb> show panic
*cpu0: unix: lock not held
ddb> trace
db_enter() at db_enter+0x1c sys/arch/amd64/amd64/db_interface.c:437
panic(ffffffff82865988) at panic+0x165 sys/kern/subr_prf.c:198
rw_assert_wrlock(fffffd806ed125c8) at rw_assert_wrlock+0xb7 sys/kern/kern_rwlock.c:387
filt_soread(fffffd807474bbb8,0) at filt_soread+0x123 sys/kern/uipc_socket.c:2237
knote_locked(fffffd806ed126e0,0) at knote_locked+0x78 filter_event sys/kern/kern_event.c:778 [inline]
knote_locked(fffffd806ed126e0,0) at knote_locked+0x78 sys/kern/kern_event.c:1845
sowakeup(fffffd806ed125c0,fffffd806ed12670) at sowakeup+0x82 sys/kern/uipc_socket2.c:611
sorwakeup(fffffd806ed125c0) at sorwakeup+0xfb sys/kern/uipc_socket.c:1791
uipc_dgram_send(fffffd80760e8b88,fffffd806d281e00,fffffd806d281300,0) at uipc_dgram_send+0x1b7 sys/kern/uipc_usrreq.c:585
sosend(fffffd80760e8b88,fffffd806d281300,ffff80002a61ce48,0,0,0) at sosend+0x663
sendit(ffff80002a5d72a0,5,ffff80002a61cfc0,0,ffff80002a61d070) at sendit+0x555 sys/kern/uipc_syscalls.c:786
sys_sendmsg(ffff80002a5d72a0,ffff80002a61d120,ffff80002a61d070) at sys_sendmsg+0x19e sys/kern/uipc_syscalls.c:604
syscall(ffff80002a61d120) at syscall+0x538 sys/arch/amd64/amd64/trap.c:577
Xsyscall() at Xsyscall+0x128
end of kernel
end trace frame: 0x70c00c0ee8b0, count: -13
ddb> show registers
rdi                                0
rsi                              0x1
rbp               0xffff80002a61cab0
rbx               0xffffffff82ca5ff0    cpu_info_full_primary+0x1ff0
rdx                            0x3fd
rcx                                0
rax                             0x1b
r8                 0x101010101010101
r9                0x8080808080808080
r10               0x744e97e1a276d896
r11               0xb4281dedd6b4dbfa
r12                                0
r13                                0
r14                                0
r15                              0x1
rip               0xffffffff811a086c    db_enter+0x1c
cs                               0x8
rflags                         0x246
rsp               0xffff80002a61caa0
ss                              0x10
db_enter+0x1c:  addq    $0x8,%rsp
ddb> show proc
PROC (syz-executor1534187535) tid=215936 pid=26110 tcnt=1 stat=onproc
    flags process=8000002<EXEC> proc=0
    runpri=17, usrpri=52, slppri=17, nice=20
    wchan=0x0, wmesg=, ps_single=0x0
    forw=0xffffffffffffffff, list=0xffff80002a5d6008,0xffffffff82e14630
    process=0xffff8000ffff69f0 user=0xffff80002a618000, vmspace=0xfffffd80074a2000
    estcpu=2, cpticks=1, pctcpu=0.0, user=0, sys=1, intr=0
ddb> ps
   PID     TID   PPID    UID  S       FLAGS  WAIT          COMMAND
*26110  215936  35576      0  7   0x8000002                syz-executor1534187535
 35576  240061  45440      0  3   0x810008a  sigsusp       ksh
 45440  370183  15785      0  3  0x1800009a  kqread        sshd
 45793  354489      1      0  3  0x18100083  ttyin         getty
 15785  213817      1      0  3  0x18000088  kqread        sshd
 41307  358715  29069     73  3  0x19100090  kqread        syslogd
 29069  184757      1      0  3  0x18100082  netio         syslogd
 16457  468889      1      0  3  0x18100080  kqread        resolvd
 61778  248055  38398     77  3  0x18100092  kqread        dhcpleased
 30627  512430  38398     77  3  0x18100092  kqread        dhcpleased
 38398   52547      1      0  3  0x18000080  kqread        dhcpleased
 97015  108940      0      0  3     0x14200  bored         smr
 66159   17835      0      0  3     0x14200  pgzero        zerothread
 86816  115960      0      0  3     0x14200  aiodoned      aiodoned
 92801  104633      0      0  3     0x14200  syncer        update
 26390   15979      0      0  3     0x14200  cleaner       cleaner
 11696   58498      0      0  3     0x14200  reaper        reaper
 22833  398391      0      0  3     0x14200  pgdaemon      pagedaemon
 54567  286057      0      0  3     0x14200  bored         viomb
 34170  417224      0      0  3  0x40014200  acpi0         acpi0
 32243  264711      0      0  3     0x14200  bored         softnet3
 96098  372896      0      0  3     0x14200  bored         softnet2
 57812  400789      0      0  3     0x14200  bored         softnet1
 87376   31174      0      0  3     0x14200  bored         softnet0
 69130   52153      0      0  3     0x14200  bored         systqmp
 30157  406578      0      0  3     0x14200  bored         systq
 57599   69185      0      0  3  0x40014200  tmoslp        softclock
  6199   30174      0      0  3  0x40014200                idle0
     1  213137      0      0  3   0x8000082  wait          init
     0       0     -1      0  3     0x10200  scheduler     swapper
ddb> show all locks
No such command
ddb> show malloc
           Type InUse  MemUse  HighUse   Limit  Requests Type Lim
         devbuf 10137   6382K    6413K 166960K     11215        0
            pcb    15     10K      10K 166960K        15        0
         rtable    58      1K       2K 166960K       112        0
             pf    12      6K       6K 166960K        12        0
         ifaddr    11      5K       5K 166960K        11        0
        ifgroup    17      1K       1K 166960K        17        0
       counters    22     16K      16K 166960K        22        0
       ioctlops     0      0K       2K 166960K        21        0
          mount     1      1K       1K 166960K         1        0
            log     0      0K       0K 166960K         4        0
         vnodes  1259     79K      79K 166960K      1275        0
      UFS quota     1     32K      32K 166960K         1        0
      UFS mount     5     36K      36K 166960K         5        0
            shm     2      1K       1K 166960K         2        0
         VM map     2      1K       1K 166960K         2        0
            sem     2      0K       0K 166960K         2        0
        dirhash    12      2K       2K 166960K        12        0
           ACPI  1697    195K     286K 166960K     12548        0
      file desc     1      0K       0K 166960K         1        0
           proc    55     58K      59K 166960K       246        0
    NFS srvsock     1      0K       0K 166960K         1        0
     NFS daemon     1     16K      16K 166960K         1        0
       in_multi    11      0K       0K 166960K        11        0
    ether_multi     1      0K       0K 166960K         1        0
    ISOFS mount     1     32K      32K 166960K         1        0
  MSDOSFS mount     1     16K      16K 166960K         1        0
           ttys    25    122K     122K 166960K        25        0
           exec     0      0K       1K 166960K       246        0
            tdb     3      0K       0K 166960K         3        0
        VM swap     8     62K      64K 166960K        10        0
       UVM amap    94      4K       5K 166960K      2132        0
       UVM aobj     3      2K       2K 166960K         3        0
     pinsyscall    21     42K      48K 166960K       849        0
        memdesc     1      4K       4K 166960K         1        0
    crypto data     1      1K       1K 166960K         1        0
            NDP     3      0K       0K 166960K         3        0
           temp     1   6788K    6852K 166960K      3236        0
         kqueue    12     18K      18K 166960K        25        0
      SYN cache     2     16K      16K 166960K         2        0
ddb> show all pools
Name      Size Requests Fail Releases Pgreq Pgrel Npage Hiwat Minpg Maxpg Idle
rtpcb      120       21    0       18     1     0     1     1     0     8    0
rtentry    112       23    0        1     1     0     1     1     0     8    0
unpcb      144       36    0       21     1     0     1     1     0     8    0
syncache   336        5    0        5     1     0     1     1     0     8    1
tcpqe       32       18    0       18     1     0     1     1     0     8    1
tcpcb      808        8    0        5     1     0     1     1     0     8    0
arp         88        2    0        0     1     0     1     1     0     8    0
inpcb      360       26    0       20     1     0     1     1     0     8    0
art_heap8  4096       1    0        0     1     0     1     1     0     8    0
art_heap4  256       96    0        0     6     0     6     6     0     8    0
art_table   32       97    0        0     1     0     1     1     0     8    0
art_node    16       22    0        2     1     0     1     1     0     8    0
dirhash    1024      17    0        0     3     0     3     3     0     8    0
dino2pl    256     1503    0       40    92     0    92    92     0     8    0
ffsino     240     1503    0       40    87     0    87    87     0     8    0
nchpl      144     1687    0       47    61     0    61    61     0     8    0
uvmvnodes   80     1512    0        0    31     0    31    31     0     8    0
vnodes     216     1512    0        0    84     0    84    84     0     8    0
namei      1024    4358    0     4358     1     0     1     1     0     8    1
kstatmem   264        6    0        0     1     0     1     1     0     8    0
scxspl     216     5178    0     5178     2     0     2     2     1     8    2
plimitpl   152       16    0       10     1     0     1     1     0     8    0
sigapl     424      311    0      282     4     0     4     4     0     8    0
knotepl    120     7366    0     7336     2     0     2     2     0     8    1
kqueuepl   184       21    0       13     1     0     1     1     0     8    0
pipepl     288       88    0       85     1     0     1     1     0     8    0
fdescpl    432      295    0      282     2     0     2     2     0     8    0
filepl     120     1139    0     1084     2     0     2     2     0     8    0
lockfpl    104        6    0        4     1     0     1     1     0     8    0
lockfspl    48        4    0        2     1     0     1     1     0     8    0
sessionpl  144       17    0        9     1     0     1     1     0     8    0
pgrppl      48       17    0        9     1     0     1     1     0     8    0
ucredpl    104       66    0       56     1     0     1     1     0     8    0
zombiepl   144      282    0      282     1     0     1     1     0     8    1
processpl  1072     311    0      282     3     0     3     3     0     8    0
procpl     680      311    0      282     3     0     3     3     0     8    0
sockpl     488       83    0       59     4     0     4     4     0     8    0
mcl8k      8192       4    0        4     1     0     1     1     0     8    1
mcl4k      4096      10    0       10     1     0     1     1     0     8    1
mcl2k      2048   12161    0    12121    26    12    14    26     0     8    8
mtagpl      96        4    0        4     1     0     1     1     0     8    1
mbufpl     256    20074    0    20025    15     4    11    15     0     8    7
bufpl      280     2474    0       89   171     0   171   171     0     8    0
anonpl      24   134257    0   132462    23     0    23    23     0   188   12
amapchunkpl 152    7439    0     7308     7     0     7     7     0   158    1
amappl16   200     3216    0     3215     4     0     4     4     0     8    3
amappl15   192        8    0        8     1     0     1     1     0     8    1
amappl14   184       97    0       88     1     0     1     1     0     8    0
amappl13   176       12    0       12     1     0     1     1     0     8    1
amappl12   168      794    0      782     1     0     1     1     0     8    0
amappl11   160       52    0       42     1     0     1     1     0     8    0
amappl10   152       16    0       16     1     0     1     1     0     8    1
amappl9    144       95    0       95     1     0     1     1     0     8    1
amappl8    136       21    0       19     1     0     1     1     0     8    0
amappl7    128       14    0       12     1     0     1     1     0     8    0
amappl6    120      162    0      151     1     0     1     1     0     8    0
amappl5    112      115    0      103     1     0     1     1     0     8    0
amappl4    104      389    0      362     1     0     1     1     0     8    0
amappl3     96     2484    0     2458     1     0     1     1     0     8    0
amappl2     88      575    0      525     2     0     2     2     0     8    0
amappl1     80     8800    0     8396    10     0    10    10     0     8    0
amappl      88     1828    0     1780     2     0     2     2     0    92    0
dma4096    4096       1    0        1     1     0     1     1     0     8    1
dma1024    1024       1    0        0     1     0     1     1     0     8    0
dma256     256        6    0        6     1     0     1     1     0     8    1
dma128     128      253    0      253     1     0     1     1     0     8    1
dma64       64        6    0        6     1     0     1     1     0     8    1
dma32       32        7    0        7     1     0     1     1     0     8    1
dma16       16       18    0       17     1     0     1     1     0     8    0
aobjpl      72        2    0        0     1     0     1     1     0     8    0
uaddrrnd    24      295    0      282     1     0     1     1     0     8    0
uaddrbest   32        2    0        0     1     0     1     1     0     8    0
uaddr       24      295    0      282     1     0     1     1     0     8    0
vmmpekpl   168     5627    0     5610     1     0     1     1     0     8    0
vmmpepl    168    32251    0    31353    46     0    46    46     0   357    1
vmsppl     352      294    0      282     2     0     2     2     0     8    0
rwobjpl     24    16955    0    14842    14     0    14    14     0     8    0
pdppl      4096     596    0      564    48    14    34    40     0     8    2
pvpl        32   226188    0   222145    50     0    50    50     0   265   14
pmappl     216      294    0      282     1     0     1     1     0     8    0
extentpl    40       56    0       38     1     0     1     1     0     8    0
phpool     112      290    0       30     8     0     8     8     0     8    0
ddb> machine ddbcpu 0
No such command
ddb> trace
db_enter() at db_enter+0x1c sys/arch/amd64/amd64/db_interface.c:437
panic(ffffffff82865988) at panic+0x165 sys/kern/subr_prf.c:198
rw_assert_wrlock(fffffd806ed125c8) at rw_assert_wrlock+0xb7 sys/kern/kern_rwlock.c:387
filt_soread(fffffd807474bbb8,0) at filt_soread+0x123 sys/kern/uipc_socket.c:2237
knote_locked(fffffd806ed126e0,0) at knote_locked+0x78 filter_event sys/kern/kern_event.c:778 [inline]
knote_locked(fffffd806ed126e0,0) at knote_locked+0x78 sys/kern/kern_event.c:1845
sowakeup(fffffd806ed125c0,fffffd806ed12670) at sowakeup+0x82 sys/kern/uipc_socket2.c:611
sorwakeup(fffffd806ed125c0) at sorwakeup+0xfb sys/kern/uipc_socket.c:1791
uipc_dgram_send(fffffd80760e8b88,fffffd806d281e00,fffffd806d281300,0) at uipc_dgram_send+0x1b7 sys/kern/uipc_usrreq.c:585
sosend(fffffd80760e8b88,fffffd806d281300,ffff80002a61ce48,0,0,0) at sosend+0x663
sendit(ffff80002a5d72a0,5,ffff80002a61cfc0,0,ffff80002a61d070) at sendit+0x555 sys/kern/uipc_syscalls.c:786
sys_sendmsg(ffff80002a5d72a0,ffff80002a61d120,ffff80002a61d070) at sys_sendmsg+0x19e sys/kern/uipc_syscalls.c:604
syscall(ffff80002a61d120) at syscall+0x538 sys/arch/amd64/amd64/trap.c:577
Xsyscall() at Xsyscall+0x128
end of kernel
end trace frame: 0x70c00c0ee8b0, count: -13
ddb> machine ddbcpu 1
No such command
ddb> trace
db_enter() at db_enter+0x1c sys/arch/amd64/amd64/db_interface.c:437
panic(ffffffff82865988) at panic+0x165 sys/kern/subr_prf.c:198
rw_assert_wrlock(fffffd806ed125c8) at rw_assert_wrlock+0xb7 sys/kern/kern_rwlock.c:387
filt_soread(fffffd807474bbb8,0) at filt_soread+0x123 sys/kern/uipc_socket.c:2237
knote_locked(fffffd806ed126e0,0) at knote_locked+0x78 filter_event sys/kern/kern_event.c:778 [inline]
knote_locked(fffffd806ed126e0,0) at knote_locked+0x78 sys/kern/kern_event.c:1845
sowakeup(fffffd806ed125c0,fffffd806ed12670) at sowakeup+0x82 sys/kern/uipc_socket2.c:611
sorwakeup(fffffd806ed125c0) at sorwakeup+0xfb sys/kern/uipc_socket.c:1791
uipc_dgram_send(fffffd80760e8b88,fffffd806d281e00,fffffd806d281300,0) at uipc_dgram_send+0x1b7 sys/kern/uipc_usrreq.c:585
sosend(fffffd80760e8b88,fffffd806d281300,ffff80002a61ce48,0,0,0) at sosend+0x663
sendit(ffff80002a5d72a0,5,ffff80002a61cfc0,0,ffff80002a61d070) at sendit+0x555 sys/kern/uipc_syscalls.c:786
sys_sendmsg(ffff80002a5d72a0,ffff80002a61d120,ffff80002a61d070) at sys_sendmsg+0x19e sys/kern/uipc_syscalls.c:604
syscall(ffff80002a61d120) at syscall+0x538 sys/arch/amd64/amd64/trap.c:577
Xsyscall() at Xsyscall+0x128
end of kernel
end trace frame: 0x70c00c0ee8b0, count: -13
ddb> 

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/03/30 23:03 openbsd 2ee472d028ec 6ee49f2e .config console log report syz C [disk image] [bsd.gdb] [kernel image] ci-openbsd-main panic: unix: lock not held
2024/03/30 22:46 openbsd 2ee472d028ec 6ee49f2e .config console log report [disk image] [bsd.gdb] [kernel image] ci-openbsd-main panic: unix: lock not held
* Struck through repros no longer work on HEAD.