syzbot


KASAN: use-after-free Write in __xfrm_policy_unlink (2)

Status: fixed on 2019/09/02 04:08
Subsystems: net
[Documentation on labels]
Reported-by: syzbot+0025447b4cb6f208558f@syzkaller.appspotmail.com
Fix commit: b805d78d300b xfrm: policy: Fix out-of-bound array accesses in __xfrm_policy_unlink
First crash: 1859d, last: 1760d
Discussions (3)
Title Replies (including bot) Last reply
KASAN: use-after-free Write in __xfrm_policy_unlink (2) 1 (2) 2019/09/02 03:31
Reminder: 26 open syzbot bugs in "net/xfrm" subsystem 1 (1) 2019/07/24 01:42
Reminder: 27 open syzbot bugs in "net/xfrm" subsystem 1 (1) 2019/06/25 05:51
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Write in __xfrm_policy_unlink net C 254 1880d 2108d 11/26 fixed on 2019/03/06 07:43

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in __write_once_size include/linux/compiler.h:221 [inline]
BUG: KASAN: use-after-free in __hlist_del include/linux/list.h:748 [inline]
BUG: KASAN: use-after-free in hlist_del_rcu include/linux/rculist.h:455 [inline]
BUG: KASAN: use-after-free in __xfrm_policy_unlink+0x4b1/0x5c0 net/xfrm/xfrm_policy.c:2217
Write of size 8 at addr ffff8880a0276f80 by task syz-executor.0/11484

CPU: 1 PID: 11484 Comm: syz-executor.0 Not tainted 5.2.0-rc6+ #51
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x172/0x1f0 lib/dump_stack.c:113
 print_address_description.cold+0x7c/0x20d mm/kasan/report.c:188
 __kasan_report.cold+0x1b/0x40 mm/kasan/report.c:317
 kasan_report+0x12/0x20 mm/kasan/common.c:614
 __asan_report_store8_noabort+0x17/0x20 mm/kasan/generic_report.c:137
 __write_once_size include/linux/compiler.h:221 [inline]
 __hlist_del include/linux/list.h:748 [inline]
 hlist_del_rcu include/linux/rculist.h:455 [inline]
 __xfrm_policy_unlink+0x4b1/0x5c0 net/xfrm/xfrm_policy.c:2217
 xfrm_policy_flush+0x331/0x460 net/xfrm/xfrm_policy.c:1794
 pfkey_spdflush+0xb0/0x290 net/key/af_key.c:2771
 pfkey_process+0x6cf/0x810 net/key/af_key.c:2830
 pfkey_sendmsg+0x40b/0xbe0 net/key/af_key.c:3669
 sock_sendmsg_nosec net/socket.c:646 [inline]
 sock_sendmsg+0xd7/0x130 net/socket.c:665
 ___sys_sendmsg+0x3e2/0x920 net/socket.c:2286
 __sys_sendmmsg+0x1bf/0x4d0 net/socket.c:2381
 __do_sys_sendmmsg net/socket.c:2410 [inline]
 __se_sys_sendmmsg net/socket.c:2407 [inline]
 __x64_sys_sendmmsg+0x9d/0x100 net/socket.c:2407
 do_syscall_64+0xfd/0x680 arch/x86/entry/common.c:301
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x459519
Code: fd b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 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 0f 83 cb b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f09c0e68c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000133
RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 0000000000459519
RDX: 0400000000000002 RSI: 0000000020000180 RDI: 0000000000000004
RBP: 000000000075bf20 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f09c0e696d4
R13: 00000000004c6af9 R14: 00000000004dbd80 R15: 00000000ffffffff

