================================================================== BUG: KASAN: use-after-free in sock_has_perm security/selinux/hooks.c:4541 [inline] BUG: KASAN: use-after-free in selinux_socket_recvmsg+0x27c/0x2c0 security/selinux/hooks.c:4905 Read of size 8 at addr ffff888022b90480 by task syz-executor.5/30744 CPU: 0 PID: 30744 Comm: syz-executor.5 Not tainted 6.1.0-rc8-syzkaller-00014-g8ed710da2873 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xd1/0x138 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:284 [inline] print_report+0x15e/0x461 mm/kasan/report.c:395 kasan_report+0xbf/0x1f0 mm/kasan/report.c:495 sock_has_perm security/selinux/hooks.c:4541 [inline] selinux_socket_recvmsg+0x27c/0x2c0 security/selinux/hooks.c:4905 security_socket_recvmsg+0x60/0xc0 security/security.c:2236 sock_recvmsg net/socket.c:1011 [inline] ____sys_recvmsg+0x23b/0x610 net/socket.c:2701 ___sys_recvmsg+0xf2/0x180 net/socket.c:2743 do_recvmmsg+0x25e/0x6e0 net/socket.c:2837 __sys_recvmmsg net/socket.c:2916 [inline] __do_sys_recvmmsg net/socket.c:2939 [inline] __se_sys_recvmmsg net/socket.c:2932 [inline] __x64_sys_recvmmsg+0x20f/0x260 net/socket.c:2932 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f372f88c0d9 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 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:00007f373058e168 EFLAGS: 00000246 ORIG_RAX: 000000000000012b RAX: ffffffffffffffda RBX: 00007f372f9ac120 RCX: 00007f372f88c0d9 RDX: 00000000000005dd RSI: 0000000020000540 RDI: 0000000000000004 RBP: 00007f372f8e7ae9 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000040012062 R11: 0000000000000246 R12: 0000000000000000 R13: 00007ffeb990312f R14: 00007f373058e300 R15: 0000000000022000 Allocated by task 30735: kasan_save_stack+0x22/0x40 mm/kasan/common.c:45 kasan_set_track+0x25/0x30 mm/kasan/common.c:52 ____kasan_kmalloc mm/kasan/common.c:371 [inline] ____kasan_kmalloc mm/kasan/common.c:330 [inline] __kasan_kmalloc+0xa3/0xb0 mm/kasan/common.c:380 kasan_kmalloc include/linux/kasan.h:211 [inline] __do_kmalloc_node mm/slab_common.c:955 [inline] __kmalloc+0x5a/0xd0 mm/slab_common.c:968 kmalloc include/linux/slab.h:558 [inline] sk_prot_alloc+0x143/0x290 net/core/sock.c:2030 sk_alloc+0x3a/0x780 net/core/sock.c:2083 nr_create+0xb6/0x5f0 net/netrom/af_netrom.c:433 __sock_create+0x359/0x790 net/socket.c:1515 sock_create net/socket.c:1566 [inline] __sys_socket_create net/socket.c:1603 [inline] __sys_socket_create net/socket.c:1588 [inline] __sys_socket+0x133/0x250 net/socket.c:1636 __do_sys_socket net/socket.c:1649 [inline] __se_sys_socket net/socket.c:1647 [inline] __x64_sys_socket+0x73/0xb0 net/socket.c:1647 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Freed by task 20: kasan_save_stack+0x22/0x40 mm/kasan/common.c:45 kasan_set_track+0x25/0x30 mm/kasan/common.c:52 kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:511 ____kasan_slab_free mm/kasan/common.c:236 [inline] ____kasan_slab_free+0x13b/0x1a0 mm/kasan/common.c:200 kasan_slab_free include/linux/kasan.h:177 [inline] __cache_free mm/slab.c:3389 [inline] __do_kmem_cache_free mm/slab.c:3585 [inline] __kmem_cache_free+0xcd/0x3b0 mm/slab.c:3592 sk_prot_free net/core/sock.c:2066 [inline] __sk_destruct+0x5e4/0x710 net/core/sock.c:2152 sk_destruct net/core/sock.c:2167 [inline] __sk_free+0x175/0x460 net/core/sock.c:2178 sk_free+0x7c/0xa0 net/core/sock.c:2189 sock_put include/net/sock.h:1987 [inline] nr_heartbeat_expiry+0x1d7/0x460 net/netrom/nr_timer.c:148 call_timer_fn+0x1da/0x7c0 kernel/time/timer.c:1474 expire_timers kernel/time/timer.c:1519 [inline] __run_timers.part.0+0x6a2/0xaf0 kernel/time/timer.c:1790 __run_timers kernel/time/timer.c:1768 [inline] run_timer_softirq+0xb7/0x1d0 kernel/time/timer.c:1803 __do_softirq+0x1fb/0xadc kernel/softirq.c:571 The buggy address belongs to the object at ffff888022b90000 which belongs to the cache kmalloc-2k of size 2048 The buggy address is located 1152 bytes inside of 2048-byte region [ffff888022b90000, ffff888022b90800) The buggy address belongs to the physical page: page:ffffea00008ae400 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x22b90 flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000000200 ffffea0000829748 ffffea00009f6088 ffff888012040800 raw: 0000000000000000 ffff888022b90000 0000000100000001 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 0x342220(__GFP_HIGH|__GFP_ATOMIC|__GFP_NOWARN|__GFP_COMP|__GFP_HARDWALL|__GFP_THISNODE), pid 30735, tgid 30732 (syz-executor.5), ts 1667230748684, free_ts 1667205314475 prep_new_page mm/page_alloc.c:2539 [inline] get_page_from_freelist+0x10b5/0x2d50 mm/page_alloc.c:4291 __alloc_pages+0x1cb/0x5b0 mm/page_alloc.c:5558 __alloc_pages_node include/linux/gfp.h:237 [inline] kmem_getpages mm/slab.c:1363 [inline] cache_grow_begin+0x94/0x390 mm/slab.c:2570 cache_alloc_refill+0x27f/0x380 mm/slab.c:2943 ____cache_alloc mm/slab.c:3019 [inline] ____cache_alloc mm/slab.c:3002 [inline] __do_cache_alloc mm/slab.c:3202 [inline] slab_alloc_node mm/slab.c:3250 [inline] __kmem_cache_alloc_node+0x44a/0x510 mm/slab.c:3549 __do_kmalloc_node mm/slab_common.c:954 [inline] __kmalloc+0x4a/0xd0 mm/slab_common.c:968 kmalloc include/linux/slab.h:558 [inline] sk_prot_alloc+0x143/0x290 net/core/sock.c:2030 sk_alloc+0x3a/0x780 net/core/sock.c:2083 nr_create+0xb6/0x5f0 net/netrom/af_netrom.c:433 __sock_create+0x359/0x790 net/socket.c:1515 sock_create net/socket.c:1566 [inline] __sys_socket_create net/socket.c:1603 [inline] __sys_socket_create net/socket.c:1588 [inline] __sys_socket+0x133/0x250 net/socket.c:1636 __do_sys_socket net/socket.c:1649 [inline] __se_sys_socket net/socket.c:1647 [inline] __x64_sys_socket+0x73/0xb0 net/socket.c:1647 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1459 [inline] free_pcp_prepare+0x65c/0xd90 mm/page_alloc.c:1509 free_unref_page_prepare mm/page_alloc.c:3387 [inline] free_unref_page+0x1d/0x4d0 mm/page_alloc.c:3483 __vunmap+0x85d/0xd30 mm/vmalloc.c:2713 free_work+0x5c/0x80 mm/vmalloc.c:97 process_one_work+0x9bf/0x1710 kernel/workqueue.c:2289 worker_thread+0x669/0x1090 kernel/workqueue.c:2436 kthread+0x2e8/0x3a0 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306 Memory state around the buggy address: ffff888022b90380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888022b90400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff888022b90480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888022b90500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888022b90580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================