KASAN: use-after-free Read in search_by_entry_key

23 views
Skip to first unread message

syzbot

unread,
Oct 8, 2020, 10:59:19 AM10/8/20
to ak...@linux-foundation.org, colin...@canonical.com, ja...@suse.cz, je...@suse.com, linux-...@vger.kernel.org, reiserf...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: c85fb28b Merge tag 'arm64-fixes' of git://git.kernel.org/p..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=136fa1fb900000
kernel config: https://syzkaller.appspot.com/x/.config?x=de7f697da23057c7
dashboard link: https://syzkaller.appspot.com/bug?extid=83b6f7cf9922cae5c4d7
compiler: clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=17ef5d4f900000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=11396677900000

Bisection is inconclusive: the issue happens on the oldest tested release.

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=13e47620500000
final oops: https://syzkaller.appspot.com/x/report.txt?x=10147620500000
console output: https://syzkaller.appspot.com/x/log.txt?x=17e47620500000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+83b6f7...@syzkaller.appspotmail.com

REISERFS (device loop0): journal params: device loop0, size 15748, journal first block 18, max trans len 1024, max batch 900, max commit age 30, max trans age 30
REISERFS (device loop0): checking transaction log (loop0)
REISERFS (device loop0): Using r5 hash to sort names
REISERFS (device loop0): using 3.5.x disk format
==================================================================
BUG: KASAN: use-after-free in bin_search_in_dir_item fs/reiserfs/namei.c:40 [inline]
BUG: KASAN: use-after-free in search_by_entry_key+0x450/0xad0 fs/reiserfs/namei.c:164
Read of size 4 at addr ffff88807cd0b7bd by task syz-executor710/6847

CPU: 1 PID: 6847 Comm: syz-executor710 Not tainted 5.9.0-rc8-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x1d6/0x29e lib/dump_stack.c:118
print_address_description+0x66/0x620 mm/kasan/report.c:383
__kasan_report mm/kasan/report.c:513 [inline]
kasan_report+0x132/0x1d0 mm/kasan/report.c:530
bin_search_in_dir_item fs/reiserfs/namei.c:40 [inline]
search_by_entry_key+0x450/0xad0 fs/reiserfs/namei.c:164
reiserfs_find_entry+0x246/0x1260 fs/reiserfs/namei.c:321
reiserfs_lookup+0x156/0x3a0 fs/reiserfs/namei.c:367
__lookup_slow+0x240/0x370 fs/namei.c:1544
lookup_one_len+0x10e/0x200 fs/namei.c:2562
reiserfs_lookup_privroot+0x85/0x1e0 fs/reiserfs/xattr.c:972
reiserfs_fill_super+0x2b51/0x3240 fs/reiserfs/super.c:2176
mount_bdev+0x24f/0x360 fs/super.c:1417
legacy_get_tree+0xea/0x180 fs/fs_context.c:592
vfs_get_tree+0x88/0x270 fs/super.c:1547
do_new_mount fs/namespace.c:2875 [inline]
path_mount+0x179d/0x29e0 fs/namespace.c:3192
do_mount fs/namespace.c:3205 [inline]
__do_sys_mount fs/namespace.c:3413 [inline]
__se_sys_mount+0x126/0x180 fs/namespace.c:3390
do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x447d9a
Code: b8 08 00 00 00 0f 05 48 3d 01 f0 ff ff 0f 83 7d a3 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 0f 83 5a a3 fb ff c3 66 0f 1f 84 00 00 00 00 00
RSP: 002b:00007ffc5d05d468 EFLAGS: 00000297 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007ffc5d05d4c0 RCX: 0000000000447d9a
RDX: 0000000020000000 RSI: 0000000020000100 RDI: 00007ffc5d05d480
RBP: 00007ffc5d05d480 R08: 00007ffc5d05d4c0 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000297 R12: 0000000000000006
R13: 0000000000000004 R14: 0000000000000003 R15: 0000000000000003

The buggy address belongs to the page:
page:0000000023b676e0 refcount:0 mapcount:0 mapping:0000000000000000 index:0x1 pfn:0x7cd0b
flags: 0xfffe0000000000()
raw: 00fffe0000000000 ffffea0001f34308 ffffea0001f34288 0000000000000000
raw: 0000000000000001 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff88807cd0b680: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff88807cd0b700: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff88807cd0b780: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
^
ffff88807cd0b800: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff88807cd0b880: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
For information about bisection process see: https://goo.gl/tpsmEJ#bisection
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches

syzbot

unread,
Oct 11, 2020, 7:45:06 PM10/11/20
to rkov...@gmail.com, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KASAN: out-of-bounds Read in leaf_paste_entries

