[syzbot] KMSAN: uninit-value in bpf_prog_run_generic_xdp

20 views
Skip to first unread message

syzbot

unread,
Nov 18, 2022, 6:39:44ā€ÆAM11/18/22
to ben-...@fluff.org, b...@alien8.de, daniel....@linux.intel.com, dave....@linux.intel.com, gli...@google.com, h...@zytor.com, linux-...@vger.kernel.org, mi...@redhat.com, pbon...@redhat.com, sathyanarayan...@linux.intel.com, syzkall...@googlegroups.com, tg...@linutronix.de, x...@kernel.org
Hello,

syzbot found the following issue on:

HEAD commit: cb231e2f67ec fs: more fsdata fixes
git tree: https://github.com/google/kmsan.git master
console output: https://syzkaller.appspot.com/x/log.txt?x=14ef6401880000
kernel config: https://syzkaller.appspot.com/x/.config?x=dc6d7125db95a828
dashboard link: https://syzkaller.appspot.com/bug?extid=0e6ddb1ef80986bdfe64
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project.git 610139d2d9ce6746b3c617fb3e2f7886272d26ff), GNU ld (GNU Binutils for Debian) 2.35.2
userspace arch: i386

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/6eabbc575a06/disk-cb231e2f.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/01e99c04e1d7/vmlinux-cb231e2f.xz
kernel image: https://storage.googleapis.com/syzbot-assets/67893482166a/bzImage-cb231e2f.xz

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

=====================================================
BUG: KMSAN: uninit-value in bpf_prog_run_generic_xdp+0x13ff/0x1a30 net/core/dev.c:4782
bpf_prog_run_generic_xdp+0x13ff/0x1a30 net/core/dev.c:4782
netif_receive_generic_xdp+0x639/0x910 net/core/dev.c:4845
do_xdp_generic net/core/dev.c:4904 [inline]
__netif_receive_skb_core+0x290f/0x6360 net/core/dev.c:5310
__netif_receive_skb_one_core net/core/dev.c:5487 [inline]
__netif_receive_skb+0xc8/0x5d0 net/core/dev.c:5603
process_backlog+0x45a/0x890 net/core/dev.c:5931
__napi_poll+0xe6/0x920 net/core/dev.c:6498
napi_poll net/core/dev.c:6565 [inline]
net_rx_action+0x9e8/0x1a20 net/core/dev.c:6676
__do_softirq+0x1c5/0x7b9 kernel/softirq.c:571
invoke_softirq+0x8f/0x100 kernel/softirq.c:445
__irq_exit_rcu+0x5a/0x110 kernel/softirq.c:650
irq_exit_rcu+0xe/0x10 kernel/softirq.c:662
sysvec_apic_timer_interrupt+0x9a/0xc0 arch/x86/kernel/apic/apic.c:1107
asm_sysvec_apic_timer_interrupt+0x1b/0x20 arch/x86/include/asm/idtentry.h:649
kmsan_get_shadow_origin_ptr+0x34/0xa0 mm/kmsan/shadow.c:97
get_shadow_origin_ptr mm/kmsan/instrumentation.c:36 [inline]
__msan_metadata_ptr_for_load_8+0x20/0x30 mm/kmsan/instrumentation.c:78
unwind_get_return_address_ptr+0x97/0xc0 arch/x86/kernel/unwind_frame.c:28
update_stack_state+0x177/0x1e0 arch/x86/kernel/unwind_frame.c:251
unwind_next_frame+0x119/0x360 arch/x86/kernel/unwind_frame.c:315
arch_stack_walk+0x1b9/0x280 arch/x86/kernel/stacktrace.c:25
stack_trace_save+0xb2/0x100 kernel/stacktrace.c:122
kmsan_save_stack_with_flags mm/kmsan/core.c:75 [inline]
kmsan_internal_poison_memory+0x45/0x90 mm/kmsan/core.c:60
kmsan_slab_free+0xcd/0x130 mm/kmsan/hooks.c:90
slab_free_hook mm/slub.c:1694 [inline]
slab_free_freelist_hook mm/slub.c:1750 [inline]
slab_free mm/slub.c:3661 [inline]
kmem_cache_free+0x365/0xdb0 mm/slub.c:3683
security_file_free+0x15d/0x1a0 security/security.c:1548
file_free fs/file_table.c:56 [inline]
__fput+0xbed/0xea0 fs/file_table.c:333
____fput+0x1a/0x20 fs/file_table.c:348
task_work_run+0x229/0x2c0 kernel/task_work.c:179
resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
exit_to_user_mode_loop+0x2a9/0x320 kernel/entry/common.c:171
exit_to_user_mode_prepare+0x16e/0x220 kernel/entry/common.c:203
__syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
syscall_exit_to_user_mode+0x23/0x40 kernel/entry/common.c:296
__do_fast_syscall_32+0xb1/0x100 arch/x86/entry/common.c:181
do_fast_syscall_32+0x33/0x70 arch/x86/entry/common.c:203
do_SYSENTER_32+0x1b/0x20 arch/x86/entry/common.c:246
entry_SYSENTER_compat_after_hwframe+0x70/0x82

