syzbot


KASAN: use-after-free Write in _atomic_dec_and_lock_irqsave

Status: auto-closed as invalid on 2021/12/17 19:52
Reported-by: syzbot+c59302ca1658701a11fc@syzkaller.appspotmail.com
First crash: 468d, last: 468d
similar bugs (1):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Write in _atomic_dec_and_lock_irqsave (2) 5 324d 320d 0/24 auto-closed as invalid on 2022/03/11 16:29

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in instrument_atomic_read_write include/linux/instrumented.h:101 [inline]
BUG: KASAN: use-after-free in atomic_add_unless include/asm-generic/atomic-instrumented.h:570 [inline]
BUG: KASAN: use-after-free in _atomic_dec_and_lock_irqsave+0x2f/0x150 lib/dec_and_lock.c:41
Write of size 4 at addr ffff88802a10111c by task ksoftirqd/1/19

CPU: 1 PID: 19 Comm: ksoftirqd/1 Not tainted 5.14.0-rc6-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1ae/0x29f lib/dump_stack.c:105
 print_address_description+0x66/0x3b0 mm/kasan/report.c:233
 __kasan_report mm/kasan/report.c:419 [inline]
 kasan_report+0x163/0x210 mm/kasan/report.c:436
 check_region_inline mm/kasan/generic.c:135 [inline]
 kasan_check_range+0x2b5/0x2f0 mm/kasan/generic.c:189
 instrument_atomic_read_write include/linux/instrumented.h:101 [inline]
 atomic_add_unless include/asm-generic/atomic-instrumented.h:570 [inline]
 _atomic_dec_and_lock_irqsave+0x2f/0x150 lib/dec_and_lock.c:41
 put_ucounts+0x7c/0x1a0 kernel/ucount.c:204
 put_cred_rcu+0x221/0x400 kernel/cred.c:124
 rcu_do_batch kernel/rcu/tree.c:2550 [inline]
 rcu_core+0x906/0x14b0 kernel/rcu/tree.c:2785
 __do_softirq+0x372/0x783 kernel/softirq.c:558
 run_ksoftirqd+0xa2/0x100 kernel/softirq.c:920
 smpboot_thread_fn+0x533/0x9d0 kernel/smpboot.c:164
 kthread+0x453/0x480 kernel/kthread.c:319
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

Allocated by task 20438:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:434 [inline]
 ____kasan_kmalloc+0xc4/0xf0 mm/kasan/common.c:513
 kasan_kmalloc include/linux/kasan.h:264 [inline]
 kmem_cache_alloc_trace+0x96/0x340 mm/slub.c:2986
 kmalloc include/linux/slab.h:591 [inline]
 kzalloc include/linux/slab.h:721 [inline]
 alloc_ucounts+0x1b1/0x5d0 kernel/ucount.c:173
 set_cred_ucounts+0x220/0x2d0 kernel/cred.c:684
 __sys_setresuid+0x6d5/0x920 kernel/sys.c:702
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

Freed by task 8456:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x3d/0x70 mm/kasan/common.c:46
 kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:360
 ____kasan_slab_free+0x109/0x150 mm/kasan/common.c:366
 kasan_slab_free include/linux/kasan.h:230 [inline]
 slab_free_hook mm/slub.c:1628 [inline]
 slab_free_freelist_hook+0x1d8/0x290 mm/slub.c:1653
 slab_free mm/slub.c:3213 [inline]
 kfree+0xcf/0x2e0 mm/slub.c:4267
 put_ucounts+0x15c/0x1a0 kernel/ucount.c:207
 put_cred_rcu+0x221/0x400 kernel/cred.c:124
 rcu_do_batch kernel/rcu/tree.c:2550 [inline]
 rcu_core+0x906/0x14b0 kernel/rcu/tree.c:2785
 __do_softirq+0x372/0x783 kernel/softirq.c:558

