[syzbot] [bpf?] [net?] KMSAN: uninit-value in bpf_prog_test_run_xdp

13 views
Skip to first unread message

syzbot

unread,
Mar 10, 2024, 5:16:24 AMMar 10
to and...@kernel.org, a...@kernel.org, b...@vger.kernel.org, dan...@iogearbox.net, da...@davemloft.net, edum...@google.com, hao...@google.com, john.fa...@gmail.com, jo...@kernel.org, kps...@kernel.org, ku...@kernel.org, linux-...@vger.kernel.org, marti...@linux.dev, net...@vger.kernel.org, pab...@redhat.com, s...@google.com, so...@kernel.org, syzkall...@googlegroups.com, yongho...@linux.dev
Hello,

syzbot found the following issue on:

HEAD commit: 3aaa8ce7a335 Merge tag 'mm-hotfixes-stable-2024-03-07-16-1..
git tree: upstream
console+strace: https://syzkaller.appspot.com/x/log.txt?x=13e5861e180000
kernel config: https://syzkaller.appspot.com/x/.config?x=f8d2f8f66e9a667a
dashboard link: https://syzkaller.appspot.com/bug?extid=6856926fbb5e9b794e5c
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=10ed8171180000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13b728ae180000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/2a093f1b5a72/disk-3aaa8ce7.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/efa5cb929ca6/vmlinux-3aaa8ce7.xz
kernel image: https://storage.googleapis.com/syzbot-assets/2b0c044e721b/bzImage-3aaa8ce7.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+685692...@syzkaller.appspotmail.com

=====================================================
BUG: KMSAN: uninit-value in bpf_prog_test_run_xdp+0x1758/0x1a30 net/bpf/test_run.c:1277
bpf_prog_test_run_xdp+0x1758/0x1a30 net/bpf/test_run.c:1277
bpf_prog_test_run+0x6af/0xac0 kernel/bpf/syscall.c:4107
__sys_bpf+0x649/0xd60 kernel/bpf/syscall.c:5475
__do_sys_bpf kernel/bpf/syscall.c:5561 [inline]
__se_sys_bpf kernel/bpf/syscall.c:5559 [inline]
__x64_sys_bpf+0xa0/0xe0 kernel/bpf/syscall.c:5559
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xcf/0x1e0 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x63/0x6b

Uninit was stored to memory at:
bpf_test_run+0x515/0xaf0
bpf_prog_test_run_xdp+0xea5/0x1a30 net/bpf/test_run.c:1267
bpf_prog_test_run+0x6af/0xac0 kernel/bpf/syscall.c:4107
__sys_bpf+0x649/0xd60 kernel/bpf/syscall.c:5475
__do_sys_bpf kernel/bpf/syscall.c:5561 [inline]
__se_sys_bpf kernel/bpf/syscall.c:5559 [inline]
__x64_sys_bpf+0xa0/0xe0 kernel/bpf/syscall.c:5559
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xcf/0x1e0 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x63/0x6b

Uninit was stored to memory at:
___bpf_prog_run+0x76dd/0xdb80
__bpf_prog_run512+0xb5/0xe0 kernel/bpf/core.c:2227
bpf_dispatcher_nop_func include/linux/bpf.h:1231 [inline]
__bpf_prog_run include/linux/filter.h:651 [inline]
bpf_prog_run_xdp include/net/xdp.h:514 [inline]
bpf_test_run+0x42d/0xaf0 net/bpf/test_run.c:421
bpf_prog_test_run_xdp+0xea5/0x1a30 net/bpf/test_run.c:1267
bpf_prog_test_run+0x6af/0xac0 kernel/bpf/syscall.c:4107
__sys_bpf+0x649/0xd60 kernel/bpf/syscall.c:5475
__do_sys_bpf kernel/bpf/syscall.c:5561 [inline]
__se_sys_bpf kernel/bpf/syscall.c:5559 [inline]
__x64_sys_bpf+0xa0/0xe0 kernel/bpf/syscall.c:5559
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xcf/0x1e0 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x63/0x6b

