[Android 5.4] KASAN: use-after-free Write in detach_if_pending

10 views
Skip to first unread message

syzbot

unread,
Feb 10, 2023, 1:19:22 PM2/10/23
to syzkaller-a...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 6a5ec6cea0cd UPSTREAM: 9p/fd: fix issue of list_del corrup..
git tree: android12-5.4
console output: https://syzkaller.appspot.com/x/log.txt?x=170c0007480000
kernel config: https://syzkaller.appspot.com/x/.config?x=e270749e5a0ba365
dashboard link: https://syzkaller.appspot.com/bug?extid=2db3ce7c2c48587cff89
compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2

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

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/68d94ce466da/disk-6a5ec6ce.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/edf99d431199/vmlinux-6a5ec6ce.xz
kernel image: https://storage.googleapis.com/syzbot-assets/685ae70c99ed/bzImage-6a5ec6ce.xz

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

==================================================================
BUG: KASAN: use-after-free in __write_once_size include/linux/compiler.h:295 [inline]
BUG: KASAN: use-after-free in __hlist_del include/linux/list.h:771 [inline]
BUG: KASAN: use-after-free in detach_timer kernel/time/timer.c:824 [inline]
BUG: KASAN: use-after-free in detach_if_pending+0x130/0x340 kernel/time/timer.c:841
Write of size 8 at addr ffff88818bb6b1c0 by task syz-executor.3/23294

CPU: 1 PID: 23294 Comm: syz-executor.3 Not tainted 5.4.225-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/21/2023
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x1d8/0x241 lib/dump_stack.c:118
print_address_description+0x8c/0x600 mm/kasan/report.c:384
__kasan_report+0xf3/0x120 mm/kasan/report.c:516
kasan_report+0x30/0x60 mm/kasan/common.c:653
__write_once_size include/linux/compiler.h:295 [inline]
__hlist_del include/linux/list.h:771 [inline]
detach_timer kernel/time/timer.c:824 [inline]
detach_if_pending+0x130/0x340 kernel/time/timer.c:841
try_to_del_timer_sync kernel/time/timer.c:1238 [inline]
del_timer_sync+0x170/0x250 kernel/time/timer.c:1379
tun_flow_uninit+0x2c/0x280 drivers/net/tun.c:1398
tun_free_netdev+0x77/0x190 drivers/net/tun.c:2348
netdev_run_todo+0xae0/0xd50 net/core/dev.c:9446
tun_detach drivers/net/tun.c:760 [inline]
tun_chr_close+0xc0/0xd0 drivers/net/tun.c:3543
__fput+0x262/0x680 fs/file_table.c:281
task_work_run+0x140/0x170 kernel/task_work.c:113
tracehook_notify_resume include/linux/tracehook.h:188 [inline]
exit_to_usermode_loop+0x18b/0x1a0 arch/x86/entry/common.c:163
prepare_exit_to_usermode+0x199/0x200 arch/x86/entry/common.c:194
entry_SYSCALL_64_after_hwframe+0x5c/0xc1

