comedi comedi2: c6xdigio: I/O port conflict (0x805,3) ================================================================== BUG: KASAN: slab-use-after-free in sysfs_remove_file_ns+0x63/0x70 fs/sysfs/file.c:510 Read of size 8 at addr ffff88804ead3630 by task syz.1.6698/25912 CPU: 1 UID: 0 PID: 25912 Comm: syz.1.6698 Not tainted syzkaller #0 PREEMPT(full) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014 Call Trace: __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:378 [inline] print_report+0xcd/0x630 mm/kasan/report.c:482 kasan_report+0xe0/0x110 mm/kasan/report.c:595 sysfs_remove_file_ns+0x63/0x70 fs/sysfs/file.c:510 sysfs_remove_file include/linux/sysfs.h:770 [inline] driver_remove_file drivers/base/driver.c:201 [inline] driver_remove_file+0x4a/0x60 drivers/base/driver.c:197 remove_bind_files drivers/base/bus.c:605 [inline] bus_remove_driver+0x224/0x2c0 drivers/base/bus.c:743 driver_unregister+0x76/0xb0 drivers/base/driver.c:277 comedi_device_detach_locked+0x12f/0xa50 drivers/comedi/drivers.c:207 comedi_device_detach+0x67/0xb0 drivers/comedi/drivers.c:215 comedi_device_attach+0x43d/0x900 drivers/comedi/drivers.c:1011 do_devconfig_ioctl+0x1b1/0x710 drivers/comedi/comedi_fops.c:872 comedi_unlocked_ioctl+0x165d/0x2f00 drivers/comedi/comedi_fops.c:2178 comedi_compat_ioctl+0x1d0/0x990 drivers/comedi/comedi_fops.c:3249 __do_compat_sys_ioctl fs/ioctl.c:695 [inline] __se_compat_sys_ioctl fs/ioctl.c:638 [inline] __ia32_compat_sys_ioctl+0x242/0x370 fs/ioctl.c:638 do_syscall_32_irqs_on arch/x86/entry/syscall_32.c:83 [inline] __do_fast_syscall_32+0x7c/0x300 arch/x86/entry/syscall_32.c:306 do_fast_syscall_32+0x32/0x80 arch/x86/entry/syscall_32.c:331 entry_SYSENTER_compat_after_hwframe+0x84/0x8e RIP: 0023:0xf7fa1579 Code: b8 01 10 06 03 74 b4 01 10 07 03 74 b0 01 10 08 03 74 d8 01 00 00 00 00 00 00 00 00 00 00 00 00 00 51 52 55 89 e5 0f 34 cd 80 <5d> 5a 59 c3 90 90 90 90 8d b4 26 00 00 00 00 8d b4 26 00 00 00 00 RSP: 002b:00000000f545455c EFLAGS: 00000296 ORIG_RAX: 0000000000000036 RAX: ffffffffffffffda RBX: 0000000000000008 RCX: 0000000040946400 RDX: 0000000080000140 RSI: 0000000000000000 RDI: 0000000000000000 RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000296 R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 Allocated by task 25429: kasan_save_stack+0x33/0x60 mm/kasan/common.c:56 kasan_save_track+0x14/0x30 mm/kasan/common.c:77 poison_kmalloc_redzone mm/kasan/common.c:400 [inline] __kasan_kmalloc+0xaa/0xb0 mm/kasan/common.c:417 kasan_kmalloc include/linux/kasan.h:262 [inline] __do_kmalloc_node mm/slub.c:5634 [inline] __kmalloc_noprof+0x32f/0x880 mm/slub.c:5646 kmalloc_noprof include/linux/slab.h:961 [inline] kzalloc_noprof include/linux/slab.h:1094 [inline] new_dir fs/proc/proc_sysctl.c:966 [inline] get_subdir fs/proc/proc_sysctl.c:1010 [inline] sysctl_mkdir_p fs/proc/proc_sysctl.c:1320 [inline] __register_sysctl_table+0xea2/0x1900 fs/proc/proc_sysctl.c:1395 __devinet_sysctl_register+0x1b9/0x360 net/ipv4/devinet.c:2677 devinet_sysctl_register net/ipv4/devinet.c:2717 [inline] devinet_sysctl_register+0x17b/0x200 net/ipv4/devinet.c:2707 inetdev_init+0x2b8/0x5a0 net/ipv4/devinet.c:291 inetdev_event+0xc5f/0x18a0 net/ipv4/devinet.c:1590 notifier_call_chain+0xbc/0x410 kernel/notifier.c:85 call_netdevice_notifiers_info+0xbe/0x140 net/core/dev.c:2229 call_netdevice_notifiers_extack net/core/dev.c:2267 [inline] call_netdevice_notifiers net/core/dev.c:2281 [inline] register_netdevice+0x182e/0x2270 net/core/dev.c:11332 tun_set_iff drivers/net/tun.c:2807 [inline] __tun_chr_ioctl+0x1eb6/0x4880 drivers/net/tun.c:3088 __do_compat_sys_ioctl fs/ioctl.c:695 [inline] __se_compat_sys_ioctl fs/ioctl.c:638 [inline] __ia32_compat_sys_ioctl+0x242/0x370 fs/ioctl.c:638 do_syscall_32_irqs_on arch/x86/entry/syscall_32.c:83 [inline] __do_fast_syscall_32+0x7c/0x300 arch/x86/entry/syscall_32.c:306 do_fast_syscall_32+0x32/0x80 arch/x86/entry/syscall_32.c:331 entry_SYSENTER_compat_after_hwframe+0x84/0x8e Freed by task 110: kasan_save_stack+0x33/0x60 mm/kasan/common.c:56 kasan_save_track+0x14/0x30 mm/kasan/common.c:77 __kasan_save_free_info+0x3b/0x60 mm/kasan/generic.c:587 kasan_save_free_info mm/kasan/kasan.h:406 [inline] poison_slab_object mm/kasan/common.c:252 [inline] __kasan_slab_free+0x5f/0x80 mm/kasan/common.c:284 kasan_slab_free include/linux/kasan.h:234 [inline] slab_free_hook mm/slub.c:2530 [inline] slab_free mm/slub.c:6619 [inline] kfree+0x2b8/0x6d0 mm/slub.c:6826 kvfree_rcu_list+0x95/0x120 mm/slab_common.c:1559 kvfree_rcu_drain_ready mm/slab_common.c:1733 [inline] kfree_rcu_monitor+0x21c/0x2f0 mm/slab_common.c:1802 kfree_rcu_shrink_scan+0xdd/0x180 mm/slab_common.c:2153 do_shrink_slab+0x42e/0x1180 mm/shrinker.c:437 shrink_slab+0x32a/0x12b0 mm/shrinker.c:664 shrink_one+0x47a/0x7a0 mm/vmscan.c:4955 shrink_many mm/vmscan.c:5016 [inline] lru_gen_shrink_node mm/vmscan.c:5094 [inline] shrink_node+0x26cb/0x3d80 mm/vmscan.c:6081 kswapd_shrink_node mm/vmscan.c:6941 [inline] balance_pgdat+0xbb8/0x1a50 mm/vmscan.c:7124 kswapd+0x590/0xb90 mm/vmscan.c:7389 kthread+0x3c5/0x780 kernel/kthread.c:463 ret_from_fork+0x675/0x7d0 arch/x86/kernel/process.c:158 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 Last potentially related work creation: kasan_save_stack+0x33/0x60 mm/kasan/common.c:56 kasan_record_aux_stack+0xa7/0xc0 mm/kasan/generic.c:559 kvfree_call_rcu+0x86/0x520 mm/slab_common.c:1995 drop_sysctl_table+0x355/0x5f0 fs/proc/proc_sysctl.c:1521 unregister_sysctl_table fs/proc/proc_sysctl.c:1542 [inline] unregister_sysctl_table+0x41/0x60 fs/proc/proc_sysctl.c:1534 __devinet_sysctl_unregister net/ipv4/devinet.c:2700 [inline] devinet_sysctl_unregister net/ipv4/devinet.c:2728 [inline] inetdev_destroy net/ipv4/devinet.c:334 [inline] inetdev_event+0xeac/0x18a0 net/ipv4/devinet.c:1655 notifier_call_chain+0xbc/0x410 kernel/notifier.c:85 call_netdevice_notifiers_info+0xbe/0x140 net/core/dev.c:2229 call_netdevice_notifiers_extack net/core/dev.c:2267 [inline] call_netdevice_notifiers net/core/dev.c:2281 [inline] unregister_netdevice_many_notify+0xf5c/0x25c0 net/core/dev.c:12284 unregister_netdevice_many net/core/dev.c:12347 [inline] unregister_netdevice_queue+0x305/0x3f0 net/core/dev.c:12161 unregister_netdevice include/linux/netdevice.h:3389 [inline] __tun_detach+0x119c/0x1490 drivers/net/tun.c:621 tun_detach drivers/net/tun.c:637 [inline] tun_chr_close+0xc2/0x230 drivers/net/tun.c:3436 __fput+0x402/0xb70 fs/file_table.c:468 task_work_run+0x150/0x240 kernel/task_work.c:227 resume_user_mode_work include/linux/resume_user_mode.h:50 [inline] exit_to_user_mode_loop+0xec/0x130 kernel/entry/common.c:43 exit_to_user_mode_prepare include/linux/irq-entry-common.h:225 [inline] syscall_exit_to_user_mode_work include/linux/entry-common.h:175 [inline] syscall_exit_to_user_mode include/linux/entry-common.h:210 [inline] __do_fast_syscall_32+0x240/0x300 arch/x86/entry/syscall_32.c:309 do_fast_syscall_32+0x32/0x80 arch/x86/entry/syscall_32.c:331 entry_SYSENTER_compat_after_hwframe+0x84/0x8e The buggy address belongs to the object at ffff88804ead3600 which belongs to the cache kmalloc-256 of size 256 The buggy address is located 48 bytes inside of freed 256-byte region [ffff88804ead3600, ffff88804ead3700) The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0xffff88804ead3600 pfn:0x4ead2 head: order:1 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0 flags: 0x4fff00000000240(workingset|head|node=1|zone=1|lastcpupid=0x7ff) page_type: f5(slab) raw: 04fff00000000240 ffff88801b442b40 ffffea0001c85e10 ffffea00013e8410 raw: ffff88804ead3600 000000000010000b 00000000f5000000 0000000000000000 head: 04fff00000000240 ffff88801b442b40 ffffea0001c85e10 ffffea00013e8410 head: ffff88804ead3600 000000000010000b 00000000f5000000 0000000000000000 head: 04fff00000000001 ffffea00013ab481 00000000ffffffff 00000000ffffffff head: ffffffffffffffff 0000000000000000 00000000ffffffff 0000000000000002 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 1, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 5939, tgid 5939 (syz-executor), ts 56012789743, free_ts 54406547014 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x1c0/0x230 mm/page_alloc.c:1850 prep_new_page mm/page_alloc.c:1858 [inline] get_page_from_freelist+0x10a3/0x3a30 mm/page_alloc.c:3884 __alloc_frozen_pages_noprof+0x25f/0x2470 mm/page_alloc.c:5183 alloc_pages_mpol+0x1fb/0x550 mm/mempolicy.c:2416 alloc_slab_page mm/slub.c:3046 [inline] allocate_slab mm/slub.c:3219 [inline] new_slab+0x24a/0x360 mm/slub.c:3273 ___slab_alloc+0xdc4/0x1ae0 mm/slub.c:4643 __slab_alloc.constprop.0+0x63/0x110 mm/slub.c:4762 __slab_alloc_node mm/slub.c:4838 [inline] slab_alloc_node mm/slub.c:5260 [inline] __do_kmalloc_node mm/slub.c:5633 [inline] __kmalloc_noprof+0x501/0x880 mm/slub.c:5646 kmalloc_noprof include/linux/slab.h:961 [inline] kzalloc_noprof include/linux/slab.h:1094 [inline] fib_create_info+0x53f/0x46b0 net/ipv4/fib_semantics.c:1402 fib_table_insert+0x177/0x1c40 net/ipv4/fib_trie.c:1212 fib_magic+0x4d4/0x5c0 net/ipv4/fib_frontend.c:1134 fib_add_ifaddr+0x4d2/0x580 net/ipv4/fib_frontend.c:1178 fib_netdev_event+0x38a/0x710 net/ipv4/fib_frontend.c:1516 notifier_call_chain+0xbc/0x410 kernel/notifier.c:85 call_netdevice_notifiers_info+0xbe/0x140 net/core/dev.c:2229 call_netdevice_notifiers_extack net/core/dev.c:2267 [inline] call_netdevice_notifiers net/core/dev.c:2281 [inline] __dev_notify_flags+0x12c/0x2e0 net/core/dev.c:9676 page last free pid 5939 tgid 5939 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1394 [inline] __free_frozen_pages+0x7df/0x1160 mm/page_alloc.c:2906 qlink_free mm/kasan/quarantine.c:163 [inline] qlist_free_all+0x4d/0x120 mm/kasan/quarantine.c:179 kasan_quarantine_reduce+0x195/0x1e0 mm/kasan/quarantine.c:286 __kasan_slab_alloc+0x69/0x90 mm/kasan/common.c:352 kasan_slab_alloc include/linux/kasan.h:252 [inline] slab_post_alloc_hook mm/slub.c:4962 [inline] slab_alloc_node mm/slub.c:5272 [inline] __kmalloc_cache_noprof+0x274/0x780 mm/slub.c:5750 kmalloc_noprof include/linux/slab.h:957 [inline] kzalloc_noprof include/linux/slab.h:1094 [inline] kobject_uevent_env+0x265/0x1870 lib/kobject_uevent.c:540 __kobject_del+0x168/0x1f0 lib/kobject.c:601 kobject_cleanup lib/kobject.c:680 [inline] kobject_release lib/kobject.c:720 [inline] kref_put include/linux/kref.h:65 [inline] kobject_put+0x327/0x5a0 lib/kobject.c:737 netdev_queue_update_kobjects+0x4e5/0x720 net/core/net-sysfs.c:2073 netif_set_real_num_tx_queues+0x151/0x870 net/core/dev.c:3183 veth_init_queues+0xe1/0x190 drivers/net/veth.c:1793 veth_newlink+0x4a3/0xa00 drivers/net/veth.c:1896 rtnl_newlink_create net/core/rtnetlink.c:3833 [inline] __rtnl_newlink net/core/rtnetlink.c:3950 [inline] rtnl_newlink+0xc45/0x2000 net/core/rtnetlink.c:4065 rtnetlink_rcv_msg+0x95e/0xe90 net/core/rtnetlink.c:6951 netlink_rcv_skb+0x158/0x420 net/netlink/af_netlink.c:2552 netlink_unicast_kernel net/netlink/af_netlink.c:1320 [inline] netlink_unicast+0x5aa/0x870 net/netlink/af_netlink.c:1346 Memory state around the buggy address: ffff88804ead3500: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88804ead3580: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff88804ead3600: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88804ead3680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88804ead3700: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ================================================================== ---------------- Code disassembly (best guess), 2 bytes skipped: 0: 10 06 adc %al,(%rsi) 2: 03 74 b4 01 add 0x1(%rsp,%rsi,4),%esi 6: 10 07 adc %al,(%rdi) 8: 03 74 b0 01 add 0x1(%rax,%rsi,4),%esi c: 10 08 adc %cl,(%rax) e: 03 74 d8 01 add 0x1(%rax,%rbx,8),%esi 1e: 00 51 52 add %dl,0x52(%rcx) 21: 55 push %rbp 22: 89 e5 mov %esp,%ebp 24: 0f 34 sysenter 26: cd 80 int $0x80 * 28: 5d pop %rbp <-- trapping instruction 29: 5a pop %rdx 2a: 59 pop %rcx 2b: c3 ret 2c: 90 nop 2d: 90 nop 2e: 90 nop 2f: 90 nop 30: 8d b4 26 00 00 00 00 lea 0x0(%rsi,%riz,1),%esi 37: 8d b4 26 00 00 00 00 lea 0x0(%rsi,%riz,1),%esi