Uninit was stored to memory at:
___bpf_prog_run+0x8567/0xdb80
__bpf_prog_run512+0xb5/0xe0 kernel/bpf/core.c:2227
bpf_dispatcher_nop_func include/linux/bpf.h:1231 [inline]
__bpf_prog_run include/linux/filter.h:651 [inline]
bpf_prog_run_xdp include/net/xdp.h:514 [inline]
bpf_test_run+0x42d/0xaf0 net/bpf/test_run.c:421
bpf_prog_test_run_xdp+0xea5/0x1a30 net/bpf/test_run.c:1267
bpf_prog_test_run+0x6af/0xac0 kernel/bpf/syscall.c:4107
__sys_bpf+0x649/0xd60 kernel/bpf/syscall.c:5475
__do_sys_bpf kernel/bpf/syscall.c:5561 [inline]
__se_sys_bpf kernel/bpf/syscall.c:5559 [inline]
__x64_sys_bpf+0xa0/0xe0 kernel/bpf/syscall.c:5559
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xcf/0x1e0 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x63/0x6b

Local variable stack created at:
__bpf_prog_run512+0x45/0xe0 kernel/bpf/core.c:2227
bpf_dispatcher_nop_func include/linux/bpf.h:1231 [inline]
__bpf_prog_run include/linux/filter.h:651 [inline]
bpf_prog_run_xdp include/net/xdp.h:514 [inline]
bpf_test_run+0x42d/0xaf0 net/bpf/test_run.c:421

CPU: 0 PID: 5009 Comm: syz-executor369 Not tainted 6.8.0-rc7-syzkaller-00142-g3aaa8ce7a335 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/25/2024
=====================================================


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

syzbot

unread,
Jul 1, 2024, 6:17:47 AM (3 days ago) Jul 1
to linux-...@vger.kernel.org, syzkall...@googlegroups.com
For archival purposes, forwarding an incoming command email to
linux-...@vger.kernel.org, syzkall...@googlegroups.com.

***

Subject: [syzbot] [bpf?] [net?] KMSAN: uninit-value in bpf_prog_test_run_xdp
Author: wojciech...@infogain.com

#syz test: https://linux.googlesource.com/linux/kernel/git/torvalds/linux e478cf26c556e4ab572ab0ab2306c986901dcd61

---
kernel/bpf/verifier.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 36ef8e96787e..13a9c2e2908a 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -7146,8 +7146,8 @@ static int check_stack_range_initialized(
* reads. However, if raw_mode is not set, we'll do extra
* checks below.
*/
- bounds_check_type = BPF_WRITE;
- clobber = true;
+ clobber = !meta || meta->raw_mode;
+ bounds_check_type = clobber ? BPF_WRITE : BPF_READ;
} else {
bounds_check_type = BPF_READ;
}
@@ -7230,8 +7230,7 @@ static int check_stack_range_initialized(
stype = &state->stack[spi].slot_type[slot % BPF_REG_SIZE];
if (*stype == STACK_MISC)
goto mark;
- if ((*stype == STACK_ZERO) ||
- (*stype == STACK_INVALID && env->allow_uninit_stack)) {
+ if (*stype == STACK_ZERO) {
if (clobber) {
/* helper can write anything into the stack */
*stype = STACK_MISC;
@@ -8748,6 +8747,8 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg,
meta->map_uid = reg->map_uid;
break;
case ARG_PTR_TO_MAP_KEY:
+ /* always mark read access */
+ meta->raw_mode = false;
/* bpf_map_xxx(..., map_ptr, ..., key) call:
* check that [key, key + map->key_size) are within
* stack limits and initialized
@@ -8763,7 +8764,7 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg,
}
err = check_helper_mem_access(env, regno,
meta->map_ptr->key_size, false,
- NULL);
+ meta);
break;
case ARG_PTR_TO_MAP_VALUE:
if (type_may_be_null(arg_type) && register_is_null(reg))
--
2.35.3

syzbot

unread,
Jul 1, 2024, 8:40:04 AM (3 days ago) Jul 1
to linux-...@vger.kernel.org, syzkall...@googlegroups.com, wojciech...@infogain.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KMSAN: uninit-value in bpf_prog_test_run_xdp

=====================================================
BUG: KMSAN: uninit-value in bpf_prog_test_run_xdp+0x175d/0x1a40 net/bpf/test_run.c:1287
bpf_prog_test_run_xdp+0x175d/0x1a40 net/bpf/test_run.c:1287
bpf_prog_test_run+0x6b7/0xad0 kernel/bpf/syscall.c:4240
__sys_bpf+0x6aa/0xd90 kernel/bpf/syscall.c:5649
__do_sys_bpf kernel/bpf/syscall.c:5738 [inline]
__se_sys_bpf kernel/bpf/syscall.c:5736 [inline]
__x64_sys_bpf+0xa0/0xe0 kernel/bpf/syscall.c:5736
do_syscall_64+0xd5/0x1f0
entry_SYSCALL_64_after_hwframe+0x6d/0x75

Uninit was stored to memory at:
bpf_test_run+0x52e/0xc30
bpf_prog_test_run_xdp+0xeaa/0x1a40 net/bpf/test_run.c:1277
bpf_prog_test_run+0x6b7/0xad0 kernel/bpf/syscall.c:4240
__sys_bpf+0x6aa/0xd90 kernel/bpf/syscall.c:5649
__do_sys_bpf kernel/bpf/syscall.c:5738 [inline]
__se_sys_bpf kernel/bpf/syscall.c:5736 [inline]
__x64_sys_bpf+0xa0/0xe0 kernel/bpf/syscall.c:5736
do_syscall_64+0xd5/0x1f0
entry_SYSCALL_64_after_hwframe+0x6d/0x75

Uninit was stored to memory at:
___bpf_prog_run+0x58c4/0xe0f0
__bpf_prog_run512+0xb5/0xe0 kernel/bpf/core.c:2252
bpf_dispatcher_nop_func include/linux/bpf.h:1233 [inline]
__bpf_prog_run include/linux/filter.h:667 [inline]
bpf_prog_run_xdp include/net/xdp.h:514 [inline]
bpf_test_run+0x43e/0xc30 net/bpf/test_run.c:423
bpf_prog_test_run_xdp+0xeaa/0x1a40 net/bpf/test_run.c:1277
bpf_prog_test_run+0x6b7/0xad0 kernel/bpf/syscall.c:4240
__sys_bpf+0x6aa/0xd90 kernel/bpf/syscall.c:5649
__do_sys_bpf kernel/bpf/syscall.c:5738 [inline]
__se_sys_bpf kernel/bpf/syscall.c:5736 [inline]
__x64_sys_bpf+0xa0/0xe0 kernel/bpf/syscall.c:5736
do_syscall_64+0xd5/0x1f0
entry_SYSCALL_64_after_hwframe+0x6d/0x75

Uninit was stored to memory at:
___bpf_prog_run+0x9098/0xe0f0
__bpf_prog_run512+0xb5/0xe0 kernel/bpf/core.c:2252
bpf_dispatcher_nop_func include/linux/bpf.h:1233 [inline]
__bpf_prog_run include/linux/filter.h:667 [inline]
bpf_prog_run_xdp include/net/xdp.h:514 [inline]
bpf_test_run+0x43e/0xc30 net/bpf/test_run.c:423
bpf_prog_test_run_xdp+0xeaa/0x1a40 net/bpf/test_run.c:1277
bpf_prog_test_run+0x6b7/0xad0 kernel/bpf/syscall.c:4240
__sys_bpf+0x6aa/0xd90 kernel/bpf/syscall.c:5649
__do_sys_bpf kernel/bpf/syscall.c:5738 [inline]
__se_sys_bpf kernel/bpf/syscall.c:5736 [inline]
__x64_sys_bpf+0xa0/0xe0 kernel/bpf/syscall.c:5736
do_syscall_64+0xd5/0x1f0
entry_SYSCALL_64_after_hwframe+0x6d/0x75

Local variable stack created at:
__bpf_prog_run512+0x45/0xe0 kernel/bpf/core.c:2252
bpf_dispatcher_nop_func include/linux/bpf.h:1233 [inline]
__bpf_prog_run include/linux/filter.h:667 [inline]
bpf_prog_run_xdp include/net/xdp.h:514 [inline]
bpf_test_run+0x43e/0xc30 net/bpf/test_run.c:423

CPU: 0 PID: 5442 Comm: syz-executor.0 Not tainted 6.9.0-rc1-syzkaller-00257-ge478cf26c556-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024
=====================================================


Tested on:

commit: e478cf26 Merge branch 'bpf-fix-a-couple-of-test-failur..
git tree: https://linux.googlesource.com/linux/kernel/git/torvalds/linux
console output: https://syzkaller.appspot.com/x/log.txt?x=14d7871e980000
kernel config: https://syzkaller.appspot.com/x/.config?x=e2599baf258ef795
dashboard link: https://syzkaller.appspot.com/bug?extid=6856926fbb5e9b794e5c
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=162e5ed1980000

Reply all
Reply to author
Forward
0 new messages