syzbot


assert "((len + sizeof(long) - NUM) &~ (sizeof(long) - NUM)) <= M_SIZE(m)" failed in uipc_mbuf.c

Status: fixed on 2023/10/21 03:15
Reported-by: syzbot+0e6817f5877926f0e96a@syzkaller.appspotmail.com
Fix commit: 7b4d35e0a60b Avoid assertion failure when splitting mbuf cluster.
First crash: 401d, last: 400d

Sample crash report:
panic: kernel diagnostic assertion "((len + sizeof(long) - 1) &~ (sizeof(long) - 1)) <= M_SIZE(m)" failed: file "/syzkaller/managers/multicore/kernel/sys/kern/uipc_mbuf.c", line 1380
Stopped at      db_enter+0x1c:  addq    $0x8,%rsp
    TID    PID    UID     PRFLAGS     PFLAGS  CPU  COMMAND
* 45098  87475      0     0x14000      0x200    1  sosplice
  18192  81827      0     0x14000      0x200    0  softnet0
db_enter() at db_enter+0x1c sys/arch/amd64/amd64/db_interface.c:437
panic(ffffffff827a5490) at panic+0x17b sys/kern/subr_prf.c:198
__assert(ffffffff82827587,ffffffff82790c18,564,ffffffff827db35e) at __assert+0x29 sys/kern/subr_prf.c:157
m_align(fffffd806d1d8000,7b2) at m_align+0x1e8 sys/kern/uipc_mbuf.c:1380
m_split(fffffd807989c300,3836,2) at m_split+0xe0 sys/kern/uipc_mbuf.c:1110
somove(fffffd806d6119a8,2) at somove+0xd5c sys/kern/uipc_socket.c:1673
sotask(fffffd806d6119a8) at sotask+0x52 sys/kern/uipc_socket.c:1427
taskq_thread(ffff800000d06400) at taskq_thread+0xe5 sys/kern/kern_task.c:450
end trace frame: 0x0, count: 7
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
*cpu1: kernel diagnostic assertion "((len + sizeof(long) - 1) &~ (sizeof(long) - 1)) <= M_SIZE(m)" failed: file "/syzkaller/managers/multicore/kernel/sys/kern/uipc_mbuf.c", line 1380
ddb{1}> trace
db_enter() at db_enter+0x1c sys/arch/amd64/amd64/db_interface.c:437
panic(ffffffff827a5490) at panic+0x17b sys/kern/subr_prf.c:198
__assert(ffffffff82827587,ffffffff82790c18,564,ffffffff827db35e) at __assert+0x29 sys/kern/subr_prf.c:157
m_align(fffffd806d1d8000,7b2) at m_align+0x1e8 sys/kern/uipc_mbuf.c:1380
m_split(fffffd807989c300,3836,2) at m_split+0xe0 sys/kern/uipc_mbuf.c:1110
somove(fffffd806d6119a8,2) at somove+0xd5c sys/kern/uipc_socket.c:1673
sotask(fffffd806d6119a8) at sotask+0x52 sys/kern/uipc_socket.c:1427
taskq_thread(ffff800000d06400) at taskq_thread+0xe5 sys/kern/kern_task.c:450
end trace frame: 0x0, count: -8
ddb{1}> show registers
rdi                                0
rsi                              0x1
rbp               0xffff80002126bb90
rbx               0xffff800020d59ba7
rdx                            0x3fd
rcx                                0
rax                             0xb7
r8                 0x101010101010101
r9                0x8080808080808080
r10               0xd12e352ac0890667
r11               0xdb4b4ec687c38886
r12               0xffff800020d599a8
r13                                0
r14                                0
r15                              0x1
rip               0xffffffff815a6dac    db_enter+0x1c
cs                               0x8
rflags                         0x246
rsp               0xffff80002126bb80
ss                              0x10
db_enter+0x1c:  addq    $0x8,%rsp
ddb{1}> show proc
PROC (sosplice) tid=45098 pid=87475 tcnt=1 stat=onproc
    flags process=14000<NOZOMBIE,SYSTEM> proc=200<SYSTEM>
    runpri=50, usrpri=50, slppri=32, nice=20
    wchan=0x0, wmesg=, ps_single=0x0
    forw=0xffffffffffffffff, list=0xffff8000211b3a98,0xffff8000211f5818
    process=0xffff8000ffff4870 user=0xffff800021266000, vmspace=0xffffffff82d48650
    estcpu=0, cpticks=1, pctcpu=0.0, user=0, sys=1, intr=0
ddb{1}> ps
   PID     TID   PPID    UID  S       FLAGS  WAIT          COMMAND
