mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [syzbot] [bpf?] WARNING in bpf_mark_chain_precision
@ 2026-09-04 14:14 syzbot
  2026-09-05  0:33 ` Forwarded: [PATCH] bpf: reject non-scalar R1 for bpf_loop() helper syzbot
  0 siblings, 1 reply; 3+ messages in thread
From: syzbot @ 2026-09-04 14:14 UTC (permalink / raw)
  To: andrii, ast, bpf, daniel, eddyz87, emil, ihor.solodrai, jolsa,
	linux-kernel, martin.lau, memxor, netdev, song, syzkaller-bugs,
	yonghong.song

Hello,

syzbot found the following issue on:

HEAD commit:    e044668419b9 Merge branch 'misc-bug-fixes-part-1'
git tree:       bpf
console+strace: https://syzkaller.appspot.com/x/log.txt?x=162038f9580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=13dd96f4206498c4
dashboard link: https://syzkaller.appspot.com/bug?extid=7b47f87674e9a1569110
compiler:       Debian clang version 22.1.8 (++20260613092233+e80beda6e255-1~exp1~20260613092250.77), Debian LLD 22.1.8
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=165fcb49580000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=112038f9580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/2c0c9fa35baf/disk-e0446684.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/1ed2d74549a1/vmlinux-e0446684.xz
kernel image: https://storage.googleapis.com/syzbot-assets/479e5164ed3b/bzImage-e0446684.xz

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

------------[ cut here ]------------
verifier bug: backtracking misuse
WARNING: kernel/bpf/backtrack.c:829 at bpf_mark_chain_precision+0x571b/0x76b0 kernel/bpf/backtrack.c:829, CPU#1: syz-executor403/5624
Modules linked in:
CPU: 1 UID: 0 PID: 5624 Comm: syz-executor403 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/24/2026
RIP: 0010:bpf_mark_chain_precision+0x571b/0x76b0 kernel/bpf/backtrack.c:829
Code: ff 89 d9 80 e1 07 80 c1 03 38 c1 0f 8c 16 ff ff ff 48 89 df e8 76 17 44 00 e9 09 ff ff ff e8 0c d0 d4 ff 48 8d 3d b5 50 6a 0e <67> 48 0f b9 3a 48 8b 3c 24 48 81 c7 88 08 00 00 48 c7 c6 a0 c6 f6
RSP: 0018:ffffc90003957228 EFLAGS: 00010293
RAX: ffffffff81f23d54 RBX: 0000000000000001 RCX: ffff88807f7b9f40
RDX: 0000000000000000 RSI: 0000000000000003 RDI: ffffffff905c8e10
RBP: 0000000000000003 R08: ffff88807f7b9f40 R09: 0000000000000003
R10: 0000000000000007 R11: 0000000000000000 R12: ffff88807f4f3050
R13: dffffc0000000000 R14: 0000000000000001 R15: 0000000000000000
FS:  00005555805e0400(0000) GS:ffff888125024000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00000000006a9ee0 CR3: 000000007133a000 CR4: 00000000003526f0
Call Trace:
 <TASK>
 mark_chain_precision kernel/bpf/verifier.c:3373 [inline]
 check_helper_call kernel/bpf/verifier.c:10894 [inline]
 do_check_insn+0x12a74/0x17c20 kernel/bpf/verifier.c:18177
 do_check kernel/bpf/verifier.c:18363 [inline]
 do_check_common+0x3c19/0x5d30 kernel/bpf/verifier.c:19444
 do_check_main kernel/bpf/verifier.c:19540 [inline]
 bpf_check+0x2639/0x2e10 kernel/bpf/verifier.c:21195
 bpf_prog_load+0x14d6/0x1c20 kernel/bpf/syscall.c:3133
 __sys_bpf+0xd0d/0xd90 kernel/bpf/syscall.c:6367
 __do_sys_bpf kernel/bpf/syscall.c:6486 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:6483 [inline]
 __x64_sys_bpf+0xba/0xd0 kernel/bpf/syscall.c:6483
 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
 do_syscall_64+0x166/0x520 arch/x86/entry/syscall_64.c:84
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f4f25cf1749
Code: c0 79 93 eb d5 48 8d 7c 1d 00 eb 99 0f 1f 44 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 d8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fff991a6f18 EFLAGS: 00000246 ORIG_RAX: 0000000000000141
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f4f25cf1749
RDX: 0000000000000080 RSI: 0000200000000300 RDI: 0000000000000005
RBP: 0000000000000000 R08: 0000000000000006 R09: 0000000000000006
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f4f25d84c40 R15: 0000000000000002
 </TASK>
----------------
Code disassembly (best guess):
   0:	ff 89 d9 80 e1 07    	decl   0x7e180d9(%rcx)
   6:	80 c1 03             	add    $0x3,%cl
   9:	38 c1                	cmp    %al,%cl
   b:	0f 8c 16 ff ff ff    	jl     0xffffff27
  11:	48 89 df             	mov    %rbx,%rdi
  14:	e8 76 17 44 00       	call   0x44178f
  19:	e9 09 ff ff ff       	jmp    0xffffff27
  1e:	e8 0c d0 d4 ff       	call   0xffd4d02f
  23:	48 8d 3d b5 50 6a 0e 	lea    0xe6a50b5(%rip),%rdi        # 0xe6a50df
* 2a:	67 48 0f b9 3a       	ud1    (%edx),%rdi <-- trapping instruction
  2f:	48 8b 3c 24          	mov    (%rsp),%rdi
  33:	48 81 c7 88 08 00 00 	add    $0x888,%rdi
  3a:	48                   	rex.W
  3b:	c7                   	.byte 0xc7
  3c:	c6                   	(bad)
  3d:	a0                   	.byte 0xa0
  3e:	c6                   	(bad)
  3f:	f6                   	.byte 0xf6


---
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 syzkaller@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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Forwarded: [PATCH] bpf: reject non-scalar R1 for bpf_loop() helper
  2026-09-04 14:14 [syzbot] [bpf?] WARNING in bpf_mark_chain_precision syzbot
@ 2026-09-05  0:33 ` syzbot
  0 siblings, 0 replies; 3+ messages in thread
