syzbot


KASAN: use-after-free Write in null_skcipher_crypt

Status: fixed on 2022/03/23 23:19
Reported-by: syzbot+93ab2623dcb5c73eda9f@syzkaller.appspotmail.com
Fix commit: 9248694dac20 esp: Fix possible buffer overflow in ESP transformation
First crash: 985d, last: 985d
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Write in null_skcipher_crypt crypto C done 3 944d 1143d 22/28 fixed on 2023/02/24 13:50

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in null_skcipher_crypt+0x14c/0x230 crypto/crypto_null.c:85
Write of size 4096 at addr ffff888169088000 by task syz-executor.3/8205

CPU: 1 PID: 8205 Comm: syz-executor.3 Tainted: G        W         5.10.93-syzkaller-01028-g0347b1658399 #0
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_lvl+0x1e2/0x24b lib/dump_stack.c:118
 print_address_description+0x8d/0x3d0 mm/kasan/report.c:233
 __kasan_report+0x142/0x220 mm/kasan/report.c:419
 kasan_report+0x51/0x70 mm/kasan/report.c:436
 check_region_inline mm/kasan/generic.c:135 [inline]
 kasan_check_range+0x2b6/0x2f0 mm/kasan/generic.c:186
 memcpy+0x44/0x70 mm/kasan/shadow.c:66
 null_skcipher_crypt+0x14c/0x230 crypto/crypto_null.c:85
 crypto_skcipher_encrypt+0xa4/0xe0 crypto/skcipher.c:636
 crypto_authenc_encrypt+0x5a4/0xbd0 crypto/authenc.c:222
 crypto_aead_encrypt+0xa4/0xe0 crypto/aead.c:94
 esp6_output_tail+0xcb0/0x1850 net/ipv6/esp6.c:659
 esp6_output+0x589/0x8d0 net/ipv6/esp6.c:735
 xfrm_output_one net/xfrm/xfrm_output.c:473 [inline]
 xfrm_output_resume+0xe80/0x12b0 net/xfrm/xfrm_output.c:508
 xfrm_output2 net/xfrm/xfrm_output.c:535 [inline]
 xfrm_output+0x32e/0x410 net/xfrm/xfrm_output.c:626
 __xfrm6_output+0x409/0xad0 net/ipv6/xfrm6_output.c:94
 NF_HOOK_COND include/linux/netfilter.h:293 [inline]
 xfrm6_output+0x140/0x300 net/ipv6/xfrm6_output.c:99
 dst_output include/net/dst.h:443 [inline]
 ip6_local_out+0x212/0x490 net/ipv6/output_core.c:161
 ip6_send_skb net/ipv6/ip6_output.c:1937 [inline]
 ip6_push_pending_frames+0x114/0x240 net/ipv6/ip6_output.c:1957
 rawv6_push_pending_frames net/ipv6/raw.c:613 [inline]
 rawv6_sendmsg+0x24f7/0x2cd0 net/ipv6/raw.c:956
 inet_sendmsg+0xa1/0xc0 net/ipv4/af_inet.c:821
 sock_sendmsg_nosec net/socket.c:652 [inline]
 sock_sendmsg net/socket.c:672 [inline]
 ____sys_sendmsg+0x5b9/0x910 net/socket.c:2343
 ___sys_sendmsg net/socket.c:2397 [inline]
 __sys_sendmmsg+0x5ae/0x7f0 net/socket.c:2487
 __do_sys_sendmmsg net/socket.c:2516 [inline]
 __se_sys_sendmmsg net/socket.c:2513 [inline]
 __x64_sys_sendmmsg+0xa0/0xb0 net/socket.c:2513
 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x7f6937df0059
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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f6936f66168 EFLAGS: 00000246 ORIG_RAX: 0000000000000133
RAX: ffffffffffffffda RBX: 00007f6937f02f60 RCX: 00007f6937df0059
RDX: 00000000000002e9 RSI: 0000000020000480 RDI: 0000000000000003
RBP: 00007f6937e4a08d R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007fffb40545cf R14: 00007f6936f66300 R15: 0000000000022000