*87475   45098      0      0  7     0x14200                sosplice
  7747  464220  51247      0  3        0x82  nanoslp       syz-executor1316767679
 51247  283625  64027      0  3    0x10008a  sigsusp       ksh
 64027  403153   6495      0  3        0x9a  kqread        sshd
 25222  308734      1      0  3    0x100083  ttyin         getty
  6495  308463      1      0  3        0x88  kqread        sshd
 22336   76096  39279     74  3   0x1100092  bpf           pflogd
 39279   25378      1      0  3        0x80  netio         pflogd
  9958  472291    459     73  3   0x1100090  kqread        syslogd
   459   24988      1      0  3    0x100082  netio         syslogd
 40069  441954      1      0  3    0x100080  kqread        resolvd
 42155   16644  61909     77  3    0x100092  kqread        dhcpleased
 68825  381871  61909     77  3    0x100092  kqread        dhcpleased
 61909  506799      1      0  3        0x80  kqread        dhcpleased
 64196  105201      0      0  3     0x14200  bored         smr
  3002  412535      0      0  3     0x14200  pgzero        zerothread
 12226  317329      0      0  3     0x14200  aiodoned      aiodoned
 48982  317648      0      0  3     0x14200  syncer        update
 97833   46308      0      0  3     0x14200  cleaner       cleaner
 15231   63463      0      0  3     0x14200  reaper        reaper
 35945   90938      0      0  3     0x14200  pgdaemon      pagedaemon
 12391  167146      0      0  3     0x14200  bored         viomb
 14495  349656      0      0  3  0x40014200  acpi0         acpi0
 89776  460134      0      0  3  0x40014200                idle1
 59882  132807      0      0  3     0x14200  bored         softnet3
 66491  393024      0      0  3     0x14200  bored         softnet2
 28115  319175      0      0  3     0x14200  bored         softnet1
 81827   18192      0      0  7     0x14200                softnet0
 37618  284232      0      0  3     0x14200  bored         systqmp
 74356  124672      0      0  3     0x14200  bored         systq
 63282  157575      0      0  3     0x14200  tmoslp        softclockmp
 29477  352117      0      0  3  0x40014200  tmoslp        softclock
 16567  328514      0      0  3  0x40014200                idle0
     1  382650      0      0  3        0x82  wait          init
     0       0     -1      0  3     0x10200  scheduler     swapper
ddb{1}> show all locks
CPU 0:
exclusive sched_lock &sched_lock r = 0 (0xffffffff82c913c8)
#0  witness_lock+0x447
#1  __mp_acquire_count+0x48 sys/kern/kern_lock.c:227
#2  mi_switch+0x486 sys/kern/sched_bsd.c:473
#3  sleep_finish+0x19b sys/kern/kern_synch.c:414
#4  msleep+0xea sys/kern/kern_synch.c:249
#5  taskq_next_work+0x6e sys/kern/kern_task.c:403
#6  taskq_thread+0x135 sys/kern/kern_task.c:443
#7  proc_trampoline+0x1c
Process 87475 (sosplice) thread 0xffff8000211f5ab0 (45098)
exclusive rwlock netlock r = 0 (0xffffffff82ba48a0)
#0  witness_lock+0x447
#1  rw_enter+0x3c8 sys/kern/kern_rwlock.c:309
#2  sotask+0x1e sys/kern/uipc_socket.c:1419
#3  taskq_thread+0xe5 sys/kern/kern_task.c:450
#4  proc_trampoline+0x1c
shared rwlock sosplice r = 0 (0xffff800000d06470)
#0  witness_lock+0x447
#1  taskq_thread+0xca sys/kern/kern_task.c:446
#2  proc_trampoline+0x1c
ddb{1}> show malloc
           Type InUse  MemUse  HighUse   Limit  Requests Type Lim
         devbuf 10163   6456K    6457K  78643K     11241        0
            pcb    13      8K       8K  78643K        13        0
         rtable    58      1K       2K  78643K       114        0
             pf    15      6K      10K  78643K        26        0
         ifaddr    13      9K       9K  78643K        13        0
        ifgroup    22      1K       1K  78643K        22        0
       counters    44     33K      33K  78643K        44        0
       ioctlops     0      0K       4K  78643K      1475        0
          mount     1      1K       1K  78643K         1        0
            log     0      0K       0K  78643K         4        0
         vnodes  1176     74K      74K  78643K      1192        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     1      0K       0K  78643K         1        0
           proc    67     91K      91K  78643K       302        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    25    122K     122K  78643K        25        0
           exec     0      0K       1K  78643K       269        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     8     62K      64K  78643K        10        0
       UVM amap   111     12K      12K  78643K      2506        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     1   5908K    5972K  78643K      3107        0
         kqueue    11     16K      18K  78643K        24        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
