From: lonial con <kongln9170@gmail.com>
To: bpf@vger.kernel.org
Cc: lonial con <kongln9170@gmail.com>
Subject: [PATCH] Fix a bug in ebpf verifier
Date: Wed, 11 Sep 2024 14:52:01 +0800 [thread overview]
Message-ID: <1726037521-18232-1-git-send-email-kongln9170@gmail.com> (raw)
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
next reply other threads:[~2024-09-11 6:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-11 6:52 lonial con [this message]
2024-09-11 14:54 ` [PATCH] Fix a bug in ebpf verifier 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1726037521-18232-1-git-send-email-kongln9170@gmail.com \
--to=kongln9170@gmail.com \
--cc=bpf@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox