syzbot


KASAN: slab-out-of-bounds Write in bpf_prog_test_run_xdp

Status: fixed on 2023/02/24 13:50
Subsystems: bpf net
[Documentation on labels]
Reported-by: syzbot+6d70ca7438345077c549@syzkaller.appspotmail.com
Fix commit: a6763080856f bpf: test_run: Fix OOB access in bpf_prog_test_run_xdp
First crash: 1049d, last: 1027d
Cause bisection: introduced by (bisect log) :
commit 1c194998252469cad00a08bd9ef0b99fd255c260
Author: Lorenzo Bianconi <lorenzo@kernel.org>
Date: Fri Jan 21 10:09:58 2022 +0000

  bpf: introduce frags support to bpf_prog_test_run_xdp()

Crash: KASAN: slab-out-of-bounds Write in bpf_prog_test_run_xdp (log)
Repro: C syz .config
  
Discussions (2)
Title Replies (including bot) Last reply
[syzbot] KASAN: slab-out-of-bounds Write in bpf_prog_test_run_xdp 4 (7) 2022/02/04 01:47
[PATCH bpf-next] bpf: test_run: fix OOB access in bpf_prog_test_run_xdp 2 (2) 2022/02/03 17:50
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KMSAN: uninit-value in bpf_prog_test_run_xdp bpf net C 4 209d 272d 0/28 auto-obsoleted due to no activity on 2024/08/19 23:24
linux-6.1 BUG: unable to handle kernel paging request in bpf_prog_test_run_xdp 1 389d 389d 0/3 auto-obsoleted due to no activity on 2024/02/21 19:18
Last patch testing requests (2)
Created Duration User Patch Repo Result
2022/09/06 02:27 16m retest repro bpf-next OK log
2022/02/02 17:26 9m lorenzo.bianconi@redhat.com https://github.com/LorenzoBianconi/bpf-next.git skzkaller_bpf_prog_test_run_xdp OK

Sample crash report:
==================================================================
BUG: KASAN: slab-out-of-bounds in __skb_frag_set_page include/linux/skbuff.h:3242 [inline]
BUG: KASAN: slab-out-of-bounds in bpf_prog_test_run_xdp+0x10ac/0x1150 net/bpf/test_run.c:972
Write of size 8 at addr ffff888077551000 by task syz-executor404/3591

CPU: 1 PID: 3591 Comm: syz-executor404 Not tainted 5.17.0-rc1-syzkaller-00550-g000fe940e51f #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 print_address_description.constprop.0.cold+0x8d/0x336 mm/kasan/report.c:255
 __kasan_report mm/kasan/report.c:442 [inline]
 kasan_report.cold+0x83/0xdf mm/kasan/report.c:459
 __skb_frag_set_page include/linux/skbuff.h:3242 [inline]
 bpf_prog_test_run_xdp+0x10ac/0x1150 net/bpf/test_run.c:972
 bpf_prog_test_run kernel/bpf/syscall.c:3356 [inline]
 __sys_bpf+0x1858/0x59a0 kernel/bpf/syscall.c:4658
 __do_sys_bpf kernel/bpf/syscall.c:4744 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:4742 [inline]
 __x64_sys_bpf+0x75/0xb0 kernel/bpf/syscall.c:4742
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7fab0da64229
Code: 28 c3 e8 2a 14 00 00 66 2e 0f 1f 84 00 00 00 00 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 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffcd63b93b8 EFLAGS: 00000246 ORIG_RAX: 0000000000000141
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fab0da64229
RDX: 0000000000000048 RSI: 0000000020000000 RDI: 000000000000000a
RBP: 00007fab0da28210 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007fab0da282a0
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
 </TASK>

