KASAN: use-after-free Write in ext4_put_super

9 views
Skip to first unread message

syzbot

unread,
Sep 25, 2022, 9:27:39 AM9/25/22
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 3f8a27f9e27b Linux 4.19.211
git tree: linux-4.19.y
console output: https://syzkaller.appspot.com/x/log.txt?x=13056eff080000
kernel config: https://syzkaller.appspot.com/x/.config?x=9b9277b418617afe
dashboard link: https://syzkaller.appspot.com/bug?extid=19f06d5730fe262a3a33
compiler: gcc version 10.2.1 20210110 (Debian 10.2.1-6)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14b1d938880000

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

EXT4-fs (loop5): re-mounted. Opts: (null)
EXT4-fs (loop3): re-mounted. Opts: (null)
EXT4-fs (loop1): re-mounted. Opts: (null)
EXT4-fs (loop4): re-mounted. Opts: (null)
==================================================================
BUG: KASAN: use-after-free in atomic_inc include/asm-generic/atomic-instrumented.h:109 [inline]
BUG: KASAN: use-after-free in kthread_stop+0x72/0x6b0 kernel/kthread.c:583
Write of size 4 at addr ffff8880aecb61a0 by task syz-executor.2/8146
EXT4-fs (loop0): re-mounted. Opts: (null)

CPU: 1 PID: 8146 Comm: syz-executor.2 Not tainted 4.19.211-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/26/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+0x8f/0xa0 mm/kasan/report.c:412
atomic_inc include/asm-generic/atomic-instrumented.h:109 [inline]
kthread_stop+0x72/0x6b0 kernel/kthread.c:583
ext4_put_super+0x93c/0x1010 fs/ext4/super.c:1054
generic_shutdown_super+0x144/0x370 fs/super.c:456
kill_block_super+0x97/0xf0 fs/super.c:1185
deactivate_locked_super+0x94/0x160 fs/super.c:329
deactivate_super+0x174/0x1a0 fs/super.c:360
cleanup_mnt+0x1a8/0x290 fs/namespace.c:1098
task_work_run+0x148/0x1c0 kernel/task_work.c:113
tracehook_notify_resume include/linux/tracehook.h:193 [inline]
exit_to_usermode_loop+0x251/0x2a0 arch/x86/entry/common.c:167
prepare_exit_to_usermode arch/x86/entry/common.c:198 [inline]
syscall_return_slowpath arch/x86/entry/common.c:271 [inline]
do_syscall_64+0x538/0x620 arch/x86/entry/common.c:296
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7fabe8050ad7
Code: ff ff ff f7 d8 64 89 01 48 83 c8 ff c3 66 0f 1f 44 00 00 31 f6 e9 09 00 00 00 66 0f 1f 84 00 00 00 00 00 b8 a6 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffdffde5718 EFLAGS: 00000246 ORIG_RAX: 00000000000000a6
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 00007fabe8050ad7
RDX: 00007ffdffde57eb RSI: 000000000000000a RDI: 00007ffdffde57e0
RBP: 00007ffdffde57e0 R08: 00000000ffffffff R09: 00007ffdffde55b0
R10: 00005555558ba903 R11: 0000000000000246 R12: 00007fabe80a95d6
R13: 00007ffdffde68a0 R14: 00005555558ba810 R15: 00007ffdffde68e0

Allocated by task 2:
kmem_cache_alloc_node+0x146/0x3b0 mm/slab.c:3649
alloc_task_struct_node kernel/fork.c:157 [inline]
dup_task_struct kernel/fork.c:807 [inline]
copy_process.part.0+0x1ceb/0x8260 kernel/fork.c:1753
copy_process kernel/fork.c:1710 [inline]
_do_fork+0x22f/0xf30 kernel/fork.c:2219
kernel_thread+0x2f/0x40 kernel/fork.c:2278
create_kthread kernel/kthread.c:282 [inline]
kthreadd+0x544/0x7b0 kernel/kthread.c:625
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:415

Freed by task 16940:
__cache_free mm/slab.c:3503 [inline]
kmem_cache_free+0x7f/0x260 mm/slab.c:3765
__put_task_struct+0x2ba/0x340 kernel/fork.c:694
put_task_struct include/linux/sched/task.h:98 [inline]
delayed_put_task_struct+0x1dc/0x320 kernel/exit.c:181
__rcu_reclaim kernel/rcu/rcu.h:236 [inline]
rcu_do_batch kernel/rcu/tree.c:2584 [inline]
invoke_rcu_callbacks kernel/rcu/tree.c:2897 [inline]
__rcu_process_callbacks kernel/rcu/tree.c:2864 [inline]
rcu_process_callbacks+0x8ff/0x18b0 kernel/rcu/tree.c:2881
__do_softirq+0x265/0x980 kernel/softirq.c:292

The buggy address belongs to the object at ffff8880aecb6180
which belongs to the cache task_struct of size 6208
The buggy address is located 32 bytes inside of
6208-byte region [ffff8880aecb6180, ffff8880aecb79c0)
The buggy address belongs to the page:
page:ffffea0002bb2d80 count:1 mapcount:0 mapping:ffff88823b8337c0 index:0x0 compound_mapcount: 0
flags: 0xfff00000008100(slab|head)
raw: 00fff00000008100 ffffea0002c0d988 ffffea0002bf5408 ffff88823b8337c0
raw: 0000000000000000 ffff8880aecb6180 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880aecb6080: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff8880aecb6100: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8880aecb6180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880aecb6200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880aecb6280: 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

syzbot