plcache    128       22    0        0     1     0     1     1     0     8    0
rtpcb      120       20    0       17     1     0     1     1     0     8    0
rtentry    112       23    0        1     1     0     1     1     0     8    0
unpcb      144       35    0       20     1     0     1     1     0     8    0
syncache   304        7    0        7     2     1     1     1     0     8    1
tcpqe       32      200    0      200     2     1     1     1     0     8    1
tcpcb      808       14    0        8     1     0     1     1     0     8    0
arp        120        2    0        0     1     0     1     1     0     8    0
inpcb      368       39    0       30     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        7     2     1     1     1     0     8    0
pfstkey    128        9    0        7     2     1     1     1     0     8    0
pfstate    376        9    0        7     2     1     1     1     0     8    0
pfrule     1344      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       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     1435    0       39    88     0    88    88     0     8    0
ffsino     272     1435    0       39    94     0    94    94     0     8    0
nchpl      144     1623    0       52    59     0    59    59     0     8    0
uvmvnodes   80     1449    0        0    30     0    30    30     0     8    0
vnodes     216     1449    0        0    81     0    81    81     0     8    0
namei      1024    4569    0     4569     2     1     1     1     0     8    1
percpumem   16       35    0        0     1     0     1     1     0     8    0
kstatmem   264        8    0        0     1     0     1     1     0     8    0
scxspl     216     5150    0     5150    10     9     1     8     1     8    1
plimitpl   152       18    0       10     1     0     1     1     0     8    0
sigapl     424      341    0      306     5     1     4     5     0     8    0
futexpl     64       17    0       17     1     0     1     1     0     8    1
knotepl    120       41    0        0     2     0     2     2     0     8    0
kqueuepl   216       20    0       13     1     0     1     1     0     8    0
pipepl     320       94    0       91     2     1     1     1     0     8    0
fdescpl    496      322    0      306     3     0     3     3     0     8    0
filepl     152     1282    0     1221     3     0     3     3     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       18    0        9     1     0     1     1     0     8    0
pgrppl      48       18    0        9     1     0     1     1     0     8    0
ucredpl    104       71    0       59     1     0     1     1     0     8    0
zombiepl   144      307    0      306     2     1     1     1     0     8    0
processpl  1072     341    0      306     3     0     3     3     0     8    0
procpl     680      345    0      310     5     1     4     4     0     8    0
sosppl     168        4    0        2     1     0     1     1     0     8    0
sockpl     488       94    0       67     5     1     4     4     0     8    0
mcl64k     65536      4    0        0     1     0     1     1     0     8    0
mcl8k      8192       6    0        0     1     0     1     1     0     8    0
mcl4k      4096       3    0        0     1     0     1     1     0     8    0
mcl2k      2048     298    0        0    33     4    29    33     0     8    0
mtagpl      96        3    0        0     1     0     1     1     0     8    0
mbufpl     256      328    0        0    18     1    17    18     0     8    0
bufpl      288     2536    0       86   175     0   175   175     0     8    0
anonpl      24   175991    0   173915    29    15    14    25     0   186    1
amapchunkpl 152    8592    0     8415     8     1     7     8     0   158    0
amappl16   200     5011    0     5009     6     5     1     5     0     8    0
amappl15   192        9    0        9     1     1     0     1     0     8    0
amappl14   184      111    0      100     1     0     1     1     0     8    0
amappl13   176       10    0       10     1     1     0     1     0     8    0
amappl12   168      874    0      857     2     1     1     2     0     8    0
amappl11   160       78    0       64     1     0     1     1     0     8    0
amappl10   152       28    0       28     2     1     1     1     0     8    1
amappl9    144      147    0      147     1     1     0     1     0     8    0
amappl8    136       32    0       30     1     0     1     1     0     8    0
amappl7    128       25    0       22     1     0     1     1     0     8    0
amappl6    120      184    0      169     1     0     1     1     0     8    0
amappl5    112      118    0      107     1     0     1     1     0     8    0
amappl4    104      468    0      434     1     0     1     1     0     8    0
amappl3     96     2438    0     2399     2     1     1     2     0     8    0
amappl2     88      499    0      451     2     0     2     2     0     8    0
amappl1     80     9508    0     9031    16     4    12    12     0     8    0
amappl      88     2202    0     2138     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      322    0      306     1     0     1     1     0     8    0
uaddrbest   32        2    0        0     1     0     1     1     0     8    0
uaddr       24      322    0      306     1     0     1     1     0     8    0
vmmpekpl   168     7311    0     7296     1     0     1     1     0     8    0
vmmpepl    168    35917    0    34829    59     8    51    52     0   357    3
vmsppl     464      321    0      306     3     0     3     3     0     8    0
rwobjpl     56    19237    0    17075    34     3    31    33     0     8    0
pdppl      4096     651    0      612    59    20    39    45     0     8    0
pvpl        32   279106    0   274203    64    21    43    57     0   265    3
pmappl     248      321    0      306     2     0     2     2     0     8    0
extentpl    40       56    0       38     1     0     1     1     0     8    0
phpool     112      492    0       29    14     0    14    14     0     8    0
ddb{1}> machine ddbcpu 0
Stopped at      x86_ipi_db+0x1e:        addq    $0x8,%rsp
x86_ipi_db(ffffffff82c07ff0) at x86_ipi_db+0x1e 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+0x27
__mp_lock(ffffffff82c58b00) at __mp_lock+0x122 __mp_lock_spin sys/kern/kern_lock.c:116 [inline]
__mp_lock(ffffffff82c58b00) at __mp_lock+0x122 sys/kern/kern_lock.c:147
softintr_dispatch(0) at softintr_dispatch+0x52 sys/arch/amd64/amd64/softintr.c:88
Xsoftclock() at Xsoftclock+0x27
__sanitizer_cov_trace_const_cmp4(ffff80000002d000,ffff80002118d9e0) at __sanitizer_cov_trace_const_cmp4+0x10 sys/dev/kcov.c:234
taskq_thread(ffff80000002d000) at taskq_thread+0x135 sys/kern/kern_task.c:443
end trace frame: 0x0, count: 7
ddb{0}> trace
x86_ipi_db(ffffffff82c07ff0) at x86_ipi_db+0x1e 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+0x27
__mp_lock(ffffffff82c58b00) at __mp_lock+0x122 __mp_lock_spin sys/kern/kern_lock.c:116 [inline]
__mp_lock(ffffffff82c58b00) at __mp_lock+0x122 sys/kern/kern_lock.c:147
softintr_dispatch(0) at softintr_dispatch+0x52 sys/arch/amd64/amd64/softintr.c:88
Xsoftclock() at Xsoftclock+0x27
__sanitizer_cov_trace_const_cmp4(ffff80000002d000,ffff80002118d9e0) at __sanitizer_cov_trace_const_cmp4+0x10 sys/dev/kcov.c:234
taskq_thread(ffff80000002d000) at taskq_thread+0x135 sys/kern/kern_task.c:443
end trace frame: 0x0, count: -8
ddb{0}> machine ddbcpu 1
Stopped at      db_enter+0x1c:  addq    $0x8,%rsp
db_enter() at db_enter+0x1c sys/arch/amd64/amd64/db_interface.c:437
panic(ffffffff827a5490) at panic+0x17b sys/kern/subr_prf.c:198
__assert(ffffffff82827587,ffffffff82790c18,564,ffffffff827db35e) at __assert+0x29 sys/kern/subr_prf.c:157
m_align(fffffd806d1d8000,7b2) at m_align+0x1e8 sys/kern/uipc_mbuf.c:1380
m_split(fffffd807989c300,3836,2) at m_split+0xe0 sys/kern/uipc_mbuf.c:1110
somove(fffffd806d6119a8,2) at somove+0xd5c sys/kern/uipc_socket.c:1673
sotask(fffffd806d6119a8) at sotask+0x52 sys/kern/uipc_socket.c:1427
taskq_thread(ffff800000d06400) at taskq_thread+0xe5 sys/kern/kern_task.c:450
end trace frame: 0x0, count: 7
ddb{1}> trace
db_enter() at db_enter+0x1c sys/arch/amd64/amd64/db_interface.c:437
panic(ffffffff827a5490) at panic+0x17b sys/kern/subr_prf.c:198
__assert(ffffffff82827587,ffffffff82790c18,564,ffffffff827db35e) at __assert+0x29 sys/kern/subr_prf.c:157
m_align(fffffd806d1d8000,7b2) at m_align+0x1e8 sys/kern/uipc_mbuf.c:1380
m_split(fffffd807989c300,3836,2) at m_split+0xe0 sys/kern/uipc_mbuf.c:1110
somove(fffffd806d6119a8,2) at somove+0xd5c sys/kern/uipc_socket.c:1673
sotask(fffffd806d6119a8) at sotask+0x52 sys/kern/uipc_socket.c:1427
taskq_thread(ffff800000d06400) at taskq_thread+0xe5 sys/kern/kern_task.c:450
end trace frame: 0x0, count: -8

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/10/18 01:47 openbsd 06914b19d74c 342b9c55 .config console log report syz C ci-openbsd-multicore assert "((len + sizeof(long) - NUM) &~ (sizeof(long) - NUM)) <= M_SIZE(m)" failed in uipc_mbuf.c
2023/10/17 23:37 openbsd 06914b19d74c 342b9c55 .config console log report ci-openbsd-multicore assert "((len + sizeof(long) - NUM) &~ (sizeof(long) - NUM)) <= M_SIZE(m)" failed in uipc_mbuf.c
* Struck through repros no longer work on HEAD.