Uninit was created at:
slab_post_alloc_hook mm/slab.h:742 [inline]
slab_alloc_node mm/slub.c:3398 [inline]
__kmem_cache_alloc_node+0x6ee/0xc90 mm/slub.c:3437
__do_kmalloc_node mm/slab_common.c:954 [inline]
__kmalloc_node_track_caller+0x117/0x3d0 mm/slab_common.c:975
kmalloc_reserve net/core/skbuff.c:437 [inline]
pskb_expand_head+0x23d/0x1970 net/core/skbuff.c:1832
netif_receive_generic_xdp+0x4c6/0x910 net/core/dev.c:4837
do_xdp_generic net/core/dev.c:4904 [inline]
__netif_receive_skb_core+0x290f/0x6360 net/core/dev.c:5310
__netif_receive_skb_one_core net/core/dev.c:5487 [inline]
__netif_receive_skb+0xc8/0x5d0 net/core/dev.c:5603
process_backlog+0x45a/0x890 net/core/dev.c:5931
__napi_poll+0xe6/0x920 net/core/dev.c:6498
napi_poll net/core/dev.c:6565 [inline]
net_rx_action+0x9e8/0x1a20 net/core/dev.c:6676
__do_softirq+0x1c5/0x7b9 kernel/softirq.c:571

CPU: 0 PID: 3506 Comm: syz-executor.2 Tainted: G W 6.1.0-rc4-syzkaller-62821-gcb231e2f67ec #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
=====================================================


---
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.

syzbot

unread,
Mar 16, 2024, 12:19:25ā€ÆPMMar 16
to and...@kernel.org, a...@kernel.org, ben-...@fluff.org, b...@alien8.de, b...@vger.kernel.org, daniel....@linux.intel.com, dan...@iogearbox.net, dave....@linux.intel.com, gli...@google.com, h...@zytor.com, linu...@vger.kernel.org, linux-...@vger.kernel.org, mi...@redhat.com, m...@pengutronix.de, net...@vger.kernel.org, pbon...@redhat.com, sathyanarayan...@linux.intel.com, syzkall...@googlegroups.com, tg...@linutronix.de, x...@kernel.org, xrive...@gmail.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 66a27abac311 Merge tag 'powerpc-6.9-1' of git://git.kernel..
git tree: upstream
console+strace: https://syzkaller.appspot.com/x/log.txt?x=14285ac9180000
kernel config: https://syzkaller.appspot.com/x/.config?x=48bb382b96e7eda7
dashboard link: https://syzkaller.appspot.com/bug?extid=0e6ddb1ef80986bdfe64
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=17ab51c9180000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=127d21f1180000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/37968fa0451e/disk-66a27aba.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/5b288c5c3088/vmlinux-66a27aba.xz
kernel image: https://storage.googleapis.com/syzbot-assets/792ddbf8146d/bzImage-66a27aba.xz

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

=====================================================
BUG: KMSAN: uninit-value in bpf_prog_run_generic_xdp+0x13a0/0x1ee0 net/core/dev.c:4876
bpf_prog_run_generic_xdp+0x13a0/0x1ee0 net/core/dev.c:4876
netif_receive_generic_xdp net/core/dev.c:4958 [inline]
do_xdp_generic+0xb68/0x1440 net/core/dev.c:5017
__netif_receive_skb_core+0x2533/0x6190 net/core/dev.c:5358
__netif_receive_skb_one_core net/core/dev.c:5536 [inline]
__netif_receive_skb+0xca/0xa00 net/core/dev.c:5652
process_backlog+0x480/0x8b0 net/core/dev.c:5981
__napi_poll+0xe7/0x980 net/core/dev.c:6632
napi_poll net/core/dev.c:6701 [inline]
net_rx_action+0x89d/0x1820 net/core/dev.c:6813
__do_softirq+0x1c0/0x7d7 kernel/softirq.c:554
invoke_softirq kernel/softirq.c:428 [inline]
__irq_exit_rcu kernel/softirq.c:633 [inline]
irq_exit_rcu+0x6a/0x130 kernel/softirq.c:645
instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1043 [inline]
sysvec_apic_timer_interrupt+0x83/0x90 arch/x86/kernel/apic/apic.c:1043
asm_sysvec_apic_timer_interrupt+0x1f/0x30 arch/x86/include/asm/idtentry.h:702
__preempt_count_dec_and_test arch/x86/include/asm/preempt.h:94 [inline]
__raw_spin_unlock_irqrestore include/linux/spinlock_api_smp.h:152 [inline]
_raw_spin_unlock_irqrestore+0x33/0x60 kernel/locking/spinlock.c:194
unlock_hrtimer_base kernel/time/hrtimer.c:1021 [inline]
hrtimer_start_range_ns+0x112c/0x11a0 kernel/time/hrtimer.c:1308
hrtimer_start include/linux/hrtimer.h:275 [inline]
j1939_tp_schedule_txtimer+0xc2/0x100 net/can/j1939/transport.c:702
j1939_sk_send_loop net/can/j1939/socket.c:1164 [inline]
j1939_sk_sendmsg+0x1a0e/0x2730 net/can/j1939/socket.c:1277
sock_sendmsg_nosec net/socket.c:730 [inline]
__sock_sendmsg+0x30f/0x380 net/socket.c:745
____sys_sendmsg+0x877/0xb60 net/socket.c:2584
___sys_sendmsg+0x28d/0x3c0 net/socket.c:2638
__sys_sendmsg net/socket.c:2667 [inline]
__do_sys_sendmsg net/socket.c:2676 [inline]
__se_sys_sendmsg net/socket.c:2674 [inline]
__x64_sys_sendmsg+0x307/0x4a0 net/socket.c:2674
do_syscall_64+0xd5/0x1f0
entry_SYSCALL_64_after_hwframe+0x6d/0x75