unread,
Oct 10, 2022, 12:29:41 PM10/10/22
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 3f8a27f9e27b Linux 4.19.211
git tree: linux-4.19.y
console output: https://syzkaller.appspot.com/x/log.txt?x=1785a83a880000
kernel config: https://syzkaller.appspot.com/x/.config?x=9b9277b418617afe
dashboard link: https://syzkaller.appspot.com/bug?extid=19f06d5730fe262a3a33
compiler: gcc version 10.2.1 20210110 (Debian 10.2.1-6)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=123a92a4880000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=161ce2dc880000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/98c0bdb4abb3/disk-3f8a27f9.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/ea228ff02669/vmlinux-3f8a27f9.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/af3755ac5deb/mount_0.gz

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

EXT4-fs (loop0): re-mounted. Opts: (null)
EXT4-fs (loop0): re-mounted. Opts: (null)
EXT4-fs (loop5): re-mounted. Opts: (null)
==================================================================
EXT4-fs (loop5): re-mounted. Opts: (null)
BUG: KASAN: use-after-free in atomic_inc include/asm-generic/atomic-instrumented.h:109 [inline]
BUG: KASAN: use-after-free in kthread_stop+0x72/0x6b0 kernel/kthread.c:583
Write of size 4 at addr ffff888092ef25a0 by task syz-executor308/8124

CPU: 0 PID: 8124 Comm: syz-executor308 Not tainted 4.19.211-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/22/2022
EXT4-fs (loop0): re-mounted. Opts: (null)
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+0x8f/0xa0 mm/kasan/report.c:412
EXT4-fs (loop0): re-mounted. Opts: (null)
atomic_inc include/asm-generic/atomic-instrumented.h:109 [inline]
kthread_stop+0x72/0x6b0 kernel/kthread.c:583
ext4_put_super+0x93c/0x1010 fs/ext4/super.c:1054
generic_shutdown_super+0x144/0x370 fs/super.c:456
EXT4-fs (loop5): re-mounted. Opts: (null)
kill_block_super+0x97/0xf0 fs/super.c:1185
deactivate_locked_super+0x94/0x160 fs/super.c:329
deactivate_super+0x174/0x1a0 fs/super.c:360
cleanup_mnt+0x1a8/0x290 fs/namespace.c:1098
EXT4-fs (loop0): re-mounted. Opts: (null)
task_work_run+0x148/0x1c0 kernel/task_work.c:113
tracehook_notify_resume include/linux/tracehook.h:193 [inline]
exit_to_usermode_loop+0x251/0x2a0 arch/x86/entry/common.c:167
prepare_exit_to_usermode arch/x86/entry/common.c:198 [inline]
syscall_return_slowpath arch/x86/entry/common.c:271 [inline]
do_syscall_64+0x538/0x620 arch/x86/entry/common.c:296
EXT4-fs (loop0): re-mounted. Opts: (null)
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7f6d28249317
Code: ff d0 48 89 c7 b8 3c 00 00 00 0f 05 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48 83 c8 ff c3 66 0f 1f 44 00 00 b8 a6 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffc08483f08 EFLAGS: 00000202 ORIG_RAX: 00000000000000a6
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 00007f6d28249317
RDX: 00007ffc08483fc9 RSI: 000000000000000a RDI: 00007ffc08483fc0
RBP: 00007ffc08483fc0 R08: 00000000ffffffff R09: 00007ffc08483da0
EXT4-fs (loop5): re-mounted. Opts: (null)
R10: 0000555556b57683 R11: 0000000000000202 R12: 00007ffc08485080
R13: 0000555556b575f0 R14: 00007ffc08483f30 R15: 00007ffc084850a0

Allocated by task 2:
kmem_cache_alloc_node+0x146/0x3b0 mm/slab.c:3649
alloc_task_struct_node kernel/fork.c:157 [inline]
dup_task_struct kernel/fork.c:807 [inline]
copy_process.part.0+0x1ceb/0x8260 kernel/fork.c:1753
copy_process kernel/fork.c:1710 [inline]
_do_fork+0x22f/0xf30 kernel/fork.c:2219
kernel_thread+0x2f/0x40 kernel/fork.c:2278
EXT4-fs (loop0): re-mounted. Opts: (null)
create_kthread kernel/kthread.c:282 [inline]
kthreadd+0x544/0x7b0 kernel/kthread.c:625
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:415

Freed by task 8286:
__cache_free mm/slab.c:3503 [inline]
kmem_cache_free+0x7f/0x260 mm/slab.c:3765
__put_task_struct+0x2ba/0x340 kernel/fork.c:694
EXT4-fs (loop5): re-mounted. Opts: (null)
put_task_struct include/linux/sched/task.h:98 [inline]
delayed_put_task_struct+0x1dc/0x320 kernel/exit.c:181
__rcu_reclaim kernel/rcu/rcu.h:236 [inline]
rcu_do_batch kernel/rcu/tree.c:2584 [inline]
invoke_rcu_callbacks kernel/rcu/tree.c:2897 [inline]
__rcu_process_callbacks kernel/rcu/tree.c:2864 [inline]
rcu_process_callbacks+0x8ff/0x18b0 kernel/rcu/tree.c:2881
__do_softirq+0x265/0x980 kernel/softirq.c:292

The buggy address belongs to the object at ffff888092ef2580
which belongs to the cache task_struct of size 6208
The buggy address is located 32 bytes inside of
6208-byte region [ffff888092ef2580, ffff888092ef3dc0)
The buggy address belongs to the page:
page:ffffea00024bbc80 count:1 mapcount:0 mapping:ffff88823b8337c0 index:0x0 compound_mapcount: 0
flags: 0xfff00000008100(slab|head)
raw: 00fff00000008100 ffffea0002a93a08 ffffea0002aac408 ffff88823b8337c0
raw: 0000000000000000 ffff888092ef2580 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff888092ef2480: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff888092ef2500: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888092ef2580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888092ef2600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888092ef2680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Reply all
Reply to author
Forward
0 new messages