KASAN: use-after-free Read in dbAllocBits

Status: upstream: reported C repro on 2022/10/01 12:57
First crash: 361d, last: 339d
Fix bisection: failed (error log, bisect log)
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream UBSAN: array-index-out-of-bounds in dbAllocBits jfs C inconclusive error 229 2d12h 358d 0/25 upstream: reported C repro on 2022/10/04 09:00
linux-5.15 UBSAN: array-index-out-of-bounds in dbAllocBits origin:upstream C error 2 102d 131d 0/3 upstream: reported C repro on 2023/05/19 07:30
linux-6.1 UBSAN: array-index-out-of-bounds in dbAllocBits origin:upstream C 2 48d 131d 0/3 upstream: reported C repro on 2023/05/19 04:28

Sample crash report:
audit: type=1800 audit(1664628890.821:2): pid=8099 uid=0 auid=4294967295 ses=4294967295 subj==unconfined op=collect_data cause=failed(directio) comm="syz-executor568" name="bus" dev="loop0" ino=7 res=0
BUG: KASAN: use-after-free in dbAllocBits+0x4d3/0x520 fs/jfs/jfs_dmap.c:2295
Read of size 8 at addr ffff8880952411b8 by task syz-executor568/8099

CPU: 0 PID: 8099 Comm: syz-executor568 Not tainted 4.19.211-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/22/2022
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x1fc/0x2ef lib/dump_stack.c:118
 print_address_description.cold+0x54/0x219 mm/kasan/report.c:256
 kasan_report_error.cold+0x8a/0x1b9 mm/kasan/report.c:354
 kasan_report mm/kasan/report.c:412 [inline]
 __asan_report_load8_noabort+0x88/0x90 mm/kasan/report.c:433
 dbAllocBits+0x4d3/0x520 fs/jfs/jfs_dmap.c:2295
 dbAllocDmap+0x61/0x110 fs/jfs/jfs_dmap.c:2072
 dbAllocDmapLev+0x159/0x330 fs/jfs/jfs_dmap.c:2026
 dbAllocCtl+0x4a2/0x700 fs/jfs/jfs_dmap.c:1866
 dbAllocAny+0x10e/0x1a0 fs/jfs/jfs_dmap.c:1580
 dbAlloc+0x4e6/0xb00 fs/jfs/jfs_dmap.c:864
 extBalloc fs/jfs/jfs_extent.c:531 [inline]
 extAlloc+0x4cb/0xdb0 fs/jfs/jfs_extent.c:138
 jfs_get_block+0x1f5/0xae0 fs/jfs/inode.c:258
 get_more_blocks fs/direct-io.c:717 [inline]
 do_direct_IO fs/direct-io.c:1003 [inline]
 do_blockdev_direct_IO fs/direct-io.c:1333 [inline]
 __blockdev_direct_IO+0x424b/0xef40 fs/direct-io.c:1419
 blockdev_direct_IO include/linux/fs.h:3059 [inline]
 jfs_direct_IO+0x10a/0x370 fs/jfs/inode.c:344
 generic_file_direct_write+0x208/0x4a0 mm/filemap.c:3073
 __generic_file_write_iter+0x2d0/0x610 mm/filemap.c:3252
 generic_file_write_iter+0x3f8/0x730 mm/filemap.c:3323
 call_write_iter include/linux/fs.h:1821 [inline]
 do_iter_readv_writev+0x668/0x790 fs/read_write.c:681
 do_iter_write+0x182/0x5d0 fs/read_write.c:960
 vfs_writev+0x153/0x2e0 fs/read_write.c:1005
 do_pwritev+0x1b6/0x270 fs/read_write.c:1094
 __do_sys_pwritev2 fs/read_write.c:1153 [inline]
 __se_sys_pwritev2 fs/read_write.c:1144 [inline]
 __x64_sys_pwritev2+0xeb/0x150 fs/read_write.c:1144
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
RIP: 0033:0x7f0be5b56dd9
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 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 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffe6b2d2bb8 EFLAGS: 00000246 ORIG_RAX: 0000000000000148
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f0be5b56dd9
RDX: 0000000000000001 RSI: 0000000020000240 RDI: 0000000000000003
RBP: 00007f0be5b16640 R08: 0000000000000000 R09: 0000000000000003
R10: 0000000000001400 R11: 0000000000000246 R12: 0000000200000004
R13: 0000000000000000 R14: 00080000000000fc R15: 0000000000000000

The buggy address belongs to the page:
page:ffffea0002549040 count:0 mapcount:0 mapping:0000000000000000 index:0x0
flags: 0xfff00000000000()
raw: 00fff00000000000 0000000000000000 ffffffff02540101 0000000000000000
raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff888095241080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff888095241100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff888095241180: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff888095241200: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff888095241280: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2022/10/01 12:56 linux-4.19.y 3f8a27f9e27b feb56351 .config console log report syz C [disk image] [vmlinux] ci2-linux-4-19 KASAN: use-after-free Read in dbAllocBits
2022/10/22 23:51 linux-4.19.y 3f8a27f9e27b c0b80a55 .config console log report info [disk image] [vmlinux] ci2-linux-4-19 KASAN: slab-out-of-bounds Read in dbAllocBits
* Struck through repros no longer work on HEAD.