syzbot


KASAN: use-after-free Read in cipso_v4_doi_add

Status: fixed on 2022/03/08 16:11
Subsystems: lsm net
[Documentation on labels]
Reported-by: syzbot+93dba5b91f0fed312cbd@syzkaller.appspotmail.com
Fix commit: 0934ad42bb2c smackfs: use netlbl_cfg_cipsov4_del() for deleting cipso_v4_doi
First crash: 1153d, last: 1153d
Discussions (9)
Title Replies (including bot) Last reply
[PATCH 5.10 000/575] 5.10.80-rc1 review 595 (595) 2022/07/31 10:51
[PATCH 4.19 000/323] 4.19.218-rc1 review 339 (339) 2021/12/04 10:30
[PATCH 4.4 000/162] 4.4.293-rc1 review 168 (168) 2021/11/25 13:11
[PATCH 4.14 000/251] 4.14.256-rc1 review 262 (262) 2021/11/25 13:07
[PATCH 4.9 000/207] 4.9.291-rc1 review 216 (216) 2021/11/25 12:58
[PATCH 5.15 000/917] 5.15.3-rc1 review 945 (945) 2021/11/24 18:04
[PATCH 5.4 000/355] 5.4.160-rc1 review 373 (373) 2021/11/16 16:50
[PATCH 5.14 000/849] 5.14.19-rc1 review 859 (859) 2021/11/16 14:04
[syzbot] KASAN: use-after-free Read in cipso_v4_doi_add 0 (1) 2021/10/19 07:14

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in cipso_v4_doi_search net/ipv4/cipso_ipv4.c:363 [inline]
BUG: KASAN: use-after-free in cipso_v4_doi_add+0x4e0/0x7c0 net/ipv4/cipso_ipv4.c:420
Read of size 4 at addr ffff88803f6a5a00 by task syz-executor.3/14359

CPU: 1 PID: 14359 Comm: syz-executor.3 Not tainted 5.15.0-rc5-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1dc/0x2d8 lib/dump_stack.c:106
 print_address_description+0x66/0x3e0 mm/kasan/report.c:256
 __kasan_report mm/kasan/report.c:442 [inline]
 kasan_report+0x19a/0x1f0 mm/kasan/report.c:459
 cipso_v4_doi_search net/ipv4/cipso_ipv4.c:363 [inline]
 cipso_v4_doi_add+0x4e0/0x7c0 net/ipv4/cipso_ipv4.c:420
 smk_cipso_doi+0x2d3/0x580 security/smack/smackfs.c:706
 smk_write_doi+0x1ab/0x270 security/smack/smackfs.c:1615
 vfs_write+0x327/0xe90 fs/read_write.c:592
 ksys_write+0x18f/0x2c0 fs/read_write.c:647
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7f31447cba39
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 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 bc ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f3141d41188 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f31448cef60 RCX: 00007f31447cba39
RDX: 0000000000000014 RSI: 0000000020000640 RDI: 0000000000000003
RBP: 00007f3144825c5f R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffd5bc3df9f R14: 00007f3141d41300 R15: 0000000000022000

Allocated by task 14339:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:434 [inline]
 ____kasan_kmalloc+0xdc/0x110 mm/kasan/common.c:513
 kasan_kmalloc include/linux/kasan.h:264 [inline]
 kmem_cache_alloc_trace+0x9f/0x310 mm/slub.c:3233
 kmalloc include/linux/slab.h:591 [inline]
 smk_cipso_doi+0x200/0x580 security/smack/smackfs.c:696
 smk_write_doi+0x1ab/0x270 security/smack/smackfs.c:1615
 vfs_write+0x327/0xe90 fs/read_write.c:592
 ksys_write+0x18f/0x2c0 fs/read_write.c:647
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

Freed by task 14339:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4c/0x80 mm/kasan/common.c:46
 kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:360
 ____kasan_slab_free+0x10d/0x150 mm/kasan/common.c:366
 kasan_slab_free include/linux/kasan.h:230 [inline]
 slab_free_hook mm/slub.c:1700 [inline]
 slab_free_freelist_hook+0x129/0x1a0 mm/slub.c:1725
 slab_free mm/slub.c:3483 [inline]
 kfree+0xcf/0x2f0 mm/slub.c:4543
 smk_cipso_doi+0x3b7/0x580
 smk_write_doi+0x1ab/0x270 security/smack/smackfs.c:1615
 vfs_write+0x327/0xe90 fs/read_write.c:592
 ksys_write+0x18f/0x2c0 fs/read_write.c:647
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