The buggy address belongs to the page:
page:ffffea00062edac0 refcount:0 mapcount:0 mapping:0000000000000000 index:0x0
flags: 0x8000000000000000()
raw: 8000000000000000 0000000000000000 dead000000000122 0000000000000000
raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as freed
page last allocated via order 2, migratetype Unmovable, gfp_mask 0x146dc0(GFP_USER|__GFP_NOWARN|__GFP_RETRY_MAYFAIL|__GFP_COMP|__GFP_ZERO)
set_page_owner include/linux/page_owner.h:31 [inline]
post_alloc_hook mm/page_alloc.c:2165 [inline]
prep_new_page+0x18f/0x370 mm/page_alloc.c:2171
get_page_from_freelist+0x2ce8/0x2d70 mm/page_alloc.c:3794
__alloc_pages_nodemask+0x393/0x840 mm/page_alloc.c:4891
__alloc_pages include/linux/gfp.h:503 [inline]
__alloc_pages_node include/linux/gfp.h:516 [inline]
alloc_pages_node include/linux/gfp.h:530 [inline]
kmalloc_order mm/slab_common.c:1342 [inline]
kmalloc_order_trace+0x2a/0x100 mm/slab_common.c:1358
__kmalloc_node include/linux/slab.h:422 [inline]
kmalloc_node include/linux/slab.h:599 [inline]
kvmalloc_node+0x7e/0xf0 mm/util.c:596
kvmalloc include/linux/mm.h:759 [inline]
kvzalloc include/linux/mm.h:767 [inline]
alloc_netdev_mqs+0x85/0xc70 net/core/dev.c:9598
tun_set_iff+0x516/0x10c0 drivers/net/tun.c:2834
__tun_chr_ioctl+0x806/0x1ed0 drivers/net/tun.c:3169
do_vfs_ioctl+0x742/0x1720 fs/ioctl.c:47
ksys_ioctl fs/ioctl.c:742 [inline]
__do_sys_ioctl fs/ioctl.c:749 [inline]
__se_sys_ioctl fs/ioctl.c:747 [inline]
__x64_sys_ioctl+0xd4/0x110 fs/ioctl.c:747
do_syscall_64+0xca/0x1c0 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x5c/0xc1
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1176 [inline]
__free_pages_ok+0x83d/0x940 mm/page_alloc.c:1438
free_the_page mm/page_alloc.c:4953 [inline]
__free_pages+0x91/0x140 mm/page_alloc.c:4959
device_release+0x6b/0x190 drivers/base/core.c:1776
kobject_cleanup lib/kobject.c:708 [inline]
kobject_release lib/kobject.c:739 [inline]
kref_put include/linux/kref.h:65 [inline]
kobject_put+0x1e6/0x2f0 lib/kobject.c:756
tun_set_iff+0xc48/0x10c0 drivers/net/tun.c:2926
__tun_chr_ioctl+0x806/0x1ed0 drivers/net/tun.c:3169
do_vfs_ioctl+0x742/0x1720 fs/ioctl.c:47
ksys_ioctl fs/ioctl.c:742 [inline]
__do_sys_ioctl fs/ioctl.c:749 [inline]
__se_sys_ioctl fs/ioctl.c:747 [inline]
__x64_sys_ioctl+0xd4/0x110 fs/ioctl.c:747
do_syscall_64+0xca/0x1c0 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x5c/0xc1

Memory state around the buggy address:
ffff88818bb6b080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff88818bb6b100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff88818bb6b180: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
^
ffff88818bb6b200: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff88818bb6b280: 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.

syzbot

unread,
Nov 14, 2023, 2:09:28 AM11/14/23
to syzkaller-a...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 2ac128c04e33 UPSTREAM: netfilter: ipset: add the missing I..
git tree: android12-5.4
console+strace: https://syzkaller.appspot.com/x/log.txt?x=15569338e80000
kernel config: https://syzkaller.appspot.com/x/.config?x=15ac5e7967d4bfae
dashboard link: https://syzkaller.appspot.com/bug?extid=2db3ce7c2c48587cff89
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=11e9cc04e80000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1667277b680000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/162c8ab019f6/disk-2ac128c0.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/ce854c8256c2/vmlinux-2ac128c0.xz
kernel image: https://storage.googleapis.com/syzbot-assets/f668f02a568f/bzImage-2ac128c0.xz

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

==================================================================
BUG: KASAN: use-after-free in __write_once_size include/linux/compiler.h:295 [inline]
BUG: KASAN: use-after-free in __hlist_del include/linux/list.h:789 [inline]
BUG: KASAN: use-after-free in detach_timer kernel/time/timer.c:824 [inline]
BUG: KASAN: use-after-free in detach_if_pending+0x160/0x360 kernel/time/timer.c:841
Write of size 8 at addr ffff8881da8231c0 by task syz-executor292/415

CPU: 0 PID: 415 Comm: syz-executor292 Not tainted 5.4.254-syzkaller-00011-g2ac128c04e33 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/09/2023
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x1d8/0x241 lib/dump_stack.c:118
print_address_description+0x8c/0x600 mm/kasan/report.c:384
__kasan_report+0xf3/0x120 mm/kasan/report.c:516
kasan_report+0x30/0x60 mm/kasan/common.c:653
__write_once_size include/linux/compiler.h:295 [inline]
__hlist_del include/linux/list.h:789 [inline]
detach_timer kernel/time/timer.c:824 [inline]
detach_if_pending+0x160/0x360 kernel/time/timer.c:841
try_to_del_timer_sync kernel/time/timer.c:1238 [inline]
del_timer_sync+0x13c/0x230 kernel/time/timer.c:1379
tun_flow_uninit+0x2c/0x280 drivers/net/tun.c:1451
tun_free_netdev+0x77/0x190 drivers/net/tun.c:2401
netdev_run_todo+0xb7f/0xdf0 net/core/dev.c:9450
tun_detach drivers/net/tun.c:765 [inline]
tun_chr_close+0xc1/0x130 drivers/net/tun.c:3554
__fput+0x262/0x680 fs/file_table.c:281
task_work_run+0x140/0x170 kernel/task_work.c:113
ptrace_notify+0x29e/0x350 kernel/signal.c:2271
ptrace_report_syscall include/linux/tracehook.h:66 [inline]
tracehook_report_syscall_exit include/linux/tracehook.h:129 [inline]
syscall_slow_exit_work+0x167/0x400 arch/x86/entry/common.c:246
syscall_return_slowpath arch/x86/entry/common.c:271 [inline]
do_syscall_64+0x19d/0x1c0 arch/x86/entry/common.c:300
entry_SYSCALL_64_after_hwframe+0x5c/0xc1

