[Android 5.4] KASAN: use-after-free Write in enqueue_timer (2)

7 views
Skip to first unread message

syzbot

unread,
Feb 17, 2025, 10:17:21 AM2/17/25
to syzkaller-a...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 39762b7a60e9 UPSTREAM: dma-buf: heaps: Fix off-by-one in C..
git tree: android12-5.4
console+strace: https://syzkaller.appspot.com/x/log.txt?x=17ae25b0580000
kernel config: https://syzkaller.appspot.com/x/.config?x=9bcfb44d32c96d73
dashboard link: https://syzkaller.appspot.com/bug?extid=02af8de0847c4564d39d
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=102fdbf8580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13d175a4580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/a9a4ec5530bd/disk-39762b7a.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/62918de812f3/vmlinux-39762b7a.xz
kernel image: https://storage.googleapis.com/syzbot-assets/c93c8f45dd33/bzImage-39762b7a.xz

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

==================================================================
BUG: KASAN: use-after-free in hlist_add_head include/linux/list.h:814 [inline]
BUG: KASAN: use-after-free in enqueue_timer+0xb7/0x300 kernel/time/timer.c:541
Write of size 8 at addr ffff8881e555b1c8 by task ksoftirqd/1/17

CPU: 1 PID: 17 Comm: ksoftirqd/1 Not tainted 5.4.289-syzkaller-00011-g39762b7a60e9 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 12/27/2024
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
hlist_add_head include/linux/list.h:814 [inline]
enqueue_timer+0xb7/0x300 kernel/time/timer.c:541
__internal_add_timer kernel/time/timer.c:554 [inline]
internal_add_timer+0x240/0x430 kernel/time/timer.c:604
__mod_timer+0x6f1/0x13e0 kernel/time/timer.c:1065
call_timer_fn+0x36/0x390 kernel/time/timer.c:1448
expire_timers kernel/time/timer.c:1493 [inline]
__run_timers+0x879/0xbe0 kernel/time/timer.c:1817
run_timer_softirq+0x63/0xf0 kernel/time/timer.c:1830
__do_softirq+0x23b/0x6b7 kernel/softirq.c:292
run_ksoftirqd+0x1f/0x30 kernel/softirq.c:603
smpboot_thread_fn+0x545/0x930 kernel/smpboot.c:165
kthread+0x2da/0x360 kernel/kthread.c:288
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:354

Allocated by task 415:
save_stack mm/kasan/common.c:70 [inline]
set_track mm/kasan/common.c:78 [inline]
__kasan_kmalloc+0x171/0x210 mm/kasan/common.c:529
slab_post_alloc_hook mm/slab.h:584 [inline]
slab_alloc_node mm/slub.c:2829 [inline]
slab_alloc mm/slub.c:2837 [inline]
__kmalloc_track_caller+0x100/0x2b0 mm/slub.c:4449
__kmalloc_reserve net/core/skbuff.c:142 [inline]
__alloc_skb+0xb4/0x4d0 net/core/skbuff.c:210
alloc_skb include/linux/skbuff.h:1080 [inline]
netlink_alloc_large_skb net/netlink/af_netlink.c:1178 [inline]
netlink_sendmsg+0x797/0xcf0 net/netlink/af_netlink.c:1875
sock_sendmsg_nosec net/socket.c:638 [inline]
__sock_sendmsg net/socket.c:650 [inline]
____sys_sendmsg+0x5ac/0x8f0 net/socket.c:2306
___sys_sendmsg net/socket.c:2360 [inline]
__sys_sendmsg+0x28b/0x380 net/socket.c:2406
do_syscall_64+0xca/0x1c0 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x5c/0xc1

Freed by task 415:
save_stack mm/kasan/common.c:70 [inline]
set_track mm/kasan/common.c:78 [inline]
kasan_set_free_info mm/kasan/common.c:345 [inline]
__kasan_slab_free+0x1b5/0x270 mm/kasan/common.c:487
slab_free_hook mm/slub.c:1455 [inline]
slab_free_freelist_hook mm/slub.c:1494 [inline]
slab_free mm/slub.c:3080 [inline]
kfree+0x123/0x370 mm/slub.c:4071
skb_release_all net/core/skbuff.c:675 [inline]
__kfree_skb net/core/skbuff.c:689 [inline]
consume_skb+0xa5/0x2a0 net/core/skbuff.c:849
netlink_unicast_kernel net/netlink/af_netlink.c:1307 [inline]
netlink_unicast+0x93e/0xb20 net/netlink/af_netlink.c:1332
netlink_sendmsg+0xa18/0xcf0 net/netlink/af_netlink.c:1900
sock_sendmsg_nosec net/socket.c:638 [inline]
__sock_sendmsg net/socket.c:650 [inline]
____sys_sendmsg+0x5ac/0x8f0 net/socket.c:2306
___sys_sendmsg net/socket.c:2360 [inline]
__sys_sendmsg+0x28b/0x380 net/socket.c:2406
do_syscall_64+0xca/0x1c0 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x5c/0xc1

