In the Linux kernel, the following vulnerability has been resolved:
ubifs: Fix read out-of-bounds in ubifswbufwrite_nolock()
Function ubifswbufwrite_nolock() may access buf out of bounds in following process:
ubifswbufwritenolock(): alignedlen = ALIGN(len, 8); // Assume len = 4089, alignedlen = 4096 if (alignedlen <= wbuf->avail) ... // Not satisfy if (wbuf->used) { ubifslebwrite() // Fill some data in avail wbuf len -= wbuf->avail; // len is still not 8-bytes aligned alignedlen -= wbuf->avail; } n = alignedlen >> c->maxwriteshift; if (n) { n <<= c->maxwriteshift; err = ubifslebwrite(c, wbuf->lnum, buf + written, wbuf->offs, n); // n > len, read out of bounds less than 8(n-len) bytes }
, which can be catched by KASAN: ========================================================= BUG: KASAN: slab-out-of-bounds in eccswhammingcalculate+0x1dc/0x7d0 Read of size 4 at addr ffff888105594ff8 by task kworker/u8:4/128 Workqueue: writeback wbworkfn (flush-ubifs00) Call Trace: kasanreport.cold+0x81/0x165 nandwritepageswecc+0xa9/0x160 ubifslebwrite+0xf2/0x1b0 [ubifs] ubifswbufwritenolock+0x421/0x12c0 [ubifs] writehead+0xdc/0x1c0 [ubifs] ubifsjnlwriteinode+0x627/0x960 [ubifs] wbworkfn+0x8af/0xb80
Function ubifswbufwritenolock() accepts that parameter 'len' is not 8 bytes aligned, the 'len' represents the true length of buf (which is allocated in 'ubifsjnlxxx', eg. ubifsjnlwriteinode), so ubifswbufwrite_nolock() must handle the length read from 'buf' carefully to write leb safely.
Fetch a reproducer in [Link].