syzbot


panic: malloc: allocation too large, type = NUM, size = ADDR

Status: fixed on 2021/12/21 15:21
Reported-by: syzbot+9f1b201cdbc97b19c7f5@syzkaller.appspotmail.com
Fix commit: 0b7f5aec6317 Let malloc return an error as opposed of panicking when sysctl kern.shminfo.shmseg is set to something ridiculously large.
First crash: 857d, last: 856d

Sample crash report:
panic: malloc: allocation too large, type = 29, size = 13002741572
Stopped at      db_enter+0x18:  addq    $0x8,%rsp
    TID    PID    UID     PRFLAGS     PFLAGS  CPU  COMMAND
*154224  21123      0         0x2          0    0  syz-executor1390
db_enter() at db_enter+0x18 sys/arch/amd64/amd64/db_interface.c:440
panic(ffffffff8247fb14) at panic+0x161 sys/kern/subr_prf.c:202
malloc(307061744,1d,1) at malloc+0xa34 sys/kern/kern_malloc.c:345
sys_shmat(ffff80002165ea90,ffff80002167d498,ffff80002167d4f0) at sys_shmat+0x7f sys/kern/sysv_shm.c:228
syscall(ffff80002167d560) at syscall+0x44e sys/arch/amd64/amd64/trap.c:585
Xsyscall() at Xsyscall+0x128
end of kernel
end trace frame: 0x7f7ffffdc1a0, 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> 
ddb> set $lines = 0
ddb> set $maxwidth = 0
ddb> show panic
*cpu0: malloc: allocation too large, type = 29, size = 13002741572
ddb> trace
db_enter() at db_enter+0x18 sys/arch/amd64/amd64/db_interface.c:440
panic(ffffffff8247fb14) at panic+0x161 sys/kern/subr_prf.c:202
malloc(307061744,1d,1) at malloc+0xa34 sys/kern/kern_malloc.c:345
sys_shmat(ffff80002165ea90,ffff80002167d498,ffff80002167d4f0) at sys_shmat+0x7f sys/kern/sysv_shm.c:228
syscall(ffff80002167d560) at syscall+0x44e sys/arch/amd64/amd64/trap.c:585
Xsyscall() at Xsyscall+0x128
end of kernel
end trace frame: 0x7f7ffffdc1a0, count: -6
ddb> show registers
rdi                                0
rsi                              0x1
rbp               0xffff80002167d280
rbx                                0
rdx                             0x8b
rcx                              0x2
rax                             0x43
r8                0xffffffff81c693b5    kprintf+0x145
r9                               0x1
r10               0xdacc8454756b98fe
r11               0xb373cb11a7f0bc76
r12                                0
r13                      0x307061744
r14                                0
r15                              0x1
rip               0xffffffff81a08b68    db_enter+0x18
cs                               0x8
rflags                         0x246
rsp               0xffff80002167d270
ss                              0x10
db_enter+0x18:  addq    $0x8,%rsp
ddb> show proc
PROC (syz-executor1390) pid=154224 stat=onproc
    flags process=2<EXEC> proc=0
    pri=52, usrpri=52, nice=20
    forw=0xffffffffffffffff, list=0xffff80002165e7f0,0xffffffff82915da8
    process=0xffff800021641b68 user=0xffff800021678000, vmspace=0xfffffd806eece778
    estcpu=2, cpticks=1, pctcpu=0.0
    user=0, sys=1, intr=0
ddb> ps
   PID     TID   PPID    UID  S       FLAGS  WAIT          COMMAND
