x_tables: ip_tables: osf match: only valid for protocol 6 ====================================================== WARNING: possible circular locking dependency detected 4.14.307-syzkaller #0 Not tainted ------------------------------------------------------ syz-executor.3/9985 is trying to acquire lock: (&bdev->bd_mutex){+.+.}, at: [] blkdev_reread_part+0x1b/0x40 block/ioctl.c:192 but task is already holding lock: (&nbd->config_lock){+.+.}, at: [] nbd_ioctl+0x11f/0xad0 drivers/block/nbd.c:1369 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #2 (&nbd->config_lock){+.+.}: __mutex_lock_common kernel/locking/mutex.c:756 [inline] __mutex_lock+0xc4/0x1310 kernel/locking/mutex.c:893 nbd_open+0x1ac/0x370 drivers/block/nbd.c:1422 __blkdev_get+0x306/0x1090 fs/block_dev.c:1470 blkdev_get+0x88/0x890 fs/block_dev.c:1611 blkdev_open+0x1cc/0x250 fs/block_dev.c:1772 do_dentry_open+0x44b/0xec0 fs/open.c:777 vfs_open+0x105/0x220 fs/open.c:888 do_last fs/namei.c:3428 [inline] path_openat+0x628/0x2970 fs/namei.c:3571 do_filp_open+0x179/0x3c0 fs/namei.c:3605 do_sys_open+0x296/0x410 fs/open.c:1081 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292 entry_SYSCALL_64_after_hwframe+0x5e/0xd3 -> #1 (nbd_index_mutex){+.+.}: __mutex_lock_common kernel/locking/mutex.c:756 [inline] __mutex_lock+0xc4/0x1310 kernel/locking/mutex.c:893 nbd_open+0x1e/0x370 drivers/block/nbd.c:1409 __blkdev_get+0x306/0x1090 fs/block_dev.c:1470 blkdev_get+0x88/0x890 fs/block_dev.c:1611 blkdev_open+0x1cc/0x250 fs/block_dev.c:1772 do_dentry_open+0x44b/0xec0 fs/open.c:777 vfs_open+0x105/0x220 fs/open.c:888 do_last fs/namei.c:3428 [inline] path_openat+0x628/0x2970 fs/namei.c:3571 do_filp_open+0x179/0x3c0 fs/namei.c:3605 do_sys_open+0x296/0x410 fs/open.c:1081 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292 entry_SYSCALL_64_after_hwframe+0x5e/0xd3 -> #0 (&bdev->bd_mutex){+.+.}: lock_acquire+0x170/0x3f0 kernel/locking/lockdep.c:3998 __mutex_lock_common kernel/locking/mutex.c:756 [inline] __mutex_lock+0xc4/0x1310 kernel/locking/mutex.c:893 blkdev_reread_part+0x1b/0x40 block/ioctl.c:192 nbd_bdev_reset drivers/block/nbd.c:1076 [inline] nbd_clear_sock_ioctl drivers/block/nbd.c:1282 [inline] __nbd_ioctl drivers/block/nbd.c:1306 [inline] nbd_ioctl+0x802/0xad0 drivers/block/nbd.c:1376 __blkdev_driver_ioctl block/ioctl.c:297 [inline] blkdev_ioctl+0x540/0x1830 block/ioctl.c:594 block_ioctl+0xd9/0x120 fs/block_dev.c:1893 vfs_ioctl fs/ioctl.c:46 [inline] file_ioctl fs/ioctl.c:500 [inline] do_vfs_ioctl+0x75a/0xff0 fs/ioctl.c:684 SYSC_ioctl fs/ioctl.c:701 [inline] SyS_ioctl+0x7f/0xb0 fs/ioctl.c:692 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292 entry_SYSCALL_64_after_hwframe+0x5e/0xd3 other info that might help us debug this: Chain exists of: &bdev->bd_mutex --> nbd_index_mutex --> &nbd->config_lock Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&nbd->config_lock); lock(nbd_index_mutex); lock(&nbd->config_lock); lock(&bdev->bd_mutex); *** DEADLOCK *** 1 lock held by syz-executor.3/9985: #0: (&nbd->config_lock){+.+.}, at: [] nbd_ioctl+0x11f/0xad0 drivers/block/nbd.c:1369 stack backtrace: CPU: 0 PID: 9985 Comm: syz-executor.3 Not tainted 4.14.307-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023 Call Trace: __dump_stack lib/dump_stack.c:17 [inline] dump_stack+0x1b2/0x281 lib/dump_stack.c:58 print_circular_bug.constprop.0.cold+0x2d7/0x41e kernel/locking/lockdep.c:1258 check_prev_add kernel/locking/lockdep.c:1905 [inline] check_prevs_add kernel/locking/lockdep.c:2022 [inline] validate_chain kernel/locking/lockdep.c:2464 [inline] __lock_acquire+0x2e0e/0x3f20 kernel/locking/lockdep.c:3491 lock_acquire+0x170/0x3f0 kernel/locking/lockdep.c:3998 __mutex_lock_common kernel/locking/mutex.c:756 [inline] __mutex_lock+0xc4/0x1310 kernel/locking/mutex.c:893 blkdev_reread_part+0x1b/0x40 block/ioctl.c:192 nbd_bdev_reset drivers/block/nbd.c:1076 [inline] nbd_clear_sock_ioctl drivers/block/nbd.c:1282 [inline] __nbd_ioctl drivers/block/nbd.c:1306 [inline] nbd_ioctl+0x802/0xad0 drivers/block/nbd.c:1376 __blkdev_driver_ioctl block/ioctl.c:297 [inline] blkdev_ioctl+0x540/0x1830 block/ioctl.c:594 block_ioctl+0xd9/0x120 fs/block_dev.c:1893 vfs_ioctl fs/ioctl.c:46 [inline] file_ioctl fs/ioctl.c:500 [inline] do_vfs_ioctl+0x75a/0xff0 fs/ioctl.c:684 SYSC_ioctl fs/ioctl.c:701 [inline] SyS_ioctl+0x7f/0xb0 fs/ioctl.c:692 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292 entry_SYSCALL_64_after_hwframe+0x5e/0xd3 RIP: 0033:0x7f5d8551c0f9 RSP: 002b:00007f5d83a8e168 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00007f5d8563bf80 RCX: 00007f5d8551c0f9 RDX: 0000000000000000 RSI: 000000000000ab04 RDI: 0000000000000003 RBP: 00007f5d85577ae9 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007fffd9b1937f R14: 00007f5d83a8e300 R15: 0000000000022000 netlink: 36 bytes leftover after parsing attributes in process `syz-executor.5'. caif:caif_disconnect_client(): nothing to disconnect caif:caif_disconnect_client(): nothing to disconnect can: request_module (can-proto-0) failed. can: request_module (can-proto-0) failed. audit: type=1400 audit(1677942501.319:2): apparmor="DENIED" operation="stack_onexec" info="label not found" error=-2 profile="unconfined" name="user" pid=10347 comm="syz-executor.1" ================================================================== BUG: KASAN: slab-out-of-bounds in tipc_nametbl_lookup_dst_nodes+0x44c/0x4c0 net/tipc/name_table.c:670 Read of size 4 at addr ffff88809ef79c10 by task syz-executor.2/10480 CPU: 1 PID: 10480 Comm: syz-executor.2 Not tainted 4.14.307-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023 Call Trace: __dump_stack lib/dump_stack.c:17 [inline] dump_stack+0x1b2/0x281 lib/dump_stack.c:58 print_address_description.cold+0x54/0x1d3 mm/kasan/report.c:251 kasan_report_error.cold+0x8a/0x191 mm/kasan/report.c:350 kasan_report mm/kasan/report.c:408 [inline] __asan_report_load4_noabort+0x68/0x70 mm/kasan/report.c:428 tipc_nametbl_lookup_dst_nodes+0x44c/0x4c0 net/tipc/name_table.c:670 tipc_sendmcast+0x51a/0xac0 net/tipc/socket.c:768 __tipc_sendmsg+0xbab/0xf90 net/tipc/socket.c:975 tipc_sendmsg+0x4c/0x70 net/tipc/socket.c:923 sock_sendmsg_nosec net/socket.c:646 [inline] sock_sendmsg+0xb5/0x100 net/socket.c:656 ___sys_sendmsg+0x6c8/0x800 net/socket.c:2062 __sys_sendmsg+0xa3/0x120 net/socket.c:2096 SYSC_sendmsg net/socket.c:2107 [inline] SyS_sendmsg+0x27/0x40 net/socket.c:2103 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292 entry_SYSCALL_64_after_hwframe+0x5e/0xd3 RIP: 0033:0x7f4f2aa450f9 RSP: 002b:00007f4f28fb7168 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 00007f4f2ab64f80 RCX: 00007f4f2aa450f9 RDX: 0000000000000000 RSI: 0000000020001240 RDI: 0000000000000003 RBP: 00007f4f2aaa0ae9 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007fff17f7267f R14: 00007f4f28fb7300 R15: 0000000000022000 Allocated by task 8045: save_stack mm/kasan/kasan.c:447 [inline] set_track mm/kasan/kasan.c:459 [inline] kasan_kmalloc+0xeb/0x160 mm/kasan/kasan.c:551 __do_kmalloc mm/slab.c:3720 [inline] __kmalloc+0x15a/0x400 mm/slab.c:3729 tipc_nameseq_create+0x53/0x290 net/tipc/name_table.c:152 tipc_nametbl_insert_publ+0xb37/0x14e0 net/tipc/name_table.c:476 tipc_nametbl_publish+0x211/0x3f0 net/tipc/name_table.c:701 tipc_sk_publish net/tipc/socket.c:2206 [inline] tipc_bind+0x2c4/0x600 net/tipc/socket.c:630 tipc_create_listen_sock net/tipc/server.c:338 [inline] tipc_open_listening_sock net/tipc/server.c:396 [inline] tipc_server_start+0x31f/0x880 net/tipc/server.c:611 tipc_topsrv_start net/tipc/subscr.c:382 [inline] tipc_topsrv_init_net+0x53b/0x730 net/tipc/subscr.c:397 ops_init+0xaa/0x3e0 net/core/net_namespace.c:118 setup_net+0x22f/0x530 net/core/net_namespace.c:298 copy_net_ns+0x19b/0x440 net/core/net_namespace.c:422 create_new_namespaces+0x375/0x720 kernel/nsproxy.c:107 unshare_nsproxy_namespaces+0xa1/0x1d0 kernel/nsproxy.c:206 SYSC_unshare kernel/fork.c:2413 [inline] SyS_unshare+0x308/0x7f0 kernel/fork.c:2363 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292 entry_SYSCALL_64_after_hwframe+0x5e/0xd3 Freed by task 6195: save_stack mm/kasan/kasan.c:447 [inline] set_track mm/kasan/kasan.c:459 [inline] kasan_slab_free+0xc3/0x1a0 mm/kasan/kasan.c:524 __cache_free mm/slab.c:3496 [inline] kfree+0xc9/0x250 mm/slab.c:3815 single_release+0x85/0xb0 fs/seq_file.c:609 close_pdeo.part.0+0xdd/0x2c0 fs/proc/inode.c:165 close_pdeo fs/proc/inode.c:382 [inline] proc_reg_release+0x1fd/0x250 fs/proc/inode.c:376 __fput+0x25f/0x7a0 fs/file_table.c:210 task_work_run+0x11f/0x190 kernel/task_work.c:113 tracehook_notify_resume include/linux/tracehook.h:191 [inline] exit_to_usermode_loop+0x1ad/0x200 arch/x86/entry/common.c:164 prepare_exit_to_usermode arch/x86/entry/common.c:199 [inline] syscall_return_slowpath arch/x86/entry/common.c:270 [inline] do_syscall_64+0x4a3/0x640 arch/x86/entry/common.c:297 entry_SYSCALL_64_after_hwframe+0x5e/0xd3 The buggy address belongs to the object at ffff88809ef79c00 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 16 bytes inside of 32-byte region [ffff88809ef79c00, ffff88809ef79c20) The buggy address belongs to the page: page:ffffea00027bde40 count:1 mapcount:0 mapping:ffff88809ef79000 index:0xffff88809ef79fc1 flags: 0xfff00000000100(slab) raw: 00fff00000000100 ffff88809ef79000 ffff88809ef79fc1 0000000100000038 raw: ffffea0002d3b720 ffffea0002793160 ffff88813fe741c0 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff88809ef79b00: 06 fc fc fc fc fc fc fc fb fb fb fb fc fc fc fc ffff88809ef79b80: 06 fc fc fc fc fc fc fc 06 fc fc fc fc fc fc fc >ffff88809ef79c00: 00 00 fc fc fc fc fc fc fb fb fb fb fc fc fc fc ^ ffff88809ef79c80: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc ffff88809ef79d00: fb fb fb fb fc fc fc fc 00 01 fc fc fc fc fc fc ==================================================================