syzbot


KASAN: use-after-free Read in netlbl_catmap_walk

Status: fixed on 2022/03/08 16:11
Subsystems: net lsm
[Documentation on labels]
Reported-by: syzbot+3f91de0b813cc3d19a80@syzkaller.appspotmail.com
Fix commit: 0817534ff9ea smackfs: Fix use-after-free in netlbl_catmap_walk()
First crash: 1205d, last: 1205d
Cause bisection: the issue happens on the oldest tested release (bisect log)
Crash: KASAN: use-after-free Read in _netlbl_catmap_getnode (log)
Repro: C syz .config
  
Discussions (18)
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
[PATCH AUTOSEL 5.15 001/146] dma-buf: WARN on dmabuf release with pending attachments 52 (52) 2021/11/14 14:25
[PATCH AUTOSEL 5.10 001/101] dma-buf: WARN on dmabuf release with pending attachments 37 (37) 2021/11/14 14:16
[PATCH AUTOSEL 4.19 01/47] drm: panel-orientation-quirks: Add quirk for KD Kurio Smart C15200 2-in-1 51 (51) 2021/11/14 14:13
[PATCH AUTOSEL 4.14 01/39] Bluetooth: sco: Fix lock_sock() blockage by memcpy_from_msg() 41 (41) 2021/11/14 14:03
[PATCH AUTOSEL 4.4 01/30] Bluetooth: sco: Fix lock_sock() blockage by memcpy_from_msg() 33 (33) 2021/11/10 15:52
[PATCH AUTOSEL 4.9 01/33] Bluetooth: sco: Fix lock_sock() blockage by memcpy_from_msg() 33 (33) 2021/11/09 01:08
[PATCH AUTOSEL 5.4 01/74] dma-buf: WARN on dmabuf release with pending attachments 26 (26) 2021/11/08 17:48
[PATCH AUTOSEL 5.14 001/138] dma-buf: WARN on dmabuf release with pending attachments 45 (45) 2021/11/08 17:45
[PATCH] smackfs: Fix use-after-free in netlbl_catmap_walk() 1 (1) 2021/09/01 23:18
[syzbot] KASAN: use-after-free Read in netlbl_catmap_walk 2 (3) 2021/08/25 18:41
Last patch testing requests (2)
Created Duration User Patch Repo Result
2021/09/03 03:34 36m pawan.kumar.gupta@linux.intel.com https://github.com/pa1gupta/linux.git smack OK
2021/09/03 01:03 45m pawan.kumar.gupta@linux.intel.com git://github.com/pa1gupta/linux.git smack OK

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in _netlbl_catmap_getnode net/netlabel/netlabel_kapi.c:564 [inline]
BUG: KASAN: use-after-free in netlbl_catmap_walk+0x28b/0x2e0 net/netlabel/netlabel_kapi.c:615
Read of size 4 at addr ffff8880161c9800 by task syz-executor742/8768

CPU: 0 PID: 8768 Comm: syz-executor742 Not tainted 5.14.0-rc7-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+0x1ae/0x29f lib/dump_stack.c:105
 print_address_description+0x66/0x3b0 mm/kasan/report.c:233
 __kasan_report mm/kasan/report.c:419 [inline]
 kasan_report+0x163/0x210 mm/kasan/report.c:436
 _netlbl_catmap_getnode net/netlabel/netlabel_kapi.c:564 [inline]
 netlbl_catmap_walk+0x28b/0x2e0 net/netlabel/netlabel_kapi.c:615
 cipso_seq_show+0x15f/0x280 security/smack/smackfs.c:789
 traverse+0x1dc/0x530 fs/seq_file.c:111
 seq_lseek+0x12b/0x240 fs/seq_file.c:323
 vfs_llseek fs/read_write.c:300 [inline]
 ksys_lseek fs/read_write.c:313 [inline]
 __do_sys_lseek fs/read_write.c:324 [inline]
 __se_sys_lseek fs/read_write.c:322 [inline]
 __x64_sys_lseek+0x15b/0x1e0 fs/read_write.c:322
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x445889
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 11 15 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:00007f9a9cff0318 EFLAGS: 00000246 ORIG_RAX: 0000000000000008
RAX: ffffffffffffffda RBX: 00000000004ca408 RCX: 0000000000445889
RDX: 0000000000000000 RSI: 0000000100000001 RDI: 0000000000000003
RBP: 00000000004ca400 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000004ca40c
R13: 00007ffead4e31bf R14: 00007f9a9cff0400 R15: 0000000000022000

