All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next v1 1/2] bpf: handle jset (if a & b ...) as a jump in CFG computation
@ 2025-06-13 17:53 Eduard Zingerman
  2025-06-13 17:53 ` [PATCH bpf-next v1 2/2] selftests/bpf: verify jset handling " Eduard Zingerman
  2025-06-13 19:10 ` [PATCH bpf-next v1 1/2] bpf: handle jset (if a & b ...) as a jump " patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Eduard Zingerman @ 2025-06-13 17:53 UTC (permalink / raw)
  To: bpf, ast, andrii
  Cc: daniel, martin.lau, kernel-team, yonghong.song, eddyz87,
	syzbot+a36aac327960ff474804, Alexei Starovoitov

BPF_JSET is a conditional jump and currently verifier.c:can_jump()
does not know about that. This can lead to incorrect live registers
and SCC computation.

E.g. in the following example:

   1: r0 = 1;
   2: r2 = 2;
   3: if r1 & 0x7 goto +1;
   4: exit;
   5: r0 = r2;
   6: exit;

W/o this fix insn_successors(3) will return only (4), a jump to (5)
would be missed and r2 won't be marked as alive at (3).

Fixes: 14c8552db644 ("bpf: simple DFA-based live registers analysis")
Reported-by: syzbot+a36aac327960ff474804@syzkaller.appspotmail.com
Suggested-by: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
---
 kernel/bpf/verifier.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index c378074516cf..e76eb0322912 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -23950,6 +23950,7 @@ static bool can_jump(struct bpf_insn *insn)
 	case BPF_JSLT:
 	case BPF_JSLE:
 	case BPF_JCOND:
+	case BPF_JSET:
 		return true;
 	}
 
-- 
2.47.1


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

end of thread, other threads:[~2025-06-13 19:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-13 17:53 [PATCH bpf-next v1 1/2] bpf: handle jset (if a & b ...) as a jump in CFG computation Eduard Zingerman
2025-06-13 17:53 ` [PATCH bpf-next v1 2/2] selftests/bpf: verify jset handling " Eduard Zingerman
2025-06-13 19:10 ` [PATCH bpf-next v1 1/2] bpf: handle jset (if a & b ...) as a jump " patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.