syzbot


witness: userret: ioctl

Status: fixed on 2020/10/22 20:39
Reported-by: syzbot+b9af9c29ed1a6dabda25@syzkaller.appspotmail.com
Fix commit: 610c242e11d3 - missing NET_UNLOCK() in pf_ioctl.c error path
First crash: 774d, last: 774d
similar bugs (2):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
openbsd witness: userret: ioctl (3) syz 2 347d 347d 3/3 fixed on 2021/12/23 16:59
openbsd witness: userret: ioctl (2) 1 363d 363d 3/3 fixed on 2021/12/08 00:40

Sample crash report:
witness: userret: returning with the following locks held:
exclusive rwlock netlock r = 0 (0xffffffff82748670)
#0  witness_lock+0x4b0 stacktrace_save sys/sys/stacktrace.h:36 [inline]
#0  witness_lock+0x4b0 sys/kern/subr_witness.c:1164
#1  pfioctl+0x1fc7
#2  VOP_IOCTL+0x9a sys/kern/vfs_vops.c:297
#3  vn_ioctl+0xba sys/kern/vfs_vnops.c:531
#4  sys_ioctl+0x4b0
#5  syscall+0x4a1 mi_syscall sys/sys/syscall_mi.h:102 [inline]
#5  syscall+0x4a1 sys/arch/amd64/amd64/trap.c:591
#6  Xsyscall+0x128
panic: witness_warn
Stopped at      db_enter+0x18:  addq    $0x8,%rsp
    TID    PID    UID     PRFLAGS     PFLAGS  CPU  COMMAND
* 10121  21389      0         0x2          0    0  syz-executor2539
db_enter() at db_enter+0x18 sys/arch/amd64/amd64/db_interface.c:398
panic(ffffffff823becb8) at panic+0x15e sys/kern/subr_prf.c:218
witness_warn(2,0,ffffffff8243f0a3) at witness_warn+0x68f witness_debugger sys/kern/subr_witness.c:2493 [inline]
witness_warn(2,0,ffffffff8243f0a3) at witness_warn+0x68f sys/kern/subr_witness.c:1455
userret(ffff8000ffff7720) at userret+0x337 sys/kern/kern_sig.c:1932
syscall(ffff800021265670) at syscall+0x55c mi_syscall_return sys/sys/syscall_mi.h:129 [inline]
syscall(ffff800021265670) at syscall+0x55c sys/arch/amd64/amd64/trap.c:613
Xsyscall() at Xsyscall+0x128
end of kernel
end trace frame: 0x7f7fffffa6c0, count: 9
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{0}> 
ddb{0}> set $lines = 0
ddb{0}> set $maxwidth = 0
ddb{0}> show panic
witness_warn
ddb{0}> trace
db_enter() at db_enter+0x18 sys/arch/amd64/amd64/db_interface.c:398
panic(ffffffff823becb8) at panic+0x15e sys/kern/subr_prf.c:218
witness_warn(2,0,ffffffff8243f0a3) at witness_warn+0x68f witness_debugger sys/kern/subr_witness.c:2493 [inline]
witness_warn(2,0,ffffffff8243f0a3) at witness_warn+0x68f sys/kern/subr_witness.c:1455
userret(ffff8000ffff7720) at userret+0x337 sys/kern/kern_sig.c:1932
syscall(ffff800021265670) at syscall+0x55c mi_syscall_return sys/sys/syscall_mi.h:129 [inline]
syscall(ffff800021265670) at syscall+0x55c sys/arch/amd64/amd64/trap.c:613
Xsyscall() at Xsyscall+0x128
end of kernel
end trace frame: 0x7f7fffffa6c0, count: -6
ddb{0}> show registers
rdi                                0
rsi                              0x1
rbp               0xffff8000212653c0
rbx               0xffff8000212653d0
rdx                             0x8b
rcx                              0x2
rax                              0x1
r8                0xffffffff821a7fd6    kprintf+0x146
r9                               0x1
r10               0x7a3a2598fac713c6
r11                0x6fc419eccdd6605
r12                     0x3000000008
r13               0xffff800021265470
r14                            0x100
r15                              0x1
rip               0xffffffff81213b78    db_enter+0x18
cs                               0x8
rflags                         0x246
rsp               0xffff8000212653b0
ss                              0x10
db_enter+0x18:  addq    $0x8,%rsp
ddb{0}> show proc
PROC (syz-executor2539) pid=10121 stat=onproc
    flags process=2<EXEC,8ORPHAN> proc=0
    pri=55, usrpri=56, nice=20
    forw=0xffffffffffffffff, list=0xffff8000ffff79b0,0xffffffff82893308
    process=0xffff80002125d090 user=0xffff800021260000, vmspace=0xfffffd806e963008
    estcpu=6, cpticks=3, pctcpu=0.0
    user=0, sys=3, intr=0
ddb{0}> ps
   PID     TID   PPID    UID  S       FLAGS  WAIT          COMMAND