*21123  154224  32364      0  7         0x2                syz-executor1390
 32364  241433  65339      0  3    0x10008a  sigsusp       ksh
 65339  174058  87910      0  3        0x9a  kqread        sshd
  6975  406453      1      0  3    0x100083  ttyin         getty
 87910   43344      1      0  3        0x88  kqread        sshd
  6370   74643  53757     73  3    0x100090  kqread        syslogd
 53757   80923      1      0  3    0x100082  netio         syslogd
 39004  332412      1      0  3    0x100080  kqread        resolvd
 86958    1611  13428     77  3    0x100092  kqread        dhcpleased
 50023  415540  13428     77  3    0x100092  kqread        dhcpleased
 13428  473042      1      0  3        0x80  kqread        dhcpleased
 85373  356448      0      0  3     0x14200  bored         smr
 48839  193071      0      0  2     0x14200                zerothread
 84623  384448      0      0  3     0x14200  aiodoned      aiodoned
 79520  386670      0      0  3     0x14200  syncer        update
 31195   88298      0      0  3     0x14200  cleaner       cleaner
 38920   53640      0      0  3     0x14200  reaper        reaper
 51946  510045      0      0  3     0x14200  pgdaemon      pagedaemon
 22308  187493      0      0  3     0x14200  bored         viomb
 41970   49771      0      0  3  0x40014200  acpi0         acpi0
 15430  469997      0      0  3     0x14200  bored         softnet
   505   15207      0      0  3     0x14200  bored         systqmp
 89333   10893      0      0  3     0x14200  bored         systq
 93889  387363      0      0  3  0x40014200  bored         softclock
 99008  271854      0      0  3  0x40014200                idle0
     1  126179      0      0  3        0x82  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 10091   6342K    6373K  78643K     11181        0
            pcb    13      8K       8K  78643K        13        0
         rtable    62      2K       2K  78643K       108        0
         ifaddr    24      7K       7K  78643K        24        0
       counters    19     16K      16K  78643K        19        0
       ioctlops     0      0K       2K  78643K        25        0
          mount     1      1K       1K  78643K         1        0
            log     0      0K       0K  78643K         5        0
         vnodes  1182     74K      74K  78643K      1187        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      0K       0K  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    55     54K      55K  78643K       222        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       312        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    73      3K       5K  78643K      1424        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     3      0K       0K  78643K         3        0
           temp    18   4173K    4237K  78643K      1723        0
         kqueue    11     16K      16K  78643K        20        0
      SYN cache     2     16K      16K  78643K         2        0