Allocated by task 6248:
 save_stack+0x23/0x90 mm/kasan/common.c:71
 set_track mm/kasan/common.c:79 [inline]
 __kasan_kmalloc mm/kasan/common.c:489 [inline]
 __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:462
 kasan_kmalloc+0x9/0x10 mm/kasan/common.c:503
 __do_kmalloc mm/slab.c:3660 [inline]
 __kmalloc+0x15c/0x740 mm/slab.c:3669
 kmalloc include/linux/slab.h:552 [inline]
 kzalloc include/linux/slab.h:742 [inline]
 tomoyo_encode2.part.0+0xf5/0x400 security/tomoyo/realpath.c:44
 tomoyo_encode2 security/tomoyo/realpath.c:30 [inline]
 tomoyo_encode+0x2b/0x50 security/tomoyo/realpath.c:79
 tomoyo_realpath_from_path+0x1d3/0x7a0 security/tomoyo/realpath.c:316
 tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
 tomoyo_check_open_permission+0x2a8/0x3f0 security/tomoyo/file.c:771
 tomoyo_file_open security/tomoyo/tomoyo.c:319 [inline]
 tomoyo_file_open+0xa9/0xd0 security/tomoyo/tomoyo.c:314
 security_file_open+0x71/0x300 security/security.c:1454
 do_dentry_open+0x373/0x1250 fs/open.c:765
 vfs_open+0xa0/0xd0 fs/open.c:887
 do_last fs/namei.c:3416 [inline]
 path_openat+0x10e9/0x46d0 fs/namei.c:3533
 do_filp_open+0x1a1/0x280 fs/namei.c:3563
 do_sys_open+0x3fe/0x5d0 fs/open.c:1070
 __do_sys_open fs/open.c:1088 [inline]
 __se_sys_open fs/open.c:1083 [inline]
 __x64_sys_open+0x7e/0xc0 fs/open.c:1083
 do_syscall_64+0xfd/0x680 arch/x86/entry/common.c:301
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 6248:
 save_stack+0x23/0x90 mm/kasan/common.c:71
 set_track mm/kasan/common.c:79 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/common.c:451
 kasan_slab_free+0xe/0x10 mm/kasan/common.c:459
 __cache_free mm/slab.c:3432 [inline]
 kfree+0xcf/0x220 mm/slab.c:3755
 tomoyo_check_open_permission+0x19e/0x3f0 security/tomoyo/file.c:786
 tomoyo_file_open security/tomoyo/tomoyo.c:319 [inline]
 tomoyo_file_open+0xa9/0xd0 security/tomoyo/tomoyo.c:314
 security_file_open+0x71/0x300 security/security.c:1454
 do_dentry_open+0x373/0x1250 fs/open.c:765
 vfs_open+0xa0/0xd0 fs/open.c:887
 do_last fs/namei.c:3416 [inline]
 path_openat+0x10e9/0x46d0 fs/namei.c:3533
 do_filp_open+0x1a1/0x280 fs/namei.c:3563
 do_sys_open+0x3fe/0x5d0 fs/open.c:1070
 __do_sys_open fs/open.c:1088 [inline]
 __se_sys_open fs/open.c:1083 [inline]
 __x64_sys_open+0x7e/0xc0 fs/open.c:1083
 do_syscall_64+0xfd/0x680 arch/x86/entry/common.c:301
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8880a0276f80
 which belongs to the cache kmalloc-64 of size 64
The buggy address is located 0 bytes inside of
 64-byte region [ffff8880a0276f80, ffff8880a0276fc0)
The buggy address belongs to the page:
page:ffffea0002809d80 refcount:1 mapcount:0 mapping:ffff8880aa400340 index:0xffff8880a0276f80
flags: 0x1fffc0000000200(slab)
raw: 01fffc0000000200 ffffea0002266688 ffffea0002224d08 ffff8880aa400340
raw: ffff8880a0276f80 ffff8880a0276000 000000010000001e 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880a0276e80: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
 ffff8880a0276f00: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
>ffff8880a0276f80: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
                   ^
 ffff8880a0277000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff8880a0277080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================

Crashes (7):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/07/01 09:05 net-next-old 954a5a029472 699d6448 .config console log report ci-upstream-net-kasan-gce
2019/06/29 11:40 net-next-old ee7dd7733b20 7509bf36 .config console log report ci-upstream-net-kasan-gce
2019/06/27 22:44 net-next-old 8b89d8dad5df 7509bf36 .config console log report ci-upstream-net-kasan-gce
2019/06/26 19:22 net-next-old 177d935a1370 7509bf36 .config console log report ci-upstream-net-kasan-gce
2019/06/26 08:36 net-next-old 045df37e743c 0a8d1a96 .config console log report ci-upstream-net-kasan-gce
2019/05/13 03:14 net-next-old b970afcfcabd 5f302c04 .config console log report ci-upstream-net-kasan-gce
2019/03/24 05:14 net-next-old 3b0f31f2b8c9 a2cef203 .config console log report ci-upstream-net-kasan-gce
* Struck through repros no longer work on HEAD.