Allocated by task 3591:
 kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
 kasan_set_track mm/kasan/common.c:45 [inline]
 set_alloc_info mm/kasan/common.c:436 [inline]
 ____kasan_kmalloc mm/kasan/common.c:515 [inline]
 ____kasan_kmalloc mm/kasan/common.c:474 [inline]
 __kasan_kmalloc+0xa9/0xd0 mm/kasan/common.c:524
 kmalloc include/linux/slab.h:586 [inline]
 kzalloc include/linux/slab.h:715 [inline]
 bpf_test_init.isra.0+0x9f/0x150 net/bpf/test_run.c:411
 bpf_prog_test_run_xdp+0x2f8/0x1150 net/bpf/test_run.c:941
 bpf_prog_test_run kernel/bpf/syscall.c:3356 [inline]
 __sys_bpf+0x1858/0x59a0 kernel/bpf/syscall.c:4658
 __do_sys_bpf kernel/bpf/syscall.c:4744 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:4742 [inline]
 __x64_sys_bpf+0x75/0xb0 kernel/bpf/syscall.c:4742
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

The buggy address belongs to the object at ffff888077550000
 which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 0 bytes to the right of
 4096-byte region [ffff888077550000, ffff888077551000)
The buggy address belongs to the page:
page:ffffea0001dd5400 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x77550
head:ffffea0001dd5400 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 dead000000000122 ffff888010c42140
raw: 0000000000000000 0000000080040004 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 3591, ts 43349371784, free_ts 43330616571
 prep_new_page mm/page_alloc.c:2434 [inline]
 get_page_from_freelist+0xa72/0x2f50 mm/page_alloc.c:4165
 __alloc_pages+0x1b2/0x500 mm/page_alloc.c:5389
 alloc_pages+0x1aa/0x310 mm/mempolicy.c:2271
 alloc_slab_page mm/slub.c:1799 [inline]
 allocate_slab mm/slub.c:1944 [inline]
 new_slab+0x28a/0x3b0 mm/slub.c:2004
 ___slab_alloc+0x87c/0xe90 mm/slub.c:3018
 __slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3105
 slab_alloc_node mm/slub.c:3196 [inline]
 slab_alloc mm/slub.c:3238 [inline]
 __kmalloc+0x2fb/0x340 mm/slub.c:4420
 kmalloc include/linux/slab.h:586 [inline]
 kzalloc include/linux/slab.h:715 [inline]
 bpf_test_init.isra.0+0x9f/0x150 net/bpf/test_run.c:411
 bpf_prog_test_run_xdp+0x2f8/0x1150 net/bpf/test_run.c:941
 bpf_prog_test_run kernel/bpf/syscall.c:3356 [inline]
 __sys_bpf+0x1858/0x59a0 kernel/bpf/syscall.c:4658
 __do_sys_bpf kernel/bpf/syscall.c:4744 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:4742 [inline]
 __x64_sys_bpf+0x75/0xb0 kernel/bpf/syscall.c:4742
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/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:1352 [inline]
 free_pcp_prepare+0x374/0x870 mm/page_alloc.c:1404
 free_unref_page_prepare mm/page_alloc.c:3325 [inline]
 free_unref_page+0x19/0x690 mm/page_alloc.c:3404
 __unfreeze_partials+0x320/0x340 mm/slub.c:2536
 qlink_free mm/kasan/quarantine.c:157 [inline]
 qlist_free_all+0x6d/0x160 mm/kasan/quarantine.c:176
 kasan_quarantine_reduce+0x180/0x200 mm/kasan/quarantine.c:283
 __kasan_slab_alloc+0xa2/0xc0 mm/kasan/common.c:446
 kasan_slab_alloc include/linux/kasan.h:260 [inline]
 slab_post_alloc_hook mm/slab.h:732 [inline]
 slab_alloc_node mm/slub.c:3230 [inline]
 slab_alloc mm/slub.c:3238 [inline]
 kmem_cache_alloc+0x202/0x3a0 mm/slub.c:3243
 getname_flags.part.0+0x50/0x4f0 fs/namei.c:138
 getname_flags+0x9a/0xe0 include/linux/audit.h:323
 user_path_at_empty+0x2b/0x60 fs/namei.c:2850
 user_path_at include/linux/namei.h:57 [inline]
 vfs_statx+0x142/0x390 fs/stat.c:221
 vfs_fstatat fs/stat.c:243 [inline]
 __do_sys_newfstatat+0x96/0x120 fs/stat.c:412
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