The buggy address belongs to the object at ffff8881e555b000
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 456 bytes inside of
512-byte region [ffff8881e555b000, ffff8881e555b200)
The buggy address belongs to the page:
page:ffffea0007955600 refcount:1 mapcount:0 mapping:ffff8881f5c02500 index:0x0 compound_mapcount: 0
flags: 0x8000000000010200(slab|head)
raw: 8000000000010200 dead000000000100 dead000000000122 ffff8881f5c02500
raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 2, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC)
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:4893
alloc_slab_page+0x39/0x3c0 mm/slub.c:343
allocate_slab mm/slub.c:1683 [inline]
new_slab+0x97/0x440 mm/slub.c:1749
new_slab_objects mm/slub.c:2505 [inline]
___slab_alloc+0x2fe/0x490 mm/slub.c:2667
__slab_alloc+0x62/0xa0 mm/slub.c:2707
slab_alloc_node mm/slub.c:2792 [inline]
slab_alloc mm/slub.c:2837 [inline]
__kmalloc_track_caller+0x16d/0x2b0 mm/slub.c:4449
__kmalloc_reserve net/core/skbuff.c:142 [inline]
__alloc_skb+0xb4/0x4d0 net/core/skbuff.c:210
alloc_skb include/linux/skbuff.h:1080 [inline]
netlink_alloc_large_skb net/netlink/af_netlink.c:1178 [inline]
netlink_sendmsg+0x797/0xcf0 net/netlink/af_netlink.c:1875
sock_sendmsg_nosec net/socket.c:638 [inline]
__sock_sendmsg net/socket.c:650 [inline]
____sys_sendmsg+0x5ac/0x8f0 net/socket.c:2306
___sys_sendmsg net/socket.c:2360 [inline]
__sys_sendmsg+0x28b/0x380 net/socket.c:2406
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:4955 [inline]
__free_pages+0x91/0x140 mm/page_alloc.c:4961
device_release+0x6b/0x190 drivers/base/core.c:1776
kobject_cleanup lib/kobject.c:716 [inline]
kobject_release lib/kobject.c:747 [inline]
kref_put include/linux/kref.h:65 [inline]
kobject_put+0x1e6/0x2f0 lib/kobject.c:764
tun_set_iff+0x870/0xdc0 drivers/net/tun.c:2924
__tun_chr_ioctl+0x8a9/0x1d00 drivers/net/tun.c:3187
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:
ffff8881e555b080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8881e555b100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8881e555b180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8881e555b200: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff8881e555b280: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================
BUG: kernel NULL pointer dereference, address: 0000000000000000
#PF: supervisor instruction fetch in kernel mode
#PF: error_code(0x0010) - not-present page
PGD 0 P4D 0
Oops: 0010 [#1] PREEMPT SMP KASAN
CPU: 1 PID: 470 Comm: syz-executor188 Tainted: G B 5.4.289-syzkaller-00011-g39762b7a60e9 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 12/27/2024
RIP: 0010:0x0
Code: Bad RIP value.
RSP: 0018:ffff8881f6f09d18 EFLAGS: 00010206
RAX: ffffffff8154e8aa RBX: 0000000000000100 RCX: ffff8881edf43f00
RDX: 0000000080000100 RSI: 0000000000000000 RDI: ffff8881e555b1c0
RBP: ffff8881f6f09ec8 R08: ffffffff8154e4ee R09: 0000000000000003
R10: ffffffffffffffff R11: dffffc0000000001 R12: 00000000ffffb630
R13: dffffc0000000000 R14: 0000000000000000 R15: ffff8881e555b1c0
FS: 00005555937f1380(0000) GS:ffff8881f6f00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffffffffffffd6 CR3: 00000001e555f000 CR4: 00000000003406a0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<IRQ>
call_timer_fn+0x36/0x390 kernel/time/timer.c:1448
expire_timers kernel/time/timer.c:1493 [inline]
__run_timers+0x879/0xbe0 kernel/time/timer.c:1817
run_timer_softirq+0x63/0xf0 kernel/time/timer.c:1830
__do_softirq+0x23b/0x6b7 kernel/softirq.c:292
invoke_softirq kernel/softirq.c:373 [inline]
irq_exit+0x195/0x1c0 kernel/softirq.c:413
exiting_irq arch/x86/include/asm/apic.h:539 [inline]
smp_apic_timer_interrupt+0x11a/0x490 arch/x86/kernel/apic/apic.c:1161
apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:834
</IRQ>
RIP: 0010:stack_trace_consume_entry+0x142/0x240 kernel/stacktrace.c:94
Code: 44 24 10 89 28 48 89 c5 4a 8d 1c eb 48 89 d8 48 c1 e8 03 42 80 3c 30 00 74 08 48 89 df e8 d6 6f 40 00 48 8b 44 24 18 48 89 03 <8b> 5d 00 43 0f b6 04 34 84 c0 0f 85 c2 00 00 00 48 8b 44 24 08 8b
RSP: 0018:ffff8881e53b7268 EFLAGS: 00000246 ORIG_RAX: ffffffffffffff13
RAX: ffffffff819fb9e4 RBX: ffff8881e53b74d0 RCX: ffff8881edf43f00
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: ffff8881e53b73b0 R08: ffffffff8153c4af R09: ffff8881e53b7310
R10: 0000000000000000 R11: dffffc0000000001 R12: 1ffff1103ca76e75
R13: 000000000000000c R14: dffffc0000000000 R15: 1ffff1103ca76e76
arch_stack_walk+0x105/0x140 arch/x86/kernel/stacktrace.c:27
stack_trace_save+0x118/0x1c0 kernel/stacktrace.c:123
save_stack mm/kasan/common.c:70 [inline]
set_track mm/kasan/common.c:78 [inline]
__kasan_kmalloc+0x171/0x210 mm/kasan/common.c:529
slab_post_alloc_hook mm/slab.h:584 [inline]
slab_alloc_node mm/slub.c:2829 [inline]
slab_alloc mm/slub.c:2837 [inline]
__kmalloc_track_caller+0x100/0x2b0 mm/slub.c:4449
kmemdup+0x21/0x50 mm/util.c:127
neigh_sysctl_register+0xb0/0x530 net/core/neighbour.c:3648
devinet_sysctl_register+0x9d/0x1a0 net/ipv4/devinet.c:2638
inetdev_init+0x255/0x450 net/ipv4/devinet.c:277
inetdev_event+0x205/0x1040 net/ipv4/devinet.c:1544
notifier_call_chain kernel/notifier.c:98 [inline]
__raw_notifier_call_chain kernel/notifier.c:399 [inline]
raw_notifier_call_chain+0x95/0x110 kernel/notifier.c:406
call_netdevice_notifiers_info net/core/dev.c:1670 [inline]
call_netdevice_notifiers_extack net/core/dev.c:1682 [inline]
call_netdevice_notifiers net/core/dev.c:1696 [inline]
register_netdevice+0xeef/0x12a0 net/core/dev.c:9240
tun_set_iff+0x7f7/0xdc0 drivers/net/tun.c:2922
__tun_chr_ioctl+0x8a9/0x1d00 drivers/net/tun.c:3187
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
RIP: 0033:0x7fd00c567ed9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 51 1f 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 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:00007ffedcc2c958 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007fd00c567ed9
RDX: 0000400000000080 RSI: 00000000400454ca RDI: 0000000000000005
RBP: 0000000000000000 R08: 00007fd00c5af1fa R09: 00007fd00c5af1fa
R10: 00007fd00c5af1fa R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
Modules linked in:
CR2: 0000000000000000
---[ end trace e5f94e2a4602df16 ]---
RIP: 0010:0x0
Code: Bad RIP value.
RSP: 0018:ffff8881f6f09d18 EFLAGS: 00010206
RAX: ffffffff8154e8aa RBX: 0000000000000100 RCX: ffff8881edf43f00
RDX: 0000000080000100 RSI: 0000000000000000 RDI: ffff8881e555b1c0
RBP: ffff8881f6f09ec8 R08: ffffffff8154e4ee R09: 0000000000000003
R10: ffffffffffffffff R11: dffffc0000000001 R12: 00000000ffffb630
R13: dffffc0000000000 R14: 0000000000000000 R15: ffff8881e555b1c0
FS: 00005555937f1380(0000) GS:ffff8881f6f00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffffffffffffd6 CR3: 00000001e555f000 CR4: 00000000003406a0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
0: 44 24 10 rex.R and $0x10,%al
3: 89 28 mov %ebp,(%rax)
5: 48 89 c5 mov %rax,%rbp
8: 4a 8d 1c eb lea (%rbx,%r13,8),%rbx
c: 48 89 d8 mov %rbx,%rax
f: 48 c1 e8 03 shr $0x3,%rax
13: 42 80 3c 30 00 cmpb $0x0,(%rax,%r14,1)
18: 74 08 je 0x22
1a: 48 89 df mov %rbx,%rdi
1d: e8 d6 6f 40 00 call 0x406ff8
22: 48 8b 44 24 18 mov 0x18(%rsp),%rax
27: 48 89 03 mov %rax,(%rbx)
* 2a: 8b 5d 00 mov 0x0(%rbp),%ebx <-- trapping instruction
2d: 43 0f b6 04 34 movzbl (%r12,%r14,1),%eax
32: 84 c0 test %al,%al
34: 0f 85 c2 00 00 00 jne 0xfc
3a: 48 8b 44 24 08 mov 0x8(%rsp),%rax
3f: 8b .byte 0x8b


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

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

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.

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup
Reply all
Reply to author
Forward
0 new messages