Uninit was stored to memory at:
pskb_expand_head+0x30f/0x19d0 net/core/skbuff.c:2253
netif_skb_check_for_xdp net/core/dev.c:4921 [inline]
netif_receive_generic_xdp net/core/dev.c:4952 [inline]
do_xdp_generic+0x931/0x1440 net/core/dev.c:5017
__netif_receive_skb_core+0x2533/0x6190 net/core/dev.c:5358
__netif_receive_skb_one_core net/core/dev.c:5536 [inline]
__netif_receive_skb+0xca/0xa00 net/core/dev.c:5652
process_backlog+0x480/0x8b0 net/core/dev.c:5981
__napi_poll+0xe7/0x980 net/core/dev.c:6632
napi_poll net/core/dev.c:6701 [inline]
net_rx_action+0x89d/0x1820 net/core/dev.c:6813
__do_softirq+0x1c0/0x7d7 kernel/softirq.c:554

Uninit was created at:
slab_post_alloc_hook mm/slub.c:3804 [inline]
slab_alloc_node mm/slub.c:3845 [inline]
kmem_cache_alloc_node+0x613/0xc50 mm/slub.c:3888
kmalloc_reserve+0x13d/0x4a0 net/core/skbuff.c:577
__alloc_skb+0x35b/0x7a0 net/core/skbuff.c:668
alloc_skb include/linux/skbuff.h:1318 [inline]
alloc_skb_with_frags+0xc8/0xbf0 net/core/skbuff.c:6504
sock_alloc_send_pskb+0xa81/0xbf0 net/core/sock.c:2795
sock_alloc_send_skb include/net/sock.h:1835 [inline]
j1939_sk_alloc_skb net/can/j1939/socket.c:878 [inline]
j1939_sk_send_loop net/can/j1939/socket.c:1142 [inline]
j1939_sk_sendmsg+0xc0a/0x2730 net/can/j1939/socket.c:1277
sock_sendmsg_nosec net/socket.c:730 [inline]
__sock_sendmsg+0x30f/0x380 net/socket.c:745
____sys_sendmsg+0x877/0xb60 net/socket.c:2584
___sys_sendmsg+0x28d/0x3c0 net/socket.c:2638
__sys_sendmsg net/socket.c:2667 [inline]
__do_sys_sendmsg net/socket.c:2676 [inline]
__se_sys_sendmsg net/socket.c:2674 [inline]
__x64_sys_sendmsg+0x307/0x4a0 net/socket.c:2674
do_syscall_64+0xd5/0x1f0
entry_SYSCALL_64_after_hwframe+0x6d/0x75

CPU: 0 PID: 5044 Comm: syz-executor640 Not tainted 6.8.0-syzkaller-11136-g66a27abac311 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/29/2024
=====================================================


---
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.

syzbot

unread,
Jul 1, 2024, 6:19:46ā€Æ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] KMSAN: uninit-value in bpf_prog_run_generic_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:53:05ā€Æ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_run_generic_xdp

