syzbot


assert "TAILQ_EMPTY(&kq->kq_head)" failed in kern_event.c

Status: fixed on 2021/01/27 16:59
Reported-by: syzbot+757c60a2aa1125137cce@syzkaller.appspotmail.com
Fix commit: 715db9d67ba3 kqueue: Fix termination assert
First crash: 1398d, last: 1398d

Sample crash report:
login: panic: kernel diagnostic assertion "TAILQ_EMPTY(&kq->kq_head)" failed: file "/syzkaller/managers/multicore/kernel/sys/kern/kern_event.c", line 1268
Stopped at      db_enter+0x18:  addq    $0x8,%rsp
    TID    PID    UID     PRFLAGS     PFLAGS  CPU  COMMAND
 197323  51321      0         0x2          0    0  syz-executor0300
*112919  51321      0         0x2  0x4000000    1K syz-executor0300
db_enter() at db_enter+0x18 sys/arch/amd64/amd64/db_interface.c:398
panic(ffffffff823c3c11) at panic+0x15e sys/kern/subr_prf.c:218
__assert(ffffffff8242d86c,ffffffff82425328,4f4,ffffffff823ad335) at __assert+0x2b sys/kern/subr_prf.c:162
kqueue_terminate(0,fffffd806e92ebd0) at kqueue_terminate+0x152 sys/kern/kern_event.c:1268
kqueue_close(fffffd807bacfa18,ffff8000ffff6010) at kqueue_close+0x40 sys/kern/kern_event.c:1286
fdrop(fffffd807bacfa18,ffff8000ffff6010) at fdrop+0xc2 sys/kern/kern_descrip.c:1279
closef(fffffd807bacfa18,ffff8000ffff6010) at closef+0x11c sys/kern/kern_descrip.c:1263
finishdup(ffff8000ffff6010,fffffd807bacf1c8,4,3,ffff800021263ac0,2) at finishdup+0x321 sys/kern/kern_descrip.c:691
dodup3(ffff8000ffff6010,4,3,0,ffff800021263ac0) at dodup3+0x5cf sys/kern/kern_descrip.c:397
syscall(ffff800021263b40) at syscall+0x4a1 mi_syscall sys/sys/syscall_mi.h:102 [inline]
syscall(ffff800021263b40) at syscall+0x4a1 sys/arch/amd64/amd64/trap.c:590
Xsyscall() at Xsyscall+0x128
end of kernel
end trace frame: 0x553cbc72400, count: 4
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{1}> 
ddb{1}> set $lines = 0
ddb{1}> set $maxwidth = 0
ddb{1}> show panic
kernel diagnostic assertion "TAILQ_EMPTY(&kq->kq_head)" failed: file "/syzkaller/managers/multicore/kernel/sys/kern/kern_event.c", line 1268
ddb{1}> trace
db_enter() at db_enter+0x18 sys/arch/amd64/amd64/db_interface.c:398
panic(ffffffff823c3c11) at panic+0x15e sys/kern/subr_prf.c:218
__assert(ffffffff8242d86c,ffffffff82425328,4f4,ffffffff823ad335) at __assert+0x2b sys/kern/subr_prf.c:162
kqueue_terminate(0,fffffd806e92ebd0) at kqueue_terminate+0x152 sys/kern/kern_event.c:1268
kqueue_close(fffffd807bacfa18,ffff8000ffff6010) at kqueue_close+0x40 sys/kern/kern_event.c:1286
fdrop(fffffd807bacfa18,ffff8000ffff6010) at fdrop+0xc2 sys/kern/kern_descrip.c:1279
closef(fffffd807bacfa18,ffff8000ffff6010) at closef+0x11c sys/kern/kern_descrip.c:1263
finishdup(ffff8000ffff6010,fffffd807bacf1c8,4,3,ffff800021263ac0,2) at finishdup+0x321 sys/kern/kern_descrip.c:691
dodup3(ffff8000ffff6010,4,3,0,ffff800021263ac0) at dodup3+0x5cf sys/kern/kern_descrip.c:397
syscall(ffff800021263b40) at syscall+0x4a1 mi_syscall sys/sys/syscall_mi.h:102 [inline]
syscall(ffff800021263b40) at syscall+0x4a1 sys/arch/amd64/amd64/trap.c:590
Xsyscall() at Xsyscall+0x128
end of kernel
end trace frame: 0x553cbc72400, count: -11
ddb{1}> show registers
rdi                                0
rsi                              0x1
rbp               0xffff8000212636e0
rbx               0xffff8000212636f0
rdx                             0x8b
rcx                              0x2
rax                              0x1
r8                0xffffffff821c43c5    kprintf+0x145
r9                               0x1
r10               0xcb6961b596649ad8
r11               0x16407f50b9183eb9
r12                     0x3000000008
r13               0xffff800021263790
r14                            0x100
r15                              0x1
rip               0xffffffff81df8258    db_enter+0x18
cs                               0x8
rflags                         0x246
rsp               0xffff8000212636d0
ss                              0x10
db_enter+0x18:  addq    $0x8,%rsp
ddb{1}> show proc
PROC (syz-executor0300) pid=112919 stat=onproc
    flags process=2<EXEC,8ORPHAN> proc=4000000<THREAD>
    pri=51, usrpri=52, nice=20
    forw=0xffffffffffffffff, list=0xffff8000ffff6a90,0xffffffff828cc870
    process=0xffff800021237b20 user=0xffff80002125e000, vmspace=0xfffffd806e958b88
    estcpu=2, cpticks=2, pctcpu=0.0
    user=0, sys=2, intr=0