The buggy address belongs to the object at ffff88803f6a5a00
 which belongs to the cache kmalloc-64 of size 64
The buggy address is located 0 bytes inside of
 64-byte region [ffff88803f6a5a00, ffff88803f6a5a40)
The buggy address belongs to the page:
page:ffffea0000fda940 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x3f6a5
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 ffffea0000866240 000000170000000d ffff888011041640
raw: 0000000000000000 0000000000200020 00000001ffffffff 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 0x12cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY), pid 6522, ts 209857791495, free_ts 209857731843
 prep_new_page mm/page_alloc.c:2424 [inline]
 get_page_from_freelist+0x779/0xa30 mm/page_alloc.c:4153
 __alloc_pages+0x255/0x580 mm/page_alloc.c:5375
 alloc_slab_page mm/slub.c:1763 [inline]
 allocate_slab+0xcc/0x4d0 mm/slub.c:1900
 new_slab mm/slub.c:1963 [inline]
 ___slab_alloc+0x41e/0xc40 mm/slub.c:2994
 __slab_alloc mm/slub.c:3081 [inline]
 slab_alloc_node mm/slub.c:3172 [inline]
 kmem_cache_alloc_node_trace+0x2c4/0x350 mm/slub.c:3256
 kmalloc_node include/linux/slab.h:609 [inline]
 kzalloc_node include/linux/slab.h:732 [inline]
 __get_vm_area_node+0x13a/0x2f0 mm/vmalloc.c:2416
 __vmalloc_node_range+0xe3/0x890 mm/vmalloc.c:3010
 __vmalloc_node mm/vmalloc.c:3069 [inline]
 vzalloc+0x75/0x80 mm/vmalloc.c:3139
 alloc_counters+0xd2/0x800 net/ipv6/netfilter/ip6_tables.c:817
 copy_entries_to_user net/ipv6/netfilter/ip6_tables.c:839 [inline]
 get_entries net/ipv6/netfilter/ip6_tables.c:1041 [inline]
 do_ip6t_get_ctl+0xf57/0x1f40 net/ipv6/netfilter/ip6_tables.c:1672
 nf_getsockopt+0x2ab/0x2d0 net/netfilter/nf_sockopt.c:116
 ipv6_getsockopt+0x4ae/0x3f30 net/ipv6/ipv6_sockglue.c:1486
 __sys_getsockopt+0x29f/0x560 net/socket.c:2220
 __do_sys_getsockopt net/socket.c:2235 [inline]
 __se_sys_getsockopt net/socket.c:2232 [inline]
 __x64_sys_getsockopt+0xb1/0xc0 net/socket.c:2232
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1338 [inline]
 free_pcp_prepare+0xc29/0xd20 mm/page_alloc.c:1389
 free_unref_page_prepare mm/page_alloc.c:3315 [inline]
 free_unref_page+0x7d/0x580 mm/page_alloc.c:3394
 __vunmap+0x926/0xa70 mm/vmalloc.c:2621
 copy_entries_to_user net/ipv6/netfilter/ip6_tables.c:884 [inline]
 get_entries net/ipv6/netfilter/ip6_tables.c:1041 [inline]
 do_ip6t_get_ctl+0x186d/0x1f40 net/ipv6/netfilter/ip6_tables.c:1672
 nf_getsockopt+0x2ab/0x2d0 net/netfilter/nf_sockopt.c:116
 ipv6_getsockopt+0x4ae/0x3f30 net/ipv6/ipv6_sockglue.c:1486
 __sys_getsockopt+0x29f/0x560 net/socket.c:2220
 __do_sys_getsockopt net/socket.c:2235 [inline]
 __se_sys_getsockopt net/socket.c:2232 [inline]
 __x64_sys_getsockopt+0xb1/0xc0 net/socket.c:2232
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

Memory state around the buggy address:
 ffff88803f6a5900: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff88803f6a5980: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff88803f6a5a00: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
                   ^
 ffff88803f6a5a80: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff88803f6a5b00: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2021/10/15 06:10 upstream 26d657410983 7aa5fe41 .config console log report info ci-upstream-kasan-gce-smack-root KASAN: use-after-free Read in cipso_v4_doi_add
* Struck through repros no longer work on HEAD.