*21389   10121  82805      0  7         0x2                syz-executor2539
 82805  140132  93966      0  3    0x10008a  pause         ksh
 93966  358023  25233      0  3        0x52  netlock       sshd
 82481  402492      1      0  3    0x100083  ttyin         getty
 25233  169491      1      0  3        0x80  select        sshd
 38812   45768  76525     74  3    0x100092  bpf           pflogd
 76525  498208      1      0  3        0x80  netio         pflogd
 75498  385478  83375     73  3    0x100010  ffs_fsync     syslogd
 83375  223131      1      0  3    0x100082  netio         syslogd
 34914  186540      1     77  3    0x100090  poll          dhclient
 66521  444419      1      0  3        0x80  poll          dhclient
 95394  319143      0      0  3     0x14200  bored         smr
 99159  237799      0      0  3     0x14200  pgzero        zerothread
 34469  271224      0      0  3     0x14200  aiodoned      aiodoned
  1828  290997      0      0  3     0x14200  syncer        update
 60905  251221      0      0  3     0x14200  cleaner       cleaner
 49122   66996      0      0  3     0x14200  reaper        reaper
  8954  486062      0      0  3     0x14200  pgdaemon      pagedaemon
 38533  173370      0      0  3     0x14200  bored         crynlk
 70534  292390      0      0  3     0x14200  bored         crypto
 20476  260354      0      0  3     0x14200  bored         viomb
 33004  142852      0      0  3  0x40014200  acpi0         acpi0
 53878  304808      0      0  7  0x40014200                idle1
 21573    8622      0      0  3     0x14200  bored         softnet
 98491  241351      0      0  3     0x14200  bored         systqmp
 94220  338954      0      0  3     0x14200  bored         systq
 95425  190288      0      0  3  0x40014200  bored         softclock
  7861  213667      0      0  3  0x40014200                idle0
     1  402624      0      0  3        0x82  wait          init
     0       0     -1      0  3     0x10200  scheduler     swapper
ddb{0}> show all locks
Process 21389 (syz-executor2539) thread 0xffff8000ffff7720 (10121)
exclusive rwlock netlock r = 0 (0xffffffff82748670)
#0  witness_lock+0x4b0 stacktrace_save sys/sys/stacktrace.h:36 [inline]
#0  witness_lock+0x4b0 sys/kern/subr_witness.c:1164
#1  pfioctl+0x1fc7
#2  VOP_IOCTL+0x9a sys/kern/vfs_vops.c:297
#3  vn_ioctl+0xba sys/kern/vfs_vnops.c:531
#4  sys_ioctl+0x4b0
#5  syscall+0x4a1 mi_syscall sys/sys/syscall_mi.h:102 [inline]
#5  syscall+0x4a1 sys/arch/amd64/amd64/trap.c:591
#6  Xsyscall+0x128
Process 75498 (syslogd) thread 0xffff8000ffff6ce0 (385478)
exclusive rrwlock inode r = 0 (0xfffffd807357a1a8)
#0  witness_lock+0x4b0 stacktrace_save sys/sys/stacktrace.h:36 [inline]
#0  witness_lock+0x4b0 sys/kern/subr_witness.c:1164
#1  rw_enter+0x446 sys/kern/kern_rwlock.c:311
#2  rrw_enter+0x88 sys/kern/kern_rwlock.c:462
#3  VOP_LOCK+0x4b sys/kern/vfs_vops.c:614
#4  vn_lock+0x6c sys/kern/vfs_vnops.c:575
#5  sys_fsync+0x113 sys/kern/vfs_syscalls.c:2887
#6  syscall+0x4a1 mi_syscall sys/sys/syscall_mi.h:102 [inline]
#6  syscall+0x4a1 sys/arch/amd64/amd64/trap.c:591
#7  Xsyscall+0x128
ddb{0}> show malloc
           Type InUse  MemUse  HighUse   Limit  Requests Type Lim
         devbuf  9474   6410K    6411K  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    39     33K      33K  78643K        39        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  1825    197K     290K  78643K     13109        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    37      2K       2K  78643K       595        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   3949K    4013K  78643K      1688        0
         kqueue     2      2K       2K  78643K         2        0
      SYN cache     2     16K      16K  78643K         2        0