ddb{1}> ps
   PID     TID   PPID    UID  S       FLAGS  WAIT          COMMAND
 51321  197323  50703      0  7         0x2                syz-executor0300
 51321  190353  50703      0  3   0x4000082  kqread        syz-executor0300
*51321  112919  50703      0  7   0x4000002                syz-executor0300
 50703  149745  11815      0  3    0x10008a  sigsusp       ksh
 11815  390694  73368      0  3        0x92  select        sshd
 62372  290428      1      0  3    0x100083  ttyin         getty
 73368  245579      1      0  3        0x80  select        sshd
 35433  110868  59713     74  3    0x100092  bpf           pflogd
 59713  265960      1      0  3        0x80  netio         pflogd
 54099  272565   9666     73  3    0x100090  kqread        syslogd
  9666  318417      1      0  3    0x100082  netio         syslogd
 16601  107028      1     77  3    0x100090  poll          dhclient
 84410  219328      1      0  3        0x80  poll          dhclient
 62790  124690      0      0  3     0x14200  bored         smr
 66871   59757      0      0  3     0x14200  pgzero        zerothread
 30331  477396      0      0  3     0x14200  aiodoned      aiodoned
 81708  505581      0      0  3     0x14200  syncer        update
 95402  453358      0      0  3     0x14200  cleaner       cleaner
 13988  384572      0      0  3     0x14200  reaper        reaper
 14947   89188      0      0  3     0x14200  pgdaemon      pagedaemon
 47789  474653      0      0  3     0x14200  bored         crynlk
 32799  102920      0      0  3     0x14200  bored         crypto
 69885  236507      0      0  3     0x14200  bored         viomb
 13609  335168      0      0  3  0x40014200  acpi0         acpi0
 11157  252716      0      0  3  0x40014200                idle1
 18238   84317      0      0  3     0x14200  bored         softnet
 78028  426606      0      0  3     0x14200  bored         systqmp
 65747  192525      0      0  3     0x14200  bored         systq
 24956  207493      0      0  3  0x40014200  bored         softclock
 40753  260519      0      0  3  0x40014200                idle0
     1  466301      0      0  3        0x82  wait          init
     0       0     -1      0  3     0x10200  scheduler     swapper
