syzbot


protection_fault: lf_clearlock

Status: fixed on 2022/04/28 05:27
Reported-by: syzbot+46d03139d7ed5e81ed2f@syzkaller.appspotmail.com
Fix commit: c30ab30fe47b Remove the lock if an identical overlapping one is already present. Preventing a use after free discovered by syzkaller.
First crash: 229d, last: 229d

Sample crash report:
kernel: protection fault trap, code=0
Stopped at      lf_clearlock+0x282:     movq    %r12,0(%rbx)
ddb{0}> 
ddb{0}> set $lines = 0
ddb{0}> set $maxwidth = 0
ddb{0}> show panic
the kernel did not panic
ddb{0}> trace
lf_clearlock(fffffd806f01cd68) at lf_clearlock+0x282 sys/kern/vfs_lockf.c:547
lf_advlock(ffff800000bd2ca0,0,fffffd807041bda0,2,ffff8000211ceb00,40) at lf_advlock+0x3bb sys/kern/vfs_lockf.c:304
VOP_ADVLOCK(fffffd806e1c5328,fffffd807041bda0,2,ffff8000211ceb00,40) at VOP_ADVLOCK+0x71 sys/kern/vfs_vops.c:628
closef(fffffd806e601c88,ffff800021142d28) at closef+0xe5
fdfree(ffff800021142d28) at fdfree+0xf4 sys/kern/kern_descrip.c:1195
exit1(ffff800021142d28,0,0,1) at exit1+0x37d sys/kern/kern_exit.c:202
sys_exit(ffff800021142d28,ffff8000211cec70,ffff8000211cecd0) at sys_exit+0x16 sys/kern/kern_exit.c:95
syscall(ffff8000211ced40) at syscall+0x489 mi_syscall sys/sys/syscall_mi.h:102 [inline]
syscall(ffff8000211ced40) at syscall+0x489 sys/arch/amd64/amd64/trap.c:585
Xsyscall() at Xsyscall+0x128
end of kernel
end trace frame: 0x7f7ffffd8070, count: -9
ddb{0}> show registers
rdi                              0x1
rsi               0xffffffff829554f0    __sancov_gen_cov_switch_values.14
rbp               0xffff8000211ce9b0
rbx               0xdeadbeefdeadbf1f
rdx                              0x1
rcx               0xfffffd806f01cd68
rax                                0
r8                0xffff8000211ceb00
r9                              0x40
r10               0xaf42b3034de4b975
r11               0xca1cda8668edf6ef
r12               0xdeadbeefdeadbeef
r13                              0x1
r14               0xfffffd806f01cd68
r15               0xfffffd806f01cd68
rip               0xffffffff819fbc32    lf_clearlock+0x282
cs                               0x8
rflags                       0x10282    __ALIGN_SIZE+0xf282
rsp               0xffff8000211ce960
ss                              0x10
lf_clearlock+0x282:     movq    %r12,0(%rbx)
ddb{0}> show proc
PROC (syz-executor3906617542) pid=516185 stat=onproc
    flags process=a<EXEC,EXITING> proc=2000<WEXIT>
    pri=56, usrpri=56, nice=20
    forw=0xffffffffffffffff, list=0xffff800021142008,0xffffffff82a0a880
    process=0xffff8000211a29a0 user=0xffff8000211c9000, vmspace=0xfffffd806ef3ee68
    estcpu=6, cpticks=1, pctcpu=0.0
    user=0, sys=1, intr=0
ddb{0}> ps
   PID     TID   PPID    UID  S       FLAGS  WAIT          COMMAND
 30547  126981   2461      0  3    0x10008a  sigsusp       ksh
  2461  513730  32481      0  7        0x12                sshd
  5676  520254      1      0  3    0x100083  ttyin         getty
 32481  327116      1      0  3        0x88  kqread        sshd
 17276  423003  51175     74  3   0x1100092  bpf           pflogd
 51175  292644      1      0  3        0x80  netio         pflogd
 40629  243064  25676     73  3   0x1100090  kqread        syslogd
 25676  220969      1      0  3    0x100082  netio         syslogd
 18799  364498      1      0  3    0x100080  kqread        resolvd
 65692  382095  25069     77  3    0x100092  kqread        dhcpleased
 41803  427608  25069     77  3    0x100092  kqread        dhcpleased
 25069  199238      1      0  3        0x80  kqread        dhcpleased
 53280  352960      0      0  3     0x14200  bored         smr
  3431  187907      0      0  2     0x14200                zerothread
 47227  121494      0      0  3     0x14200  aiodoned      aiodoned
 44740  162949      0      0  3     0x14200  syncer        update
 15755  170898      0      0  3     0x14200  cleaner       cleaner
 75748   15521      0      0  3     0x14200  reaper        reaper
 13779  267841      0      0  3     0x14200  pgdaemon      pagedaemon
 53836   64381      0      0  3     0x14200  bored         viomb
 37424  124061      0      0  3  0x40014200  acpi0         acpi0
 29671  126275      0      0  3  0x40014200                idle1
 67863  292279      0      0  3     0x14200  bored         softnet
 70357  358064      0      0  3     0x14200  bored         systqmp
 31594  504294      0      0  3     0x14200  bored         systq
 38375  145131      0      0  3  0x40014200  bored         softclock
 39958  228620      0      0  3  0x40014200                idle0
     1  360850      0      0  3        0x82  wait          init
     0       0     -1      0  3     0x10200  scheduler     swapper