REISERFS (device loop5): Using tea hash to sort names
REISERFS (device loop5): using 3.5.x disk format
==================================================================
BUG: KASAN: out-of-bounds in memmove include/linux/string.h:421 [inline]
BUG: KASAN: out-of-bounds in leaf_paste_entries+0x453/0x910 fs/reiserfs/lbalance.c:1377
Read of size 18446744073709547488 at addr ffff888054500fbf by task syz-executor.5/8365

CPU: 1 PID: 8365 Comm: syz-executor.5 Not tainted 5.9.0-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x198/0x1fd lib/dump_stack.c:118
print_address_description.constprop.0.cold+0xae/0x497 mm/kasan/report.c:383
__kasan_report mm/kasan/report.c:513 [inline]
kasan_report.cold+0x1f/0x37 mm/kasan/report.c:530
check_memory_region_inline mm/kasan/generic.c:186 [inline]
check_memory_region+0x13d/0x180 mm/kasan/generic.c:192
memmove+0x20/0x60 mm/kasan/common.c:94
memmove include/linux/string.h:421 [inline]
leaf_paste_entries+0x453/0x910 fs/reiserfs/lbalance.c:1377
balance_leaf_finish_node_paste_dirent fs/reiserfs/do_balan.c:1295 [inline]
balance_leaf_finish_node_paste fs/reiserfs/do_balan.c:1321 [inline]
balance_leaf_finish_node fs/reiserfs/do_balan.c:1364 [inline]
balance_leaf+0x915f/0xd320 fs/reiserfs/do_balan.c:1452
do_balance+0x311/0x800 fs/reiserfs/do_balan.c:1888
reiserfs_paste_into_item+0x762/0x8e0 fs/reiserfs/stree.c:2132
reiserfs_add_entry+0x8cb/0xcf0 fs/reiserfs/namei.c:566
reiserfs_mkdir+0x66e/0x980 fs/reiserfs/namei.c:858
create_privroot fs/reiserfs/xattr.c:882 [inline]
reiserfs_xattr_init+0x4de/0xb52 fs/reiserfs/xattr.c:1004
reiserfs_fill_super+0x215d/0x2df3 fs/reiserfs/super.c:2177
mount_bdev+0x32e/0x3f0 fs/super.c:1417
legacy_get_tree+0x105/0x220 fs/fs_context.c:592
vfs_get_tree+0x89/0x2f0 fs/super.c:1547
do_new_mount fs/namespace.c:2875 [inline]
path_mount+0x1387/0x20a0 fs/namespace.c:3192
do_mount fs/namespace.c:3205 [inline]
__do_sys_mount fs/namespace.c:3413 [inline]
__se_sys_mount fs/namespace.c:3390 [inline]
__x64_sys_mount+0x27f/0x300 fs/namespace.c:3390
do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x4608aa
Code: b8 a6 00 00 00 0f 05 48 3d 01 f0 ff ff 0f 83 ad 89 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 0f 83 8a 89 fb ff c3 66 0f 1f 84 00 00 00 00 00
RSP: 002b:00007fb93b411a88 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007fb93b411b20 RCX: 00000000004608aa
RDX: 0000000020000000 RSI: 0000000020000100 RDI: 00007fb93b411ae0
RBP: 00007fb93b411ae0 R08: 00007fb93b411b20 R09: 0000000020000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000020000000
R13: 0000000020000100 R14: 0000000020000200 R15: 0000000020000080

The buggy address belongs to the page:
page:00000000729425a0 refcount:2 mapcount:0 mapping:00000000be8e086b index:0x1fc8 pfn:0x54500
aops:def_blk_aops ino:0
flags: 0xfffe0000002032(referenced|lru|active|private)
raw: 00fffe0000002032 ffffea0001513c48 ffffea00015143c8 ffff8880892e3c80
raw: 0000000000001fc8 ffff8880585b43a0 00000002ffffffff ffff8880a9578000
page dumped because: kasan: bad access detected
page->mem_cgroup:ffff8880a9578000

Memory state around the buggy address:
ffff888054500e80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff888054500f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff888054500f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
^
ffff888054501000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff888054501080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================


Tested on:

commit: bbf5c979 Linux 5.9
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1360d784500000
kernel config: https://syzkaller.appspot.com/x/.config?x=3d8333c88fe898d7
dashboard link: https://syzkaller.appspot.com/bug?extid=83b6f7cf9922cae5c4d7
compiler: gcc (GCC) 10.1.0-syz 20200507

syzbot

unread,
Oct 20, 2020, 8:40:06 AM10/20/20
to anmol.k...@gmail.com, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
general protection fault in reiserfs_security_init