Memory state around the buggy address:
 ffff888077550f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff888077550f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff888077551000: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
                   ^
 ffff888077551080: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888077551100: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (18):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2022/02/02 13:12 net-next-old 000fe940e51f 4ebb2798 .config console log report syz C ci-upstream-net-kasan-gce KASAN: slab-out-of-bounds Write in bpf_prog_test_run_xdp
2022/02/02 13:04 bpf-next dd5152ab338c 4ebb2798 .config console log report syz C ci-upstream-bpf-next-kasan-gce KASAN: slab-out-of-bounds Write in bpf_prog_test_run_xdp
2022/02/14 00:47 net-next-old 5a8fb33e5305 8b9ca619 .config console log report info ci-upstream-net-kasan-gce KASAN: slab-out-of-bounds Write in bpf_prog_test_run_xdp
2022/02/12 11:30 net-next-old 5a8fb33e5305 8b9ca619 .config console log report info ci-upstream-net-kasan-gce KASAN: slab-out-of-bounds Write in bpf_prog_test_run_xdp
2022/02/06 08:48 net-next-old 5a8fb33e5305 a7dab638 .config console log report info ci-upstream-net-kasan-gce KASAN: slab-out-of-bounds Write in bpf_prog_test_run_xdp
2022/02/02 07:26 bpf-next 533de4aea6a9 4ebb2798 .config console log report info ci-upstream-bpf-next-kasan-gce KASAN: slab-out-of-bounds Write in bpf_prog_test_run_xdp
2022/02/01 05:50 bpf-next 0407a65f356e 6b7c57fe .config console log report info ci-upstream-bpf-next-kasan-gce KASAN: slab-out-of-bounds Write in bpf_prog_test_run_xdp
2022/02/01 00:02 bpf-next 0407a65f356e 6b7c57fe .config console log report info ci-upstream-bpf-next-kasan-gce KASAN: slab-out-of-bounds Write in bpf_prog_test_run_xdp
2022/01/30 08:02 net-next-old ff58831fa02d 495e00c5 .config console log report info ci-upstream-net-kasan-gce KASAN: slab-out-of-bounds Write in bpf_prog_test_run_xdp
2022/01/28 23:43 net-next-old b76bbb34dc80 495e00c5 .config console log report info ci-upstream-net-kasan-gce KASAN: slab-out-of-bounds Write in bpf_prog_test_run_xdp
2022/01/28 17:06 bpf-next b3dddab2ff10 495e00c5 .config console log report info ci-upstream-bpf-next-kasan-gce KASAN: slab-out-of-bounds Write in bpf_prog_test_run_xdp
2022/01/28 15:02 net-next-old d344e55356c2 495e00c5 .config console log report info ci-upstream-net-kasan-gce KASAN: slab-out-of-bounds Write in bpf_prog_test_run_xdp
2022/01/28 00:41 bpf-next 8033c6c2fed2 64a8e201 .config console log report info ci-upstream-bpf-next-kasan-gce KASAN: slab-out-of-bounds Write in bpf_prog_test_run_xdp
2022/01/27 12:18 bpf-next ff943683f8a6 2cbffd88 .config console log report info ci-upstream-bpf-next-kasan-gce KASAN: slab-out-of-bounds Write in bpf_prog_test_run_xdp
2022/01/27 03:22 bpf-next c446fdacb10d 2cbffd88 .config console log report info ci-upstream-bpf-next-kasan-gce KASAN: slab-out-of-bounds Write in bpf_prog_test_run_xdp
2022/01/25 10:39 bpf-next 74bb0f0c299c 2cbffd88 .config console log report info ci-upstream-bpf-next-kasan-gce KASAN: slab-out-of-bounds Write in bpf_prog_test_run_xdp
2022/01/24 14:43 bpf-next a9921ce1cae5 214351e1 .config console log report info ci-upstream-bpf-next-kasan-gce KASAN: slab-out-of-bounds Write in bpf_prog_test_run_xdp
2022/01/22 14:30 bpf-next a9921ce1cae5 214351e1 .config console log report info ci-upstream-bpf-next-kasan-gce KASAN: slab-out-of-bounds Write in bpf_prog_test_run_xdp
* Struck through repros no longer work on HEAD.