ddb{0}> show all locks
ddb{0}> show malloc
           Type InUse  MemUse  HighUse   Limit  Requests Type Lim
         devbuf 10150   6455K    6455K  78643K     11240        0
            pcb    13      8K       8K  78643K        13        0
         rtable    62      2K       2K  78643K       112        0
         ifaddr    29      8K       8K  78643K        32        0
       counters    40     33K      33K  78643K        40        0
       ioctlops     0      0K       4K  78643K      1479        0
          mount     1      1K       1K  78643K         1        0
            log     0      0K       0K  78643K         5        0
         vnodes  1167     73K      73K  78643K      1180        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     12548        0
      file desc     2      2K       3K  78643K         4        0
           proc    67     87K      87K  78643K       282        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    31    148K     148K  78643K        31        0
           exec     0      0K       2K  78643K       432        0
            tdb     3      0K       0K  78643K         3        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    58      3K       5K  78643K      1531        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   4705K    4769K  78643K      2507        0
         kqueue    11     16K      18K  78643K        24        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
plcache    128       22    0        0     1     0     1     1     0     8    0
rtpcb      120       17    0       14     1     0     1     1     0     8    0
rtentry    112       23    0        1     1     0     1     1     0     8    0
unpcb      136       35    0       20     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
arp        120        2    0        0     1     0     1     1     0     8    0
inpcb      312       32    0       26     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        8    0        0     1     0     1     1     0     8    0
pfstkey    112        8    0        0     1     0     1     1     0     8    0
pfstate    320        8    0        0     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     1425    0       39    87     0    87    87     0     8    0
ffsino     272     1425    0       39    93     0    93    93     0     8    0
nchpl      144     1614    0       49    58     0    58    58     0     8    0
uvmvnodes   80     1435    0        0    30     0    30    30     0     8    0
vnodes     224     1435    0        0    85     0    85    85     0     8    0
namei      1024    4476    0     4476     1     0     1     1     0     8    1
percpumem   16       32    0        0     1     0     1     1     0     8    0
scxspl     216     3868    0     3868     2     1     1     2     0     8    1
plimitpl   152       16    0        9     1     0     1     1     0     8    0
sigapl     424      320    0      291     4     0     4     4     0     8    0
knotepl    120       49    0        0     2     0     2     2     0     8    0
kqueuepl   216       20    0       13     1     0     1     1     0     8    0
pipepl     336       86    0       83     1     0     1     1     0     8    0
fdescpl    496      306    0      291     3     0     3     3     0     8    0
filepl     152     1185    0     1125     3     0     3     3     0     8    0
lockfpl    104       11    0        7     1     0     1     1     0     8    0
lockfspl    48        5    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       72    0       60     1     0     1     1     0     8    0
zombiepl   144      292    0      291     1     0     1     1     0     8    0
processpl  1064     320    0      291     3     0     3     3     0     8    0
procpl     672      320    0      291     3     0     3     3     0     8    0
sockpl     480       84    0       60     4     0     4     4     0     8    0
mcl8k      8192       3    0        0     1     0     1     1     0     8    0
mcl4k      4096       3    0        0     1     0     1     1     0     8    0
mcl2k      2048      62    0        0     8     0     8     8     0     8    0
mtagpl      96        3    0        0     1     0     1     1     0     8    0
mbufpl     256      109    0        0     7     0     7     7     0     8    0
bufpl      288     2011    0       92   138     0   138   138     0     8    0
anonpl      24    38423    0    36428    16     2    14    15     0   186    1
amapchunkpl 152    2820    0     2723     6     1     5     6     0   158    0
amappl16   200       97    0       92     1     0     1     1     0     8    0
amappl14   184        1    0        1     1     1     0     1     0     8    0
amappl13   176       34    0       33     2     1     1     1     0     8    0
amappl12   168        5    0        4     1     0     1     1     0     8    0
amappl11   160       66    0       49     1     0     1     1     0     8    0
amappl10   152        3    0        1     1     0     1     1     0     8    0
amappl9    144      487    0      485     1     0     1     1     0     8    0
amappl8    136      364    0      363     2     1     1     1     0     8    0
amappl7    128       53    0       49     1     0     1     1     0     8    0
amappl6    120      104    0       94     1     0     1     1     0     8    0
amappl5    112       91    0       78     1     0     1     1     0     8    0
amappl4    104      628    0      608     1     0     1     1     0     8    0
amappl3     96      412    0      389     1     0     1     1     0     8    0
amappl2     88      454    0      416     2     1     1     2     0     8    0
amappl1     80     9473    0     9066    10     0    10    10     0     8    0
amappl      88     1250    0     1210     2     0     2     2     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      72        2    0        0     1     0     1     1     0     8    0
uaddrrnd    24      306    0      291     1     0     1     1     0     8    0
uaddrbest   32        2    0        0     1     0     1     1     0     8    0
uaddr       24      306    0      291     1     0     1     1     0     8    0
vmmpekpl   168     6235    0     6219     1     0     1     1     0     8    0
vmmpepl    168    27022    0    26164    47     5    42    47     0   357    0
vmsppl     368      305    0      291     2     0     2     2     0     8    0
rwobjpl     56     9716    0     7710    31     1    30    30     0     8    1
pdppl      4096     619    0      582    48    11    37    45     0     8    0
pvpl        32   130742    0   126782    40     4    36    40     0   265    1
pmappl     248      305    0      291     2     0     2     2     0     8    0
extentpl    40       58    0       38     1     0     1     1     0     8    0
phpool     112      404    0       14    12     0    12    12     0     8    0
ddb{0}> machine ddbcpu 0
Invalid cpu 0
ddb{0}> trace
lf_clearlock(fffffd806f01cd68) at lf_clearlock+0x282 sys/kern/vfs_lockf.c:547
lf_advlock(ffff800000bd2ca0,0,fffffd807041bda0,2,ffff8000211ceb00,40) at lf_advlock+0x3bb sys/kern/vfs_lockf.c:304
VOP_ADVLOCK(fffffd806e1c5328,fffffd807041bda0,2,ffff8000211ceb00,40) at VOP_ADVLOCK+0x71 sys/kern/vfs_vops.c:628
closef(fffffd806e601c88,ffff800021142d28) at closef+0xe5
fdfree(ffff800021142d28) at fdfree+0xf4 sys/kern/kern_descrip.c:1195
exit1(ffff800021142d28,0,0,1) at exit1+0x37d sys/kern/kern_exit.c:202
sys_exit(ffff800021142d28,ffff8000211cec70,ffff8000211cecd0) at sys_exit+0x16 sys/kern/kern_exit.c:95
syscall(ffff8000211ced40) at syscall+0x489 mi_syscall sys/sys/syscall_mi.h:102 [inline]
syscall(ffff8000211ced40) at syscall+0x489 sys/arch/amd64/amd64/trap.c:585
Xsyscall() at Xsyscall+0x128
end of kernel
end trace frame: 0x7f7ffffd8070, count: -9
ddb{0}> machine ddbcpu 1
Stopped at      x86_ipi_db+0x1a:        addq    $0x8,%rsp
ddb{1}> trace
x86_ipi_db(ffff800020ce8ff0) at x86_ipi_db+0x1a sys/arch/amd64/amd64/db_interface.c:393
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(ffffffff829cae18) at __mp_lock+0x122 __mp_lock_spin sys/kern/kern_lock.c:116 [inline]
__mp_lock(ffffffff829cae18) at __mp_lock+0x122 sys/kern/kern_lock.c:147
userret(ffff800021143a48) at userret+0x18e sys/kern/kern_sig.c:1977
syscall(ffff8000211c2300) at syscall+0x57e mi_syscall_return sys/sys/syscall_mi.h:129 [inline]
syscall(ffff8000211c2300) at syscall+0x57e sys/arch/amd64/amd64/trap.c:607
Xsyscall() at Xsyscall+0x128
end of kernel
end trace frame: 0x7f7ffffc0620, count: -7
ddb{1}> 

Crashes (1):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-openbsd-multicore 2022/04/12 18:20 openbsd 7499e163a17c faabdb86 .config log report syz C protection_fault: lf_clearlock
* Struck through repros no longer work on HEAD.