ddb{0}> 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
tcpcb      736        8    0        5     1     0     1     1     0     8    0
inpcb      296       29    0       23     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        0     1     0     1     1     0     8    0
pfstkey    112        9    0        0     1     0     1     1     0     8    0
pfstate    328        9    0        0     1     0     1     1     0     8    0
pfrule     1360      21    0       15     2     0     2     2     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     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     208     1408    0        0    75     0    75    75     0     8    0
namei      1024    3781    0     3781     2     1     1     1     0     8    1
percpumem   16       30    0        0     1     0     1     1     0     8    0
scxspl     216     3281    0     3280     2     1     1     2     0     8    0
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        5    0        0     1     0     1     1     0     8    0
kqueuepl   152        1    0        0     1     0     1     1     0     8    0
pipepl     304       64    0       60     2     1     1     1     0     8    0
fdescpl    496      205    0      192     3     0     3     3     0     8    0
filepl     152      958    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  1056     221    0      192     3     0     3     3     0     8    0
procpl     656      221    0      192     3     0     3     3     0     8    0
sockpl     400       73    0       55     2     0     2     2     0     8    0
mcl4k      4096       1    0        0     1     0     1     1     0     8    0
mcl2k      2048      79    0        0    10     0    10    10     0     8    0
mtagpl      96        1    0        0     1     0     1     1     0     8    0
mbufpl     256       91    0        0     6     0     6     6     0     8    0
bufpl      280     1931    0      112   130     0   130   130     0     8    0
anonpl      16    19690    0    18453     8     2     6     7     0   124    0
amapchunkpl 152     527    0      490     3     1     2     3     0   158    0
amappl16   192       81    0       76     1     0     1     1     0     8    0
amappl15   184        1    0        0     1     0     1     1     0     8    0
amappl14   176       22    0       19     1     0     1     1     0     8    0
amappl13   168       14    0       13     2     1     1     1     0     8    0
amappl12   160       11    0       11     1     1     0     1     0     8    0
amappl11   152       50    0       35     1     0     1     1     0     8    0
amappl10   144        6    0        4     1     0     1     1     0     8    0
amappl9    136      194    0      194     2     1     1     1     0     8    1
amappl8    128       62    0       61     1     0     1     1     0     8    0
amappl7    120      213    0      210     1     0     1     1     0     8    0
amappl6    112       58    0       51     1     0     1     1     0     8    0
amappl5    104      367    0      350     1     0     1     1     0     8    0
amappl4     96      276    0      252     1     0     1     1     0     8    0
amappl3     88      103    0       96     1     0     1     1     0     8    0
amappl2     80      852    0      801     3     1     2     2     0     8    0
amappl1     72    14220    0    13799    15     5    10    15     0     8    0
amappl      80      403    0      383     1     0     1     1     0    84    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     5537    0     5517     2     0     2     2     0     8    0
vmmpepl    168    29927    0    29099    48     8    40    48     0   357    1
vmsppl     368      204    0      192     2     0     2     2     0     8    0
pdppl      4096     417    0      384     5     0     5     5     0     8    0
pvpl        32    80777    0    77790    32     4    28    28     0   265    1
pmappl     232      204    0      192     1     0     1     1     0     8    0
extentpl    40       57    0       39     1     0     1     1     0     8    0
phpool     112      224    0        3     7     0     7     7     0     8    0
ddb{0}> machine ddbcpu 0
Invalid cpu 0
ddb{0}> trace
db_enter() at db_enter+0x18 sys/arch/amd64/amd64/db_interface.c:398
panic(ffffffff823becb8) at panic+0x15e sys/kern/subr_prf.c:218
witness_warn(2,0,ffffffff8243f0a3) at witness_warn+0x68f witness_debugger sys/kern/subr_witness.c:2493 [inline]
witness_warn(2,0,ffffffff8243f0a3) at witness_warn+0x68f sys/kern/subr_witness.c:1455
userret(ffff8000ffff7720) at userret+0x337 sys/kern/kern_sig.c:1932
syscall(ffff800021265670) at syscall+0x55c mi_syscall_return sys/sys/syscall_mi.h:129 [inline]
syscall(ffff800021265670) at syscall+0x55c sys/arch/amd64/amd64/trap.c:613
Xsyscall() at Xsyscall+0x128
end of kernel
end trace frame: 0x7f7fffffa6c0, count: -6
ddb{0}> machine ddbcpu 1
Stopped at      x86_ipi_db+0x1a:        addq    $0x8,%rsp
x86_ipi_db(ffff800020d70ff0) 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
acpicpu_idle() at acpicpu_idle+0x2eb sys/dev/acpi/acpicpu.c:1206
sched_idle(ffff800020d70ff0) at sched_idle+0x417 sys/kern/kern_sched.c:178
end trace frame: 0x0, count: 10
ddb{1}> trace
x86_ipi_db(ffff800020d70ff0) 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
acpicpu_idle() at acpicpu_idle+0x2eb sys/dev/acpi/acpicpu.c:1206
sched_idle(ffff800020d70ff0) at sched_idle+0x417 sys/kern/kern_sched.c:178
end trace frame: 0x0, count: -5
ddb{1}> 

Crashes (3):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-openbsd-multicore 2020/10/21 21:19 openbsd 0415c54721ce be6b1582 .config log report syz C
ci-openbsd-multicore 2020/10/21 21:06 openbsd 0415c54721ce be6b1582 .config log report
ci-openbsd-multicore 2020/10/21 21:02 openbsd 0415c54721ce be6b1582 .config log report
* Struck through repros no longer work on HEAD.