REISERFS (device loop1): Using tea hash to sort names
REISERFS (device loop1): using 3.5.x disk format
general protection fault, probably for non-canonical address 0xdffffc000000000d: 0000 [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x0000000000000068-0x000000000000006f]
CPU: 0 PID: 8382 Comm: syz-executor.1 Not tainted 5.9.0-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:d_really_is_negative include/linux/dcache.h:472 [inline]
RIP: 0010:reiserfs_xattr_jcreate_nblocks fs/reiserfs/xattr.h:78 [inline]
RIP: 0010:reiserfs_security_init+0x285/0x4d0 fs/reiserfs/xattr_security.c:70
Code: 48 c1 ea 03 80 3c 02 00 0f 85 2b 02 00 00 4d 8b ad a0 05 00 00 48 b8 00 00 00 00 00 fc ff df 49 8d 7d 68 48 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 23 02 00 00 49 83 7d 68 00 0f 84 62 01 00 00 48
RSP: 0018:ffffc900050b7980 EFLAGS: 00010202
RAX: dffffc0000000000 RBX: 0000000000000036 RCX: 000000000000006c
RDX: 000000000000000d RSI: ffffffff81ffeba3 RDI: 0000000000000068
RBP: ffff888065fc7820 R08: ffffc900050b7a10 R09: ffffc900050b7a18
R10: 0000000000000000 R11: 0000000000000000 R12: 00000000000005fa
R13: 0000000000000000 R14: ffff88801ace8000 R15: 0000000000000000
FS: 00007f76847db700(0000) GS:ffff8880ae400000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000055e576ee7098 CR3: 000000002f843000 CR4: 00000000001506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
reiserfs_mkdir+0x2c9/0x980 fs/reiserfs/namei.c:823
create_privroot fs/reiserfs/xattr.c:889 [inline]
reiserfs_xattr_init+0x4de/0xb60 fs/reiserfs/xattr.c:1011
reiserfs_fill_super+0x215d/0x2e00 fs/reiserfs/super.c:2177
mount_bdev+0x32e/0x3f0 fs/super.c:1419
legacy_get_tree+0x105/0x220 fs/fs_context.c:592
vfs_get_tree+0x89/0x2f0 fs/super.c:1549
do_new_mount fs/namespace.c:2875 [inline]
path_mount+0x1387/0x20a0 fs/namespace.c:3203
do_mount fs/namespace.c:3216 [inline]
__do_sys_mount fs/namespace.c:3424 [inline]
__se_sys_mount fs/namespace.c:3401 [inline]
__x64_sys_mount+0x27f/0x300 fs/namespace.c:3401
do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x4608aa
Code: b8 a6 00 00 00 0f 05 48 3d 01 f0 ff ff 0f 83 ad 89 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 0f 83 8a 89 fb ff c3 66 0f 1f 84 00 00 00 00 00
RSP: 002b:00007f76847daa88 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007f76847dab20 RCX: 00000000004608aa
RDX: 0000000020000000 RSI: 0000000020000100 RDI: 00007f76847daae0
RBP: 00007f76847daae0 R08: 00007f76847dab20 R09: 0000000020000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000020000000
R13: 0000000020000100 R14: 0000000020000200 R15: 0000000020000080
Modules linked in:

---[ end trace c2435f76d8049a45 ]---
RIP: 0010:d_really_is_negative include/linux/dcache.h:472 [inline]
RIP: 0010:reiserfs_xattr_jcreate_nblocks fs/reiserfs/xattr.h:78 [inline]
RIP: 0010:reiserfs_security_init+0x285/0x4d0 fs/reiserfs/xattr_security.c:70
Code: 48 c1 ea 03 80 3c 02 00 0f 85 2b 02 00 00 4d 8b ad a0 05 00 00 48 b8 00 00 00 00 00 fc ff df 49 8d 7d 68 48 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 23 02 00 00 49 83 7d 68 00 0f 84 62 01 00 00 48
RSP: 0018:ffffc900050b7980 EFLAGS: 00010202
RAX: dffffc0000000000 RBX: 0000000000000036 RCX: 000000000000006c
RDX: 000000000000000d RSI: ffffffff81ffeba3 RDI: 0000000000000068
RBP: ffff888065fc7820 R08: ffffc900050b7a10 R09: ffffc900050b7a18
R10: 0000000000000000 R11: 0000000000000000 R12: 00000000000005fa
R13: 0000000000000000 R14: ffff88801ace8000 R15: 0000000000000000
FS: 00007f76847db700(0000) GS:ffff8880ae400000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f013c224000 CR3: 000000002f843000 CR4: 00000000001506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400


Tested on:

commit: 270315b8 Merge tag 'riscv-for-linus-5.10-mw0' of git://git..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=15ddce6f900000
kernel config: https://syzkaller.appspot.com/x/.config?x=7661c11333e660d4
dashboard link: https://syzkaller.appspot.com/bug?extid=83b6f7cf9922cae5c4d7
compiler: gcc (GCC) 10.1.0-syz 20200507
patch: https://syzkaller.appspot.com/x/patch.diff?x=119f3837900000

Reply all
Reply to author
Forward
0 new messages