=====================================================
BUG: KMSAN: uninit-value in bpf_prog_run_generic_xdp+0x13a0/0x1ee0 net/core/dev.c:4923
bpf_prog_run_generic_xdp+0x13a0/0x1ee0 net/core/dev.c:4923
netif_receive_generic_xdp net/core/dev.c:5005 [inline]
do_xdp_generic+0xb68/0x1440 net/core/dev.c:5064
__netif_receive_skb_core+0x2533/0x6190 net/core/dev.c:5405
__netif_receive_skb_one_core net/core/dev.c:5583 [inline]
__netif_receive_skb+0xca/0xa00 net/core/dev.c:5699
process_backlog+0x49d/0x920 net/core/dev.c:6028
__napi_poll+0xe7/0x980 net/core/dev.c:6679
napi_poll net/core/dev.c:6748 [inline]
net_rx_action+0x82a/0x1850 net/core/dev.c:6864
__do_softirq+0x1c0/0x7d7 kernel/softirq.c:554
do_softirq+0x9a/0x100 kernel/softirq.c:455
__local_bh_enable_ip+0x9f/0xb0 kernel/softirq.c:382
__raw_spin_unlock_bh include/linux/spinlock_api_smp.h:167 [inline]
_raw_spin_unlock_bh+0x2d/0x40 kernel/locking/spinlock.c:210
spin_unlock_bh include/linux/spinlock.h:396 [inline]
release_sock+0x219/0x250 net/core/sock.c:3559
j1939_sk_sendmsg+0x23d8/0x2730 net/can/j1939/socket.c:1280
sock_sendmsg_nosec net/socket.c:730 [inline]
__sock_sendmsg+0x30f/0x380 net/socket.c:745
____sys_sendmsg+0x877/0xb60 net/socket.c:2584
___sys_sendmsg+0x28d/0x3c0 net/socket.c:2638
__sys_sendmsg net/socket.c:2667 [inline]
__do_sys_sendmsg net/socket.c:2676 [inline]
__se_sys_sendmsg net/socket.c:2674 [inline]
__x64_sys_sendmsg+0x307/0x4a0 net/socket.c:2674
do_syscall_64+0xd5/0x1f0
entry_SYSCALL_64_after_hwframe+0x6d/0x75

Uninit was stored to memory at:
pskb_expand_head+0x30f/0x19d0 net/core/skbuff.c:2253
netif_skb_check_for_xdp net/core/dev.c:4968 [inline]
netif_receive_generic_xdp net/core/dev.c:4999 [inline]
do_xdp_generic+0x931/0x1440 net/core/dev.c:5064
__netif_receive_skb_core+0x2533/0x6190 net/core/dev.c:5405
__netif_receive_skb_one_core net/core/dev.c:5583 [inline]
__netif_receive_skb+0xca/0xa00 net/core/dev.c:5699
process_backlog+0x49d/0x920 net/core/dev.c:6028
__napi_poll+0xe7/0x980 net/core/dev.c:6679
napi_poll net/core/dev.c:6748 [inline]
net_rx_action+0x82a/0x1850 net/core/dev.c:6864
__do_softirq+0x1c0/0x7d7 kernel/softirq.c:554

Uninit was created at:
slab_post_alloc_hook mm/slub.c:3804 [inline]
slab_alloc_node mm/slub.c:3845 [inline]
kmem_cache_alloc_node+0x613/0xc50 mm/slub.c:3888
kmalloc_reserve+0x13d/0x4a0 net/core/skbuff.c:577
__alloc_skb+0x35b/0x7a0 net/core/skbuff.c:668
alloc_skb include/linux/skbuff.h:1313 [inline]
alloc_skb_with_frags+0xc8/0xbf0 net/core/skbuff.c:6504
sock_alloc_send_pskb+0xa81/0xbf0 net/core/sock.c:2795
sock_alloc_send_skb include/net/sock.h:1842 [inline]
j1939_sk_alloc_skb net/can/j1939/socket.c:878 [inline]
j1939_sk_send_loop net/can/j1939/socket.c:1142 [inline]
j1939_sk_sendmsg+0xc0a/0x2730 net/can/j1939/socket.c:1277
sock_sendmsg_nosec net/socket.c:730 [inline]
__sock_sendmsg+0x30f/0x380 net/socket.c:745
____sys_sendmsg+0x877/0xb60 net/socket.c:2584
___sys_sendmsg+0x28d/0x3c0 net/socket.c:2638
__sys_sendmsg net/socket.c:2667 [inline]
__do_sys_sendmsg net/socket.c:2676 [inline]
__se_sys_sendmsg net/socket.c:2674 [inline]
__x64_sys_sendmsg+0x307/0x4a0 net/socket.c:2674
do_syscall_64+0xd5/0x1f0
entry_SYSCALL_64_after_hwframe+0x6d/0x75

CPU: 1 PID: 5441 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=1648f869980000
kernel config: https://syzkaller.appspot.com/x/.config?x=e2599baf258ef795
dashboard link: https://syzkaller.appspot.com/bug?extid=0e6ddb1ef80986bdfe64
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=11c3ffa6980000

Reply all
Reply to author
Forward
0 new messages