Allocated by task 7787:
 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:428 [inline]
 __kasan_slab_alloc+0xb2/0xe0 mm/kasan/common.c:461
 kasan_slab_alloc include/linux/kasan.h:259 [inline]
 slab_post_alloc_hook mm/slab.h:583 [inline]
 slab_alloc_node mm/slub.c:2954 [inline]
 slab_alloc mm/slub.c:2962 [inline]
 kmem_cache_alloc+0x1a2/0x380 mm/slub.c:2967
 kmem_cache_alloc_node include/linux/slab.h:423 [inline]
 __alloc_skb+0x7b/0x580 net/core/skbuff.c:199
 alloc_skb include/linux/skbuff.h:1101 [inline]
 __ip6_append_data+0x29aa/0x3d80 net/ipv6/ip6_output.c:1660
 ip6_append_data+0x1ab/0x2d0 net/ipv6/ip6_output.c:1829
 rawv6_sendmsg+0x1e4f/0x2cd0 net/ipv6/raw.c:949
 inet_sendmsg+0xa1/0xc0 net/ipv4/af_inet.c:821
 sock_sendmsg_nosec net/socket.c:652 [inline]
 sock_sendmsg net/socket.c:672 [inline]
 ____sys_sendmsg+0x5b9/0x910 net/socket.c:2343
 ___sys_sendmsg net/socket.c:2397 [inline]
 __sys_sendmmsg+0x5ae/0x7f0 net/socket.c:2487
 __do_sys_sendmmsg net/socket.c:2516 [inline]
 __se_sys_sendmmsg net/socket.c:2513 [inline]
 __x64_sys_sendmmsg+0xa0/0xb0 net/socket.c:2513
 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

The buggy address belongs to the object at ffff888169088000
 which belongs to the cache skbuff_head_cache of size 240
The buggy address is located 0 bytes inside of
 240-byte region [ffff888169088000, ffff8881690880f0)
The buggy address belongs to the page:
page:ffffea0005a42200 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff888169088280 pfn:0x169088
flags: 0x8000000000000200(slab)
raw: 8000000000000200 ffffea00046f5b48 ffffea0004147b88 ffff888107fe2180
raw: ffff888169088280 00000000000c0004 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 0x112cc0(GFP_USER|__GFP_NOWARN|__GFP_NORETRY), pid 7359, ts 2363207542878, free_ts 2363175526908
 set_page_owner include/linux/page_owner.h:35 [inline]
 post_alloc_hook mm/page_alloc.c:2385 [inline]
 prep_new_page mm/page_alloc.c:2391 [inline]
 get_page_from_freelist+0xa74/0xa90 mm/page_alloc.c:4063
 __alloc_pages_nodemask+0x3c8/0x820 mm/page_alloc.c:5106
 alloc_slab_page mm/slub.c:1813 [inline]
 allocate_slab+0x6b/0x350 mm/slub.c:1815
 new_slab mm/slub.c:1876 [inline]
 new_slab_objects mm/slub.c:2635 [inline]
 ___slab_alloc+0x143/0x2f0 mm/slub.c:2798
 __slab_alloc mm/slub.c:2838 [inline]
 slab_alloc_node mm/slub.c:2920 [inline]
 slab_alloc mm/slub.c:2962 [inline]
 kmem_cache_alloc+0x26f/0x380 mm/slub.c:2967
 kmem_cache_alloc_node include/linux/slab.h:423 [inline]
 __alloc_skb+0x7b/0x580 net/core/skbuff.c:199
 alloc_skb include/linux/skbuff.h:1101 [inline]
 __ip6_append_data+0x29aa/0x3d80 net/ipv6/ip6_output.c:1660
 ip6_append_data+0x1ab/0x2d0 net/ipv6/ip6_output.c:1829
 rawv6_sendmsg+0x1e4f/0x2cd0 net/ipv6/raw.c:949
 inet_sendmsg+0xa1/0xc0 net/ipv4/af_inet.c:821
 sock_sendmsg_nosec net/socket.c:652 [inline]
 sock_sendmsg net/socket.c:672 [inline]
 ____sys_sendmsg+0x5b9/0x910 net/socket.c:2343
 ___sys_sendmsg net/socket.c:2397 [inline]
 __sys_sendmmsg+0x5ae/0x7f0 net/socket.c:2487
 __do_sys_sendmmsg net/socket.c:2516 [inline]
 __se_sys_sendmmsg net/socket.c:2513 [inline]
 __x64_sys_sendmmsg+0xa0/0xb0 net/socket.c:2513
 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:28 [inline]
 free_pages_prepare mm/page_alloc.c:1331 [inline]
 free_pcp_prepare+0x18f/0x1c0 mm/page_alloc.c:1405
 free_unref_page_prepare mm/page_alloc.c:3291 [inline]
 free_unref_page mm/page_alloc.c:3341 [inline]
 free_the_page mm/page_alloc.c:5165 [inline]
 __free_pages+0x2e3/0x4a0 mm/page_alloc.c:5173
 __vunmap+0x856/0x980 mm/vmalloc.c:2275
 free_work+0x66/0x90 mm/vmalloc.c:68
 process_one_work+0x6b4/0xfb0 kernel/workqueue.c:2298
 worker_thread+0xb15/0x1600 kernel/workqueue.c:2444
 kthread+0x371/0x390 kernel/kthread.c:313
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:296

Memory state around the buggy address:
 ffff888169087f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff888169087f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff888169088000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff888169088080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc
 ffff888169088100: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2022/01/21 21:20 android12-5.10-lts 0347b1658399 214351e1 .config console log report info ci2-android-5-10 KASAN: use-after-free Write in null_skcipher_crypt
* Struck through repros no longer work on HEAD.