Last potentially related work creation:
 kasan_save_stack+0x27/0x50 mm/kasan/common.c:38
 kasan_record_aux_stack+0xee/0x120 mm/kasan/generic.c:348
 __call_rcu kernel/rcu/tree.c:3029 [inline]
 call_rcu+0x1a0/0xa20 kernel/rcu/tree.c:3109
 inetdev_destroy net/ipv4/devinet.c:325 [inline]
 inetdev_event+0x79a/0x14d0 net/ipv4/devinet.c:1598
 notifier_call_chain kernel/notifier.c:83 [inline]
 raw_notifier_call_chain+0xe7/0x170 kernel/notifier.c:410
 call_netdevice_notifiers_info net/core/dev.c:2123 [inline]
 call_netdevice_notifiers_extack net/core/dev.c:2135 [inline]
 call_netdevice_notifiers net/core/dev.c:2149 [inline]
 unregister_netdevice_many+0xf7e/0x1980 net/core/dev.c:11093
 ip_tunnel_delete_nets+0x325/0x370 net/ipv4/ip_tunnel.c:1122
 ops_exit_list net/core/net_namespace.c:178 [inline]
 cleanup_net+0x7ec/0xc60 net/core/net_namespace.c:595
 process_one_work+0x833/0x10c0 kernel/workqueue.c:2276
 worker_thread+0xac1/0x1320 kernel/workqueue.c:2422
 kthread+0x453/0x480 kernel/kthread.c:319
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

Second to last potentially related work creation:
 kasan_save_stack+0x27/0x50 mm/kasan/common.c:38
 kasan_record_aux_stack+0xee/0x120 mm/kasan/generic.c:348
 insert_work+0x54/0x400 kernel/workqueue.c:1332
 __queue_work+0x928/0xc60 kernel/workqueue.c:1498
 queue_work_on+0x111/0x200 kernel/workqueue.c:1525
 queue_work include/linux/workqueue.h:507 [inline]
 call_usermodehelper_exec+0x283/0x470 kernel/umh.c:435
 kobject_uevent_env+0x1337/0x1700 lib/kobject_uevent.c:618
 netdev_queue_add_kobject net/core/net-sysfs.c:1621 [inline]
 netdev_queue_update_kobjects+0x1c6/0x400 net/core/net-sysfs.c:1655
 register_queue_kobjects net/core/net-sysfs.c:1716 [inline]
 netdev_register_kobject+0x263/0x310 net/core/net-sysfs.c:1959
 register_netdevice+0x12a1/0x1c20 net/core/dev.c:10349
 register_netdev+0x37/0x50 net/core/dev.c:10473
 sixpack_open+0x5be/0x9e0 drivers/net/hamradio/6pack.c:623
 tty_ldisc_open drivers/tty/tty_ldisc.c:449 [inline]
 tty_set_ldisc+0x530/0x950 drivers/tty/tty_ldisc.c:579
 tiocsetd drivers/tty/tty_io.c:2455 [inline]
 tty_ioctl+0x1394/0x1720 drivers/tty/tty_io.c:2741
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:1069 [inline]
 __se_sys_ioctl+0xfb/0x170 fs/ioctl.c:1055
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

The buggy address belongs to the object at ffff88802a101100
 which belongs to the cache kmalloc-192 of size 192
The buggy address is located 28 bytes inside of
 192-byte region [ffff88802a101100, ffff88802a1011c0)