ddb{1}> show all locks
Process 51321 (syz-executor0300) thread 0xffff8000ffff6010 (112919)
exclusive kernel_lock &kernel_lock r = 0 (0xffffffff828cca98)
#0  witness_lock+0x4b0 stacktrace_save sys/sys/stacktrace.h:36 [inline]
#0  witness_lock+0x4b0 sys/kern/subr_witness.c:1176
#1  kqueue_close+0x2d sys/kern/kern_event.c:1284
#2  fdrop+0xc2 sys/kern/kern_descrip.c:1279
#3  closef+0x11c sys/kern/kern_descrip.c:1263
#4  finishdup+0x321 sys/kern/kern_descrip.c:691
#5  dodup3+0x5cf sys/kern/kern_descrip.c:397
#6  syscall+0x4a1 mi_syscall sys/sys/syscall_mi.h:102 [inline]
#6  syscall+0x4a1 sys/arch/amd64/amd64/trap.c:590
#7  Xsyscall+0x128
ddb{1}> show malloc
           Type InUse  MemUse  HighUse   Limit  Requests Type Lim
         devbuf  9475   6411K    6412K  78643K     10565        0
            pcb    13      8K       8K  78643K        13        0
         rtable    61      2K       2K  78643K       127        0
         ifaddr    29      8K       8K  78643K        30        0
       counters    40     33K      33K  78643K        40        0
       ioctlops     0      0K       4K  78643K      1467        0
          mount     1      1K       1K  78643K         1        0
         vnodes  1183     74K      75K  78643K      1188        0
      UFS quota     1     32K      32K  78643K         1        0
      UFS mount     5     36K      36K  78643K         5        0
            shm     2      1K       1K  78643K         2        0
         VM map     2      1K       1K  78643K         2        0
            sem     2      0K       0K  78643K         2        0
        dirhash    12      2K       2K  78643K        12        0
           ACPI  1697    195K     286K  78643K     12598        0
      file desc     1      0K       0K  78643K         1        0
           proc    59     63K      71K  78643K       367        0
    NFS srvsock     1      0K       0K  78643K         1        0
     NFS daemon     1     16K      16K  78643K         1        0
       in_multi    11      0K       0K  78643K        11        0
    ether_multi     1      0K       0K  78643K         1        0
    ISOFS mount     1     32K      32K  78643K         1        0
  MSDOSFS mount     1     16K      16K  78643K         1        0
           ttys    19     95K      95K  78643K        19        0
           exec     0      0K       2K  78643K       302        0
        pagedep     1      8K       8K  78643K         1        0
       inodedep     1     32K      32K  78643K         1        0
         newblk     1      0K       0K  78643K         1        0
        VM swap     7     26K      26K  78643K         7        0
       UVM amap    38      2K       2K  78643K       596        0
       UVM aobj     3      2K       2K  78643K         3        0
        memdesc     1      4K       4K  78643K         1        0
    crypto data     1      1K       1K  78643K         1        0
            NDP     4      0K       0K  78643K         4        0
           temp    23   3969K    4033K  78643K      1687        0
         kqueue     3      4K       4K  78643K         3        0
      SYN cache     2     16K      16K  78643K         2        0
