KASAN: use-after-free Read in nilfs_segctor_sync

9 views
Skip to first unread message

syzbot

unread,
Nov 2, 2022, 10:31:56 AM11/2/22
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: a85772d7ba90 Linux 4.14.297
git tree: linux-4.14.y
console output: https://syzkaller.appspot.com/x/log.txt?x=12468ba1880000
kernel config: https://syzkaller.appspot.com/x/.config?x=c7c676c786714374
dashboard link: https://syzkaller.appspot.com/bug?extid=c267f64d1e972c68f8fa
compiler: gcc version 10.2.1 20210110 (Debian 10.2.1-6)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1756e37e880000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=15dca5ee880000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/39db606a8a5a/disk-a85772d7.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/bc47cfcb03c7/vmlinux-a85772d7.xz
kernel image: https://storage.googleapis.com/syzbot-assets/a5aa85f7ae07/bzImage-a85772d7.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/560b3054aa22/mount_0.gz

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

Remounting filesystem read-only
NILFS (loop3): segctord starting. Construction interval = 5 seconds, CP frequency < 30 seconds
NILFS (loop3): mounting fs with errors
==================================================================
BUG: KASAN: use-after-free in __lock_acquire+0x2c57/0x3f20 kernel/locking/lockdep.c:3369
Read of size 8 at addr ffff88809a05d3a8 by task syz-executor178/8003
NILFS (loop2): mounting fs with errors

NILFS (loop2): segctord starting. Construction interval = 5 seconds, CP frequency < 30 seconds
CPU: 1 PID: 8003 Comm: syz-executor178 Not tainted 4.14.297-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/11/2022
Call Trace:
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0x1b2/0x281 lib/dump_stack.c:58
print_address_description.cold+0x54/0x1d3 mm/kasan/report.c:252
kasan_report_error.cold+0x8a/0x191 mm/kasan/report.c:351
kasan_report mm/kasan/report.c:409 [inline]
__asan_report_load8_noabort+0x68/0x70 mm/kasan/report.c:430
__lock_acquire+0x2c57/0x3f20 kernel/locking/lockdep.c:3369
lock_acquire+0x170/0x3f0 kernel/locking/lockdep.c:3998
__raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
_raw_spin_lock_irqsave+0x8c/0xc0 kernel/locking/spinlock.c:160
finish_wait+0xb2/0x260 kernel/sched/wait.c:376
nilfs_segctor_sync+0x1e6/0x250 fs/nilfs2/segment.c:2210
nilfs_construct_segment+0xab/0x120 fs/nilfs2/segment.c:2265
nilfs_transaction_commit+0x7bb/0xae0 fs/nilfs2/segment.c:299
nilfs_evict_inode+0x2be/0x3a0 fs/nilfs2/inode.c:967
evict+0x2c8/0x700 fs/inode.c:554
iput_final fs/inode.c:1523 [inline]
iput+0x458/0x7e0 fs/inode.c:1550
dentry_unlink_inode+0x25c/0x310 fs/dcache.c:387
d_delete+0x1c5/0x280 fs/dcache.c:2417
vfs_rmdir.part.0+0x260/0x390 fs/namei.c:3922
vfs_rmdir fs/namei.c:3895 [inline]
do_rmdir+0x334/0x3c0 fs/namei.c:3970
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x5e/0xd3

Allocated by task 8003:
save_stack mm/kasan/kasan.c:447 [inline]
set_track mm/kasan/kasan.c:459 [inline]
kasan_kmalloc+0xeb/0x160 mm/kasan/kasan.c:551
kmem_cache_alloc_trace+0x131/0x3d0 mm/slab.c:3618
kmalloc include/linux/slab.h:488 [inline]
kzalloc include/linux/slab.h:661 [inline]
nilfs_segctor_new fs/nilfs2/segment.c:2673 [inline]
nilfs_attach_log_writer+0x127/0x970 fs/nilfs2/segment.c:2802
nilfs_fill_super fs/nilfs2/super.c:1088 [inline]
nilfs_mount+0x95b/0xd00 fs/nilfs2/super.c:1332
mount_fs+0x92/0x2a0 fs/super.c:1237
vfs_kern_mount.part.0+0x5b/0x470 fs/namespace.c:1046
vfs_kern_mount fs/namespace.c:1036 [inline]
do_new_mount fs/namespace.c:2572 [inline]
do_mount+0xe65/0x2a30 fs/namespace.c:2905
SYSC_mount fs/namespace.c:3121 [inline]
SyS_mount+0xa8/0x120 fs/namespace.c:3098
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x5e/0xd3

Freed by task 8032:
save_stack mm/kasan/kasan.c:447 [inline]
set_track mm/kasan/kasan.c:459 [inline]
kasan_slab_free+0xc3/0x1a0 mm/kasan/kasan.c:524
__cache_free mm/slab.c:3496 [inline]
kfree+0xc9/0x250 mm/slab.c:3815
nilfs_segctor_destroy fs/nilfs2/segment.c:2772 [inline]
nilfs_detach_log_writer+0x56f/0x980 fs/nilfs2/segment.c:2829
nilfs_attach_log_writer+0xcb/0x970 fs/nilfs2/segment.c:2799
nilfs_remount+0x326/0x470 fs/nilfs2/super.c:1186
do_remount_sb+0x150/0x530 fs/super.c:868
do_remount fs/namespace.c:2393 [inline]
do_mount+0x15f3/0x2a30 fs/namespace.c:2896
SYSC_mount fs/namespace.c:3121 [inline]
SyS_mount+0xa8/0x120 fs/namespace.c:3098
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x5e/0xd3

The buggy address belongs to the object at ffff88809a05d200
which belongs to the cache kmalloc-1024 of size 1024
The buggy address is located 424 bytes inside of
1024-byte region [ffff88809a05d200, ffff88809a05d600)
The buggy address belongs to the page:
page:ffffea0002681700 count:1 mapcount:0 mapping:ffff88809a05c000 index:0x0 compound_mapcount: 0
flags: 0xfff00000008100(slab|head)
raw: 00fff00000008100 ffff88809a05c000 0000000000000000 0000000100000007
raw: ffffea000277b520 ffffea000268f920 ffff88813fe74ac0 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff88809a05d280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88809a05d300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88809a05d380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88809a05d400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88809a05d480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


---
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.
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches
Reply all
Reply to author
Forward
0 new messages