================================================================== BUG: KASAN: slab-out-of-bounds in pfkey_sadb2xfrm_user_sec_ctx net/key/af_key.c:474 [inline] BUG: KASAN: slab-out-of-bounds in pfkey_compile_policy+0x8e6/0xd40 net/key/af_key.c:3306 Read of size 1280 at addr ffff8801ca354658 by task syzkaller883765/3324 CPU: 0 PID: 3324 Comm: syzkaller883765 Not tainted 4.9.71-g2506378 #9 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 ffff8801c927f818 ffffffff81d922b9 ffffea000728d500 ffff8801ca354658 0000000000000000 ffff8801ca354700 ffff8801c89b2200 ffff8801c927f850 ffffffff8153bab3 ffff8801ca354658 0000000000000500 0000000000000000 Call Trace: [] __dump_stack lib/dump_stack.c:15 [inline] [] dump_stack+0xc1/0x128 lib/dump_stack.c:51 [] print_address_description+0x73/0x280 mm/kasan/report.c:252 [] kasan_report_error mm/kasan/report.c:351 [inline] [] kasan_report+0x275/0x360 mm/kasan/report.c:408 [] check_memory_region_inline mm/kasan/kasan.c:318 [inline] [] check_memory_region+0x137/0x190 mm/kasan/kasan.c:325 [] memcpy+0x23/0x50 mm/kasan/kasan.c:360 [] pfkey_sadb2xfrm_user_sec_ctx net/key/af_key.c:474 [inline] [] pfkey_compile_policy+0x8e6/0xd40 net/key/af_key.c:3306 [] xfrm_user_policy+0x2fe/0x530 net/xfrm/xfrm_state.c:1907 [] do_ip_setsockopt.isra.12+0x1977/0x2960 net/ipv4/ip_sockglue.c:1151 [] compat_ip_setsockopt+0x4f/0xf0 net/ipv4/ip_sockglue.c:1269 [] inet_csk_compat_setsockopt+0x95/0x120 net/ipv4/inet_connection_sock.c:914 [] compat_tcp_setsockopt+0x3d/0x70 net/ipv4/tcp.c:2747 [] compat_sock_common_setsockopt+0xb2/0x140 net/core/sock.c:2717 [] C_SYSC_setsockopt net/compat.c:398 [inline] [] compat_SyS_setsockopt+0x149/0x290 net/compat.c:381 [] do_syscall_32_irqs_on arch/x86/entry/common.c:322 [inline] [] do_fast_syscall_32+0x2f7/0x890 arch/x86/entry/common.c:384 [] entry_SYSENTER_compat+0x51/0x60 arch/x86/entry/entry_64_compat.S:124 Allocated by task 3324: save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57 save_stack+0x43/0xd0 mm/kasan/kasan.c:505 set_track mm/kasan/kasan.c:517 [inline] kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:609 __kmalloc+0x11d/0x310 mm/slub.c:3741 kmalloc include/linux/slab.h:495 [inline] xfrm_user_policy+0xc1/0x530 net/xfrm/xfrm_state.c:1896 do_ip_setsockopt.isra.12+0x1977/0x2960 net/ipv4/ip_sockglue.c:1151 compat_ip_setsockopt+0x4f/0xf0 net/ipv4/ip_sockglue.c:1269 inet_csk_compat_setsockopt+0x95/0x120 net/ipv4/inet_connection_sock.c:914 compat_tcp_setsockopt+0x3d/0x70 net/ipv4/tcp.c:2747 compat_sock_common_setsockopt+0xb2/0x140 net/core/sock.c:2717 C_SYSC_setsockopt net/compat.c:398 [inline] compat_SyS_setsockopt+0x149/0x290 net/compat.c:381 do_syscall_32_irqs_on arch/x86/entry/common.c:322 [inline] do_fast_syscall_32+0x2f7/0x890 arch/x86/entry/common.c:384 entry_SYSENTER_compat+0x51/0x60 arch/x86/entry/entry_64_compat.S:124 Freed by task 1798: save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57 save_stack+0x43/0xd0 mm/kasan/kasan.c:505 set_track mm/kasan/kasan.c:517 [inline] kasan_slab_free+0x72/0xc0 mm/kasan/kasan.c:582 slab_free_hook mm/slub.c:1355 [inline] slab_free_freelist_hook mm/slub.c:1377 [inline] slab_free mm/slub.c:2958 [inline] kfree+0x103/0x300 mm/slub.c:3878 seq_release+0x59/0x70 fs/seq_file.c:372 kernfs_fop_release+0xcb/0x140 fs/kernfs/file.c:742 __fput+0x28c/0x6e0 fs/file_table.c:208 ____fput+0x15/0x20 fs/file_table.c:244 task_work_run+0x115/0x190 kernel/task_work.c:116 tracehook_notify_resume include/linux/tracehook.h:191 [inline] exit_to_usermode_loop+0xfc/0x120 arch/x86/entry/common.c:160 prepare_exit_to_usermode arch/x86/entry/common.c:190 [inline] syscall_return_slowpath+0x1a0/0x1e0 arch/x86/entry/common.c:259 entry_SYSCALL_64_fastpath+0xc4/0xc6 The buggy address belongs to the object at ffff8801ca354640 which belongs to the cache kmalloc-256 of size 256 The buggy address is located 24 bytes inside of 256-byte region [ffff8801ca354640, ffff8801ca354740) The buggy address belongs to the page: page:ffffea000728d500 count:1 mapcount:0 mapping: (null) index:0xffff8801ca354dc0 flags: 0x8000000000000080(slab) page dumped because: kasan: bad access detected Memory state around the buggy address: ffff8801ca354600: fc fc fc fc fc fc fc fc 00 00 00 00 00 00 00 00 ffff8801ca354680: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffff8801ca354700: 02 fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ^ ffff8801ca354780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8801ca354800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================