ddb> show all pools
Name      Size Requests Fail Releases Pgreq Pgrel Npage Hiwat Minpg Maxpg Idle
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      128       33    0       20     1     0     1     1     0     8    0
syncache   296        5    0        5     1     0     1     1     0     8    1
tcpcb      736        8    0        5     1     0     1     1     0     8    0
arp         88        2    0        0     1     0     1     1     0     8    0
inpcb      304       25    0       19     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     1404    0       22    87     0    87    87     0     8    0
ffsino     240     1404    0       22    82     0    82    82     0     8    0
nchpl      144     1578    0       38    58     0    58    58     0     8    0
uvmvnodes   72     1413    0        0    26     0    26    26     0     8    0
vnodes     224     1413    0        0    84     0    84    84     0     8    0
namei      1024    3858    0     3858     1     0     1     1     0     8    1
scxspl     216     3338    0     3338     2     1     1     2     0     8    1
plimitpl   152       15    0        9     1     0     1     1     0     8    0
sigapl     424      225    0      199     4     0     4     4     0     8    0
knotepl    112     2876    0     2848     1     0     1     1     0     8    0
kqueuepl   184       16    0        9     1     0     1     1     0     8    0
pipepl     304       62    0       59     1     0     1     1     0     8    0
fdescpl    432      212    0      199     3     0     3     3     0     8    0
filepl     120      947    0      894     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     96       64    0       54     1     0     1     1     0     8    0
zombiepl   144      199    0      199     1     0     1     1     0     8    1
processpl  1000     225    0      199     5     1     4     5     0     8    0
procpl     672      225    0      199     3     0     3     3     0     8    0
sockpl     448       75    0       53     3     0     3     3     0     8    0
mcl8k      8192       9    0        9     1     0     1     1     0     8    1
mcl4k      4096       5    0        5     1     0     1     1     0     8    1
mcl2k      2048    5648    0     5612     8     1     7     8     0     8    1
mtagpl      96        3    0        3     1     1     0     1     0     8    0
mbufpl     256     9660    0     9585     8     1     7     8     0     8    1
bufpl      280     1912    0       88   131     0   131   131     0     8    0
anonpl      24    29222    0    27197    16     3    13    16     0   188    0
amapchunkpl 152    2686    0     2560     7     1     6     7     0   158    0
amappl16   200       25    0       24     2     1     1     1     0     8    0
amappl15   192       58    0       54     1     0     1     1     0     8    0
amappl13   176       16    0       15     1     0     1     1     0     8    0
amappl12   168        7    0        7     1     1     0     1     0     8    0
amappl11   160       56    0       44     1     0     1     1     0     8    0
amappl10   152        8    0        8     1     1     0     1     0     8    0
amappl9    144      199    0      196     1     0     1     1     0     8    0
amappl8    136      246    0      244     1     0     1     1     0     8    0
amappl7    128       29    0       28     1     0     1     1     0     8    0
amappl6    120       33    0       28     1     0     1     1     0     8    0
amappl5    112      231    0      216     1     0     1     1     0     8    0
amappl4    104      469    0      450     1     0     1     1     0     8    0
amappl3     96      145    0      132     1     0     1     1     0     8    0
amappl2     88      269    0      237     1     0     1     1     0     8    0
amappl1     80     6814    0     6470     9     0     9     9     0     8    1
amappl      88     1207    0     1151     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      64        2    0        0     1     0     1     1     0     8    0
uaddrrnd    24      212    0      199     1     0     1     1     0     8    0
uaddrbest   32        2    0        0     1     0     1     1     0     8    0
uaddr       24      212    0      199     1     0     1     1     0     8    0
vmmpekpl   168     5644    0     5628     1     0     1     1     0     8    0
vmmpepl    168    20360    0    19603    39     1    38    38     0   357    1
vmsppl     272      211    0      199     2     0     2     2     0     8    0
rwobjpl     24     6326    0     5829     4     0     4     4     0     8    1
pdppl      4096     430    0      398    48    16    32    44     0     8    0
pvpl        32   100048    0    96307    34     0    34    34     0   265    1
pmappl     192      211    0      199     1     0     1     1     0     8    0
extentpl    40       58    0       40     1     0     1     1     0     8    0
phpool     112      255    0       20     7     0     7     7     0     8    0
ddb> machine ddbcpu 0
No such command
ddb> trace
db_enter() at db_enter+0x18 sys/arch/amd64/amd64/db_interface.c:440
panic(ffffffff8247fb14) at panic+0x161 sys/kern/subr_prf.c:202
malloc(307061744,1d,1) at malloc+0xa34 sys/kern/kern_malloc.c:345
sys_shmat(ffff80002165ea90,ffff80002167d498,ffff80002167d4f0) at sys_shmat+0x7f sys/kern/sysv_shm.c:228
syscall(ffff80002167d560) at syscall+0x44e sys/arch/amd64/amd64/trap.c:585
Xsyscall() at Xsyscall+0x128
end of kernel
end trace frame: 0x7f7ffffdc1a0, count: -6
ddb> machine ddbcpu 1
No such command
ddb> trace
db_enter() at db_enter+0x18 sys/arch/amd64/amd64/db_interface.c:440
panic(ffffffff8247fb14) at panic+0x161 sys/kern/subr_prf.c:202
malloc(307061744,1d,1) at malloc+0xa34 sys/kern/kern_malloc.c:345
sys_shmat(ffff80002165ea90,ffff80002167d498,ffff80002167d4f0) at sys_shmat+0x7f sys/kern/sysv_shm.c:228
syscall(ffff80002167d560) at syscall+0x44e sys/arch/amd64/amd64/trap.c:585
Xsyscall() at Xsyscall+0x128
end of kernel
end trace frame: 0x7f7ffffdc1a0, count: -6
ddb> 

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2021/12/14 17:06 openbsd 859a437b422b d018dd31 .config console log report syz C ci-openbsd-main panic: malloc: allocation too large, type = NUM, size = ADDR
2021/12/15 18:46 openbsd 03319b45cc1f 572bcb40 .config console log report ci-openbsd-multicore panic: malloc: allocation too large, type = NUM, size = ADDR
2021/12/14 16:28 openbsd 859a437b422b d018dd31 .config console log report ci-openbsd-main panic: malloc: allocation too large, type = NUM, size = ADDR
* Struck through repros no longer work on HEAD.