From: syzbot @ 2026-09-05  0:33 UTC (permalink / raw)
  To: linux-kernel, syzkaller-bugs

For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.

***

Subject: [PATCH] bpf: reject non-scalar R1 for bpf_loop() helper
Author: kartikey406@gmail.com

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git master

syzbot reported a verifier backtracking warning ("backtracking misuse")
in bpf_mark_chain_precision() triggered by a crafted program that calls
bpf_loop() with a non-scalar value in R1 (nr_loops).

bpf_loop()'s prototype declares arg1_type as ARG_ANYTHING, which accepts
any initialized register, including pointers. However, check_helper_call()
unconditionally calls mark_chain_precision() on R1, because the verifier
relies on the nr_loops value to reason about loop termination. Precision
tracking is only valid for SCALAR_VALUE registers, so passing a pointer in
R1 reaches the SCALAR_VALUE assertion in the backtracking code and trips
the warning instead of failing verification cleanly.

Reject the program with a proper error when R1 is not a scalar, before
calling mark_chain_precision().

Reported-by: syzbot+7b47f87674e9a1569110@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=7b47f87674e9a1569110
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
 kernel/bpf/verifier.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index e421ea2b80c3..d8df29ac7dac 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -10886,6 +10886,10 @@ static int check_helper_call(struct bpf_verifier_env *env, struct bpf_insn *insn
 		break;
 	case BPF_FUNC_loop:
 		update_loop_inline_state(env, meta.subprogno);
+		if (cur_regs(env)[BPF_REG_1].type != SCALAR_VALUE) {
+			verbose(env, "R1 must be a scalar for bpf_loop\n");
+			return -EINVAL;
+		}
 		/* Verifier relies on R1 value to determine if bpf_loop() iteration
 		 * is finished, thus mark it precise.
 		 */
-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [syzbot] [bpf?] WARNING in bpf_mark_chain_precision
       [not found] <20260905003317.18035-1-kartikey406@gmail.com>
@ 2026-09-05  2:08 ` syzbot
  0 siblings, 0 replies; 3+ messages in thread
From: syzbot @ 2026-09-05  2:08 UTC (permalink / raw)
  To: kartikey406, linux-kernel, syzkaller-bugs

Hello,

syzbot tried to test the proposed patch but the build/boot failed:

failed to apply patch:
error: patch failed: kernel/bpf/verifier.c:10886
error: kernel/bpf/verifier.c: patch does not apply



Tested on:

commit:         b75a000f Merge branch 'bpf-add-missing-precision-propa..
git tree:       bpf
kernel config:  https://syzkaller.appspot.com/x/.config?x=13dd96f4206498c4
dashboard link: https://syzkaller.appspot.com/bug?extid=7b47f87674e9a1569110
compiler:       
patch:          https://syzkaller.appspot.com/x/patch.diff?x=1774e125580000


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-05  2:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-04 14:14 [syzbot] [bpf?] WARNING in bpf_mark_chain_precision syzbot
2026-09-05  0:33 ` Forwarded: [PATCH] bpf: reject non-scalar R1 for bpf_loop() helper syzbot
     [not found] <20260905003317.18035-1-kartikey406@gmail.com>
2026-09-05  2:08 ` [syzbot] [bpf?] WARNING in bpf_mark_chain_precision syzbot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®