The buggy address belongs to the page:
page:ffffea0000a84040 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x2a101
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 ffffea00005d2100 0000000900000007 ffff888011041a00
raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x12cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY), pid 8456, ts 148626461315, free_ts 148608362928
 prep_new_page mm/page_alloc.c:2436 [inline]
 get_page_from_freelist+0x779/0xa30 mm/page_alloc.c:4169
 __alloc_pages+0x26c/0x5f0 mm/page_alloc.c:5391
 alloc_slab_page mm/slub.c:1691 [inline]
 allocate_slab+0xf1/0x540 mm/slub.c:1831
 new_slab mm/slub.c:1894 [inline]
 new_slab_objects mm/slub.c:2640 [inline]
 ___slab_alloc+0x1cf/0x350 mm/slub.c:2803
 __slab_alloc mm/slub.c:2843 [inline]
 slab_alloc_node mm/slub.c:2925 [inline]
 slab_alloc mm/slub.c:2967 [inline]
 kmem_cache_alloc_trace+0x29d/0x340 mm/slub.c:2984
 kmalloc include/linux/slab.h:591 [inline]
 netdevice_queue_work drivers/infiniband/core/roce_gid_mgmt.c:643 [inline]
 netdevice_event+0x3af/0x970 drivers/infiniband/core/roce_gid_mgmt.c:802
 notifier_call_chain kernel/notifier.c:83 [inline]
 raw_notifier_call_chain+0xe7/0x170 kernel/notifier.c:410
 __dev_notify_flags+0x306/0x5d0 net/core/dev.c:2123
 dev_change_flags+0xe3/0x190 net/core/dev.c:8898
 do_setlink+0xcbd/0x3f70 net/core/rtnetlink.c:2721
 __rtnl_newlink net/core/rtnetlink.c:3393 [inline]
 rtnl_newlink+0x16e4/0x1cd0 net/core/rtnetlink.c:3508
 rtnetlink_rcv_msg+0x91c/0xe50 net/core/rtnetlink.c:5574
 netlink_rcv_skb+0x1f0/0x460 net/netlink/af_netlink.c:2504
 netlink_unicast_kernel net/netlink/af_netlink.c:1314 [inline]
 netlink_unicast+0x7de/0x9b0 net/netlink/af_netlink.c:1340
 netlink_sendmsg+0x9e7/0xe00 net/netlink/af_netlink.c:1929
 sock_sendmsg_nosec net/socket.c:703 [inline]
 sock_sendmsg net/socket.c:723 [inline]
 __sys_sendto+0x541/0x720 net/socket.c:2019
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1346 [inline]
 free_pcp_prepare+0xc29/0xd20 mm/page_alloc.c:1397
 free_unref_page_prepare mm/page_alloc.c:3332 [inline]
 free_unref_page+0x7e/0x550 mm/page_alloc.c:3411
 free_slab mm/slub.c:1934 [inline]
 discard_slab mm/slub.c:1940 [inline]
 __slab_free+0x5c0/0x6b0 mm/slub.c:3143
 do_slab_free mm/slub.c:3201 [inline]
 ___cache_free+0xfc/0x120 mm/slub.c:3220
 qlist_free_all mm/kasan/quarantine.c:165 [inline]
 kasan_quarantine_reduce+0x151/0x1c0 mm/kasan/quarantine.c:272
 __kasan_slab_alloc+0x2f/0xd0 mm/kasan/common.c:444
 kasan_slab_alloc include/linux/kasan.h:254 [inline]
 slab_post_alloc_hook mm/slab.h:519 [inline]
 slab_alloc_node mm/slub.c:2959 [inline]
 slab_alloc mm/slub.c:2967 [inline]
 kmem_cache_alloc_trace+0x209/0x340 mm/slub.c:2984
 kmalloc include/linux/slab.h:591 [inline]
 kzalloc include/linux/slab.h:721 [inline]
 ipv6_add_addr+0x408/0x1480 net/ipv6/addrconf.c:1083
 add_addr+0x194/0x470 net/ipv6/addrconf.c:3077
 addrconf_notify+0x179f/0x2110 net/ipv6/addrconf.c:3589
 notifier_call_chain kernel/notifier.c:83 [inline]
 raw_notifier_call_chain+0xe7/0x170 kernel/notifier.c:410
 __dev_notify_flags+0x306/0x5d0 net/core/dev.c:2123
 dev_change_flags+0xe3/0x190 net/core/dev.c:8898
 do_setlink+0xcbd/0x3f70 net/core/rtnetlink.c:2721
 __rtnl_newlink net/core/rtnetlink.c:3393 [inline]
 rtnl_newlink+0x16e4/0x1cd0 net/core/rtnetlink.c:3508
 rtnetlink_rcv_msg+0x91c/0xe50 net/core/rtnetlink.c:5574

Memory state around the buggy address:
 ffff88802a101000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88802a101080: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff88802a101100: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                            ^
 ffff88802a101180: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff88802a101200: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (1):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce-smack-root 2021/08/19 19:51 upstream d6d09a694205 b599f2fc .config log report info KASAN: use-after-free Write in _atomic_dec_and_lock_irqsave
* Struck through repros no longer work on HEAD.