2019-02-12 00:32:08

by Kyungtae Kim

[permalink] [raw]
Subject: UBSAN: Undefined behaviour in fs/jfs/jfs_dmap.c

I'm reporting a bug in linux-4.19.19: "UBSAN: Undefined behaviour in
fs/jfs/jfs_dmap.c"
(don't have repro)

A memory access violation (invalid array index) arose in dmtree
function dbAdjTree().
For now, however, it's hard to say for sure this caused by user-supplied input.

=========================================
UBSAN: Undefined behaviour in fs/jfs/jfs_dmap.c:2915:15
index 342 is out of range for type 's8 [341]'
CPU: 0 PID: 3703 Comm: syz-executor6 Not tainted 4.19.19 #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0xd2/0x148 lib/dump_stack.c:113
ubsan_epilogue+0x12/0x94 lib/ubsan.c:159
__ubsan_handle_out_of_bounds+0x174/0x1b8 lib/ubsan.c:386
dbAdjTree+0x5e5/0x6b0 fs/jfs/jfs_dmap.c:2915
dbSplit+0x170/0x230 fs/jfs/jfs_dmap.c:2694
dbAdjCtl+0x357/0x9c0 fs/jfs/jfs_dmap.c:2569
dbAllocDmap+0xd0/0x120 fs/jfs/jfs_dmap.c:2082
dbAllocDmapLev+0x154/0x370 fs/jfs/jfs_dmap.c:2026
dbAllocCtl+0x12b/0x7b0 fs/jfs/jfs_dmap.c:1866
dbAllocAG+0x99e/0x1180 fs/jfs/jfs_dmap.c:1407
dbAlloc+0x47c/0xb00 fs/jfs/jfs_dmap.c:863
extBalloc fs/jfs/jfs_extent.c:531 [inline]
extAlloc+0x4b4/0x1000 fs/jfs/jfs_extent.c:138
jfs_get_block+0x5d0/0xbf0 fs/jfs/inode.c:257
nobh_write_begin+0x35b/0xc90 fs/buffer.c:2607
jfs_write_begin+0x42/0x100 fs/jfs/inode.c:322
generic_perform_write+0x224/0x4f0 mm/filemap.c:3139
__generic_file_write_iter+0x395/0x6c0 mm/filemap.c:3264
generic_file_write_iter+0x31e/0x6e0 mm/filemap.c:3292
call_write_iter include/linux/fs.h:1811 [inline]
new_sync_write fs/read_write.c:474 [inline]
__vfs_write+0x538/0x6e0 fs/read_write.c:487
vfs_write+0x1b3/0x520 fs/read_write.c:549
ksys_write+0xde/0x1c0 fs/read_write.c:598
__do_sys_write fs/read_write.c:610 [inline]
__se_sys_write fs/read_write.c:607 [inline]
__x64_sys_write+0x7e/0xc0 fs/read_write.c:607
do_syscall_64+0xc4/0x510 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x4497b9
Code: e8 8c 9f 02 00 48 83 c4 18 c3 0f 1f 80 00 00 00 00 48 89 f8 48
89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d
01 f0 ff ff 0f 83 9b 6b fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fde5da97c68 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007fde5da986cc RCX: 00000000004497b9
RDX: 000000000000009e RSI: 0000000020000100 RDI: 0000000000000016
RBP: 000000000071bf58 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff
R13: 000000000000bd90 R14: 00000000006f4e30 R15: 00007fde5da98700
=========================================

Thanks,
Kyungtae