Allocated by task 8768:
 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+0xcd/0x100 mm/kasan/common.c:513
 kasan_kmalloc include/linux/kasan.h:264 [inline]
 kmem_cache_alloc_trace+0x96/0x340 mm/slub.c:2986
 kmalloc include/linux/slab.h:591 [inline]
 kzalloc include/linux/slab.h:721 [inline]
 netlbl_catmap_alloc include/net/netlabel.h:317 [inline]
 _netlbl_catmap_getnode net/netlabel/netlabel_kapi.c:582 [inline]
 netlbl_catmap_setbit+0x1cb/0x3f0 net/netlabel/netlabel_kapi.c:782
 smk_netlbl_mls+0x103/0x5e0 security/smack/smack_access.c:505
 smk_set_cipso+0x621/0x810 security/smack/smackfs.c:921
 vfs_write+0x289/0xc90 fs/read_write.c:603
 ksys_write+0x171/0x2a0 fs/read_write.c:658
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

Freed by task 8769:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x3d/0x70 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:1628 [inline]
 slab_free_freelist_hook+0x1e8/0x2a0 mm/slub.c:1653
 slab_free mm/slub.c:3213 [inline]
 kfree+0xcf/0x2e0 mm/slub.c:4267
 netlbl_catmap_free include/net/netlabel.h:335 [inline]
 smk_set_cipso+0x682/0x810 security/smack/smackfs.c:923
 vfs_write+0x289/0xc90 fs/read_write.c:603
 ksys_write+0x171/0x2a0 fs/read_write.c:658
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

The buggy address belongs to the object at ffff8880161c9800
 which belongs to the cache kmalloc-64 of size 64
The buggy address is located 0 bytes inside of
 64-byte region [ffff8880161c9800, ffff8880161c9840)
The buggy address belongs to the page:
page:ffffea0000587240 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x161c9
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 0000000000000000 0000000b00000001 ffff888011041640
raw: 0000000000000000 0000000080200020 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 6484, ts 27339779214, free_ts 27310944203
 prep_new_page mm/page_alloc.c:2436 [inline]
 get_page_from_freelist+0x779/0xa30 mm/page_alloc.c:4168
 __alloc_pages+0x26c/0x5f0 mm/page_alloc.c:5390
 alloc_slab_page mm/slub.c:1691 [inline]
 allocate_slab+0xf1/0x540 mm/slub.c:1831
 new_slab mm/slub.c:1894 [inline]
 new_slab_objects mm/slub.c:2640 [inline]
 ___slab_alloc+0x1cf/0x350 mm/slub.c:2803
 __slab_alloc mm/slub.c:2843 [inline]
 slab_alloc_node mm/slub.c:2925 [inline]
 __kmalloc_node+0x310/0x430 mm/slub.c:4159
 kmalloc_node include/linux/slab.h:614 [inline]
 kvmalloc_node+0x81/0xf0 mm/util.c:587
 kvmalloc include/linux/mm.h:806 [inline]
 simple_xattr_alloc+0x3f/0xa0 fs/xattr.c:951
 shmem_initxattrs+0x91/0x1e0 mm/shmem.c:3142
 security_inode_init_security+0x37a/0x3c0 security/security.c:1099
 shmem_mknod+0xb0/0x1b0 mm/shmem.c:2822
 lookup_open fs/namei.c:3228 [inline]
 open_last_lookups fs/namei.c:3298 [inline]
 path_openat+0x13b7/0x36b0 fs/namei.c:3504
 do_filp_open+0x253/0x4d0 fs/namei.c:3534
 do_sys_openat2+0x124/0x460 fs/open.c:1204
 do_sys_open fs/open.c:1220 [inline]
 __do_sys_open fs/open.c:1228 [inline]
 __se_sys_open fs/open.c:1224 [inline]
 __x64_sys_open+0x221/0x270 fs/open.c:1224
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 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:1346 [inline]
 free_pcp_prepare+0xc29/0xd20 mm/page_alloc.c:1397
 free_unref_page_prepare mm/page_alloc.c:3332 [inline]
 free_unref_page+0x7e/0x550 mm/page_alloc.c:3411
 __vunmap+0x926/0xa70 mm/vmalloc.c:2587
 free_work+0x66/0x90 mm/vmalloc.c:82
 process_one_work+0x833/0x10c0 kernel/workqueue.c:2276
 worker_thread+0xac1/0x1320 kernel/workqueue.c:2422
 kthread+0x453/0x480 kernel/kthread.c:319
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

Memory state around the buggy address:
 ffff8880161c9700: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
 ffff8880161c9780: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff8880161c9800: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
                   ^
 ffff8880161c9880: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff8880161c9900: fb 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/08/25 14:11 upstream 6e764bcd1cf7 b599f2fc .config console log report syz C ci-upstream-kasan-gce-smack-root KASAN: use-after-free Read in netlbl_catmap_walk
* Struck through repros no longer work on HEAD.