The buggy address belongs to the page:
page:ffffea00076a08c0 refcount:0 mapcount:0 mapping:0000000000000000 index:0x0
flags: 0x8000000000000000()
raw: 8000000000000000 0000000000000000 ffffea00076a08c8 0000000000000000
raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as freed
page last allocated via order 2, migratetype Unmovable, gfp_mask 0x46dc0(GFP_KERNEL|__GFP_NOWARN|__GFP_RETRY_MAYFAIL|__GFP_COMP|__GFP_ZERO)
set_page_owner include/linux/page_owner.h:31 [inline]
post_alloc_hook mm/page_alloc.c:2165 [inline]
prep_new_page+0x18f/0x370 mm/page_alloc.c:2171
get_page_from_freelist+0x2d13/0x2d90 mm/page_alloc.c:3794
__alloc_pages_nodemask+0x393/0x840 mm/page_alloc.c:4891
__alloc_pages include/linux/gfp.h:503 [inline]
__alloc_pages_node include/linux/gfp.h:516 [inline]
alloc_pages_node include/linux/gfp.h:530 [inline]
kmalloc_order mm/slab_common.c:1342 [inline]
kmalloc_order_trace+0x2a/0x100 mm/slab_common.c:1358
__kmalloc_node include/linux/slab.h:422 [inline]
kmalloc_node include/linux/slab.h:599 [inline]
kvmalloc_node+0x7e/0xf0 mm/util.c:596
kvmalloc include/linux/mm.h:759 [inline]
kvzalloc include/linux/mm.h:767 [inline]
alloc_netdev_mqs+0x85/0xc70 net/core/dev.c:9602
tun_set_iff+0x51f/0xdc0 drivers/net/tun.c:2887
__tun_chr_ioctl+0x860/0x1d50 drivers/net/tun.c:3180
do_vfs_ioctl+0x742/0x1720 fs/ioctl.c:47
ksys_ioctl fs/ioctl.c:742 [inline]
__do_sys_ioctl fs/ioctl.c:749 [inline]
__se_sys_ioctl fs/ioctl.c:747 [inline]
__x64_sys_ioctl+0xd4/0x110 fs/ioctl.c:747
do_syscall_64+0xca/0x1c0 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x5c/0xc1
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1176 [inline]
__free_pages_ok+0x847/0x950 mm/page_alloc.c:1438
free_the_page mm/page_alloc.c:4953 [inline]
__free_pages+0x91/0x140 mm/page_alloc.c:4959
device_release+0x6b/0x190 drivers/base/core.c:1776
kobject_cleanup lib/kobject.c:708 [inline]
kobject_release lib/kobject.c:739 [inline]
kref_put include/linux/kref.h:65 [inline]
kobject_put+0x1e6/0x2f0 lib/kobject.c:756
tun_set_iff+0x870/0xdc0 drivers/net/tun.c:2918
__tun_chr_ioctl+0x860/0x1d50 drivers/net/tun.c:3180
do_vfs_ioctl+0x742/0x1720 fs/ioctl.c:47
ksys_ioctl fs/ioctl.c:742 [inline]
__do_sys_ioctl fs/ioctl.c:749 [inline]
__se_sys_ioctl fs/ioctl.c:747 [inline]
__x64_sys_ioctl+0xd4/0x110 fs/ioctl.c:747
do_syscall_64+0xca/0x1c0 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x5c/0xc1

Memory state around the buggy address:
ffff8881da823080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff8881da823100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff8881da823180: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
^
ffff8881da823200: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff8881da823280: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================


---
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.
Reply all
Reply to author
Forward
0 new messages