KASAN: use-after-free Write in put_files_struct

9 views
Skip to first unread message

syzbot

unread,
Jan 9, 2022, 8:51:22 PM1/9/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=12840be3b00000
kernel config: https://syzkaller.appspot.com/x/.config?x=9b9277b418617afe
dashboard link: https://syzkaller.appspot.com/bug?extid=beb477b6a7657361bdd0
compiler: gcc version 10.2.1 20210110 (Debian 10.2.1-6)

Unfortunately, I don't have any reproducer for this issue yet.

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

==================================================================
BUG: KASAN: use-after-free in atomic_dec_and_test include/asm-generic/atomic-instrumented.h:259 [inline]
BUG: KASAN: use-after-free in put_files_struct+0x23/0x350 fs/file.c:415
Write of size 4 at addr ffff8880001220c0 by task syz-executor.2/26832

CPU: 1 PID: 26832 Comm: syz-executor.2 Not tainted 4.19.211-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+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_dec_and_test include/asm-generic/atomic-instrumented.h:259 [inline]
put_files_struct+0x23/0x350 fs/file.c:415
exit_files+0x7e/0xa0 fs/file.c:445
do_exit+0xbb9/0x2be0 kernel/exit.c:865
do_group_exit+0x125/0x310 kernel/exit.c:967
get_signal+0x3f2/0x1f70 kernel/signal.c:2589
do_signal+0x8f/0x1670 arch/x86/kernel/signal.c:799
exit_to_usermode_loop+0x204/0x2a0 arch/x86/entry/common.c:163
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:0x7fd8d23ade99
Code: Bad RIP value.
RSP: 002b:00007fd8d0d23218 EFLAGS: 00000246 ORIG_RAX: 00000000000000ca
RAX: fffffffffffffe00 RBX: 00007fd8d24c0f68 RCX: 00007fd8d23ade99
RDX: 0000000000000000 RSI: 0000000000000080 RDI: 00007fd8d24c0f68
RBP: 00007fd8d24c0f60 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007fd8d24c0f6c
R13: 00007ffefec60edf R14: 00007fd8d0d23300 R15: 0000000000022000

Allocated by task 8127:
kmem_cache_alloc+0x122/0x370 mm/slab.c:3559
dup_fd+0x85/0xbf0 fs/file.c:280
copy_files kernel/fork.c:1391 [inline]
copy_process.part.0+0x1e75/0x8260 kernel/fork.c:1901
copy_process kernel/fork.c:1710 [inline]
_do_fork+0x22f/0xf30 kernel/fork.c:2219
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 26836:
__cache_free mm/slab.c:3503 [inline]
kmem_cache_free+0x7f/0x260 mm/slab.c:3765
put_files_struct fs/file.c:421 [inline]
put_files_struct+0x2c8/0x350 fs/file.c:413
exit_files+0x7e/0xa0 fs/file.c:445
do_exit+0xbb9/0x2be0 kernel/exit.c:865
do_group_exit+0x125/0x310 kernel/exit.c:967
get_signal+0x3f2/0x1f70 kernel/signal.c:2589
do_signal+0x8f/0x1670 arch/x86/kernel/signal.c:799
exit_to_usermode_loop+0x204/0x2a0 arch/x86/entry/common.c:163
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

The buggy address belongs to the object at ffff8880001220c0
which belongs to the cache files_cache of size 832
The buggy address is located 0 bytes inside of
832-byte region [ffff8880001220c0, ffff888000122400)
The buggy address belongs to the page:
page:ffffea0000004880 count:1 mapcount:0 mapping:ffff88823b833ac0 index:0x0
IPVS: ftp: loaded support on port[0] = 21
flags: 0x7ff00000000100(slab)
raw: 007ff00000000100 ffffea0002923248 ffffea000292d288 ffff88823b833ac0
raw: 0000000000000000 ffff8880001220c0 0000000100000004 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff888000121f80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff888000122000: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888000122080: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
^
ffff888000122100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888000122180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
IPVS: ftp: loaded support on port[0] = 21
IPVS: ftp: loaded support on port[0] = 21


---
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

unread,
May 9, 2022, 9:51:17 PM5/9/22
to syzkaller...@googlegroups.com
Auto-closing this bug as obsolete.
Crashes did not happen for a while, no reproducer and no activity.
Reply all
Reply to author
Forward
0 new messages