BPF List
 help / color / mirror / Atom feed
* [PATCH] Fix a bug in ebpf verifier
@ 2024-09-11  6:52 lonial con
  2024-09-11 14:54 ` Eduard Zingerman
  0 siblings, 1 reply; 10+ messages in thread
From: lonial con @ 2024-09-11  6:52 UTC (permalink / raw)
  To: bpf; +Cc: lonial con

In find_equal_scalars(), it should not copy the reg->subreg_def, otherwise a bug will occur when the program flag has BPF_F_TEST_RND_HI32.

Reported-by: Lonial Con <kongln9170@gmail.com>
Signed-off-by: Lonial Con <kongln9170@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 d852009..1e01b7f 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -15101,7 +15101,9 @@ static void find_equal_scalars(struct bpf_verifier_state *vstate,
 			continue;
 		if ((!(reg->id & BPF_ADD_CONST) && !(known_reg->id & BPF_ADD_CONST)) ||
 		    reg->off == known_reg->off) {
+			s32 subreg_def = reg->subreg_def;
 			copy_register_state(reg, known_reg);
+			reg->subreg_def = subreg_def;
 		} else {
 			s32 saved_off = reg->off;
 
@@ -15109,7 +15111,9 @@ static void find_equal_scalars(struct bpf_verifier_state *vstate,
 			__mark_reg_known(&fake_reg, (s32)reg->off - (s32)known_reg->off);
 
 			/* reg = known_reg; reg += delta */
+			s32 subreg_def = reg->subreg_def;
 			copy_register_state(reg, known_reg);
+			reg->subreg_def = subreg_def;
 			/*
 			 * Must preserve off, id and add_const flag,
 			 * otherwise another find_equal_scalars() will be incorrect.
-- 
2.7.4


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

end of thread, other threads:[~2024-09-24 18:46 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-11  6:52 [PATCH] Fix a bug in ebpf verifier lonial con
2024-09-11 14:54 ` Eduard Zingerman
2024-09-12  2:53   ` lonial con
2024-09-12  4:31     ` Eduard Zingerman
     [not found]       ` <CAH6SPwjoACNcNBWCjYauSMYCFOUAys10uH-xM6mF8_Q79D0Yow@mail.gmail.com>
2024-09-12 14:40         ` lonial con
2024-09-12 17:38           ` Eduard Zingerman
2024-09-12 23:36           ` Eduard Zingerman
2024-09-24  8:11             ` Eduard Zingerman
2024-09-24 13:40               ` lonial con
2024-09-24 18:46                 ` Eduard Zingerman

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