ddb{1}> show all pools
Name      Size Requests Fail Releases Pgreq Pgrel Npage Hiwat Minpg Maxpg Idle
arp         64        2    0        0     1     0     1     1     0     8    0
plcache    128       20    0        0     1     0     1     1     0     8    0
rtpcb      120       15    0       13     1     0     1     1     0     8    0
rtentry    112       23    0        1     1     0     1     1     0     8    0
unpcb      120       29    0       19     1     0     1     1     0     8    0
syncache   296        5    0        5     2     1     1     1     0     8    1
tcpqe       32        1    0        1     1     1     0     1     0     8    0
tcpcb      736        8    0        4     1     0     1     1     0     8    0
inpcb      304       29    0       22     1     0     1     1     0     8    0
pfosfp      40     1428    0     1005     5     0     5     5     0     8    0
pfosfpen   112     1428    0      714    21     0    21    21     0     8    0
pfstitem    24        9    0        2     1     0     1     1     0     8    0
pfstkey    112        9    0        2     1     0     1     1     0     8    0
pfstate    328        9    0        2     1     0     1     1     0     8    0
pfrule     1360      21    0       16     2     1     1     2     0     8    0
art_heap8  4096       1    0        0     1     0     1     1     0     8    0
art_heap4  256       95    0        0     6     0     6     6     0     8    0
art_table   32       96    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     1398    0       16    87     0    87    87     0     8    0
ffsino     272     1398    0       16    93     0    93    93     0     8    0
nchpl      144     1572    0       33    59     1    58    58     0     8    0
uvmvnodes   72     1408    0        0    26     0    26    26     0     8    0
vnodes     224     1408    0        0    83     0    83    83     0     8    0
namei      1024    3781    0     3781     2     1     1     1     0     8    1
percpumem   16       31    0        0     1     0     1     1     0     8    0
scxspl     216     3637    0     3637    10     9     1     8     0     8    1
plimitpl   152       14    0        8     1     0     1     1     0     8    0
sigapl     424      221    0      192     4     0     4     4     0     8    0
knotepl    112        6    0        1     1     0     1     1     0     8    0
kqueuepl   168        2    0        0     1     0     1     1     0     8    0
pipepl     336       64    0       60     2     1     1     1     0     8    0
fdescpl    496      205    0      192     3     0     3     3     0     8    0
filepl     152      959    0      909     2     0     2     2     0     8    0
lockfpl    104        5    0        4     1     0     1     1     0     8    0
lockfspl    48        3    0        2     1     0     1     1     0     8    0
sessionpl  144       18    0        9     1     0     1     1     0     8    0
pgrppl      48       18    0        9     1     0     1     1     0     8    0
ucredpl     96       62    0       53     1     0     1     1     0     8    0
zombiepl   144      192    0      192     2     1     1     1     0     8    1
processpl  1080     221    0      192     3     0     3     3     0     8    0
procpl     672      223    0      192     3     0     3     3     0     8    0
sockpl     432       73    0       54     4     1     3     3     0     8    0
mcl4k      4096       3    0        0     1     0     1     1     0     8    0
mcl2k      2048      64    0        0     8     0     8     8     0     8    0
mtagpl      96        1    0        0     1     0     1     1     0     8    0
mbufpl     256       95    0        0     5     0     5     5     0     8    0
bufpl      280     2005    0      112   136     0   136   136     0     8    0
anonpl      24    19974    0    18705    11     2     9    10     0   186    1
amapchunkpl 152     531    0      490     3     1     2     3     0   158    0
amappl16   200       77    0       72     1     0     1     1     0     8    0
amappl15   192        1    0        0     1     0     1     1     0     8    0
amappl14   184       22    0       19     1     0     1     1     0     8    0
amappl13   176       14    0       13     2     1     1     1     0     8    0
amappl12   168        4    0        4     2     1     1     1     0     8    1
amappl11   160       51    0       36     1     0     1     1     0     8    0
amappl10   152       12    0       10     1     0     1     1     0     8    0
amappl9    144      234    0      234     2     1     1     1     0     8    1
amappl8    136       63    0       61     1     0     1     1     0     8    0
amappl7    128      209    0      208     1     0     1     1     0     8    0
amappl6    120       57    0       49     1     0     1     1     0     8    0
amappl5    112      355    0      340     1     0     1     1     0     8    0
amappl4    104      275    0      252     1     0     1     1     0     8    0
amappl3     96      108    0      100     1     0     1     1     0     8    0
amappl2     88      840    0      779     2     0     2     2     0     8    0
amappl1     80    14214    0    13776    17     6    11    17     0     8    0
amappl      88      405    0      383     1     0     1     1     0    92    0
dma4096    4096       1    0        1     1     1     0     1     0     8    0
dma1024    1024       1    0        0     1     0     1     1     0     8    0
dma256     256        6    0        6     1     1     0     1     0     8    0
dma128     128      253    0      253     1     1     0     1     0     8    0
dma64       64        6    0        6     1     1     0     1     0     8    0
dma32       32        7    0        7     1     1     0     1     0     8    0
dma16       16       18    0       17     1     0     1     1     0     8    0
aobjpl      64        2    0        0     1     0     1     1     0     8    0
uaddrrnd    24      205    0      192     1     0     1     1     0     8    0
uaddrbest   32        2    0        0     1     0     1     1     0     8    0
uaddr       24      205    0      192     1     0     1     1     0     8    0
vmmpekpl   168     5587    0     5569     1     0     1     1     0     8    0
vmmpepl    168    30085    0    29205    51    12    39    48     0   357    0
vmsppl     368      204    0      192     2     0     2     2     0     8    0
rwobjpl     56     7705    0     7129    14     5     9    13     0     8    0
pdppl      4096     417    0      384    51    18    33    39     0     8    0
pvpl        32    80770    0    77718    34     6    28    28     0   265    0
pmappl     232      204    0      192     1     0     1     1     0     8    0
extentpl    40       58    0       40     1     0     1     1     0     8    0
phpool     112      267    0       23     8     0     8     8     0     8    0
ddb{1}> machine ddbcpu 0
Stopped at      x86_ipi_db+0x1a:        addq    $0x8,%rsp
x86_ipi_db(ffffffff82738ff0) at x86_ipi_db+0x1a sys/arch/amd64/amd64/db_interface.c:352
x86_ipi_handler() at x86_ipi_handler+0xb7 sys/arch/amd64/amd64/ipi.c:106
Xresume_lapic_ipi() at Xresume_lapic_ipi+0x23
__mp_lock(ffffffff828cc890) at __mp_lock+0x129 __mp_lock_spin sys/kern/kern_lock.c:116 [inline]
__mp_lock(ffffffff828cc890) at __mp_lock+0x129 sys/kern/kern_lock.c:147
softintr_dispatch(0) at softintr_dispatch+0x4e sys/arch/amd64/amd64/softintr.c:90
Xsoftclock() at Xsoftclock+0x1f
end of kernel
end trace frame: 0x7f7fffff4f40, count: 9
ddb{0}> trace
x86_ipi_db(ffffffff82738ff0) at x86_ipi_db+0x1a sys/arch/amd64/amd64/db_interface.c:352
x86_ipi_handler() at x86_ipi_handler+0xb7 sys/arch/amd64/amd64/ipi.c:106
Xresume_lapic_ipi() at Xresume_lapic_ipi+0x23
__mp_lock(ffffffff828cc890) at __mp_lock+0x129 __mp_lock_spin sys/kern/kern_lock.c:116 [inline]
__mp_lock(ffffffff828cc890) at __mp_lock+0x129 sys/kern/kern_lock.c:147
softintr_dispatch(0) at softintr_dispatch+0x4e sys/arch/amd64/amd64/softintr.c:90
Xsoftclock() at Xsoftclock+0x1f
end of kernel
end trace frame: 0x7f7fffff4f40, count: -6
ddb{0}> machine ddbcpu 1
Stopped at      db_enter+0x18:  addq    $0x8,%rsp
db_enter() at db_enter+0x18 sys/arch/amd64/amd64/db_interface.c:398
panic(ffffffff823c3c11) at panic+0x15e sys/kern/subr_prf.c:218
__assert(ffffffff8242d86c,ffffffff82425328,4f4,ffffffff823ad335) at __assert+0x2b sys/kern/subr_prf.c:162
kqueue_terminate(0,fffffd806e92ebd0) at kqueue_terminate+0x152 sys/kern/kern_event.c:1268
kqueue_close(fffffd807bacfa18,ffff8000ffff6010) at kqueue_close+0x40 sys/kern/kern_event.c:1286
fdrop(fffffd807bacfa18,ffff8000ffff6010) at fdrop+0xc2 sys/kern/kern_descrip.c:1279
closef(fffffd807bacfa18,ffff8000ffff6010) at closef+0x11c sys/kern/kern_descrip.c:1263
finishdup(ffff8000ffff6010,fffffd807bacf1c8,4,3,ffff800021263ac0,2) at finishdup+0x321 sys/kern/kern_descrip.c:691
dodup3(ffff8000ffff6010,4,3,0,ffff800021263ac0) at dodup3+0x5cf sys/kern/kern_descrip.c:397
syscall(ffff800021263b40) at syscall+0x4a1 mi_syscall sys/sys/syscall_mi.h:102 [inline]
syscall(ffff800021263b40) at syscall+0x4a1 sys/arch/amd64/amd64/trap.c:590
Xsyscall() at Xsyscall+0x128
end of kernel
end trace frame: 0x553cbc72400, count: 4
ddb{1}> trace
db_enter() at db_enter+0x18 sys/arch/amd64/amd64/db_interface.c:398
panic(ffffffff823c3c11) at panic+0x15e sys/kern/subr_prf.c:218
__assert(ffffffff8242d86c,ffffffff82425328,4f4,ffffffff823ad335) at __assert+0x2b sys/kern/subr_prf.c:162
kqueue_terminate(0,fffffd806e92ebd0) at kqueue_terminate+0x152 sys/kern/kern_event.c:1268
kqueue_close(fffffd807bacfa18,ffff8000ffff6010) at kqueue_close+0x40 sys/kern/kern_event.c:1286
fdrop(fffffd807bacfa18,ffff8000ffff6010) at fdrop+0xc2 sys/kern/kern_descrip.c:1279
closef(fffffd807bacfa18,ffff8000ffff6010) at closef+0x11c sys/kern/kern_descrip.c:1263
finishdup(ffff8000ffff6010,fffffd807bacf1c8,4,3,ffff800021263ac0,2) at finishdup+0x321 sys/kern/kern_descrip.c:691
dodup3(ffff8000ffff6010,4,3,0,ffff800021263ac0) at dodup3+0x5cf sys/kern/kern_descrip.c:397
syscall(ffff800021263b40) at syscall+0x4a1 mi_syscall sys/sys/syscall_mi.h:102 [inline]
syscall(ffff800021263b40) at syscall+0x4a1 sys/arch/amd64/amd64/trap.c:590
Xsyscall() at Xsyscall+0x128
end of kernel
end trace frame: 0x553cbc72400, count: -11
ddb{1}> 

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2021/01/26 14:08 openbsd 044aaac6d42e 52e37319 .config console log report syz C ci-openbsd-multicore assert "TAILQ_EMPTY(&kq->kq_head)" failed in kern_event.c
2021/01/26 13:57 openbsd 044aaac6d42e 52e37319 .config console log report ci-openbsd-multicore assert "TAILQ_EMPTY(&kq->kq_head)" failed in kern_event.c
* Struck through repros no longer work on HEAD.