From: Alexei Starovoitov <ast@fb.com>
To: "David S . Miller" <davem@davemloft.net>
Cc: Daniel Borkmann <daniel@iogearbox.net>,
John Fastabend <john.fastabend@gmail.com>,
<netdev@vger.kernel.org>, <kernel-team@fb.com>
Subject: [PATCH net-next 3/7] bpf: don't mark FP reg as uninit
Date: Thu, 30 Nov 2017 21:31:37 -0800 [thread overview]
Message-ID: <20171201053141.3992592-4-ast@fb.com> (raw)
In-Reply-To: <20171201053141.3992592-1-ast@fb.com>
when verifier hits an internal bug don't mark register R10==FP as uninit,
since it's read only register and it's not technically correct to let
verifier run further, since it may assume that R10 has valid auxiliary state.
While developing subsequent patches this issue was discovered,
though the code eventually changed that aux reg state doesn't have
pointers any more it is still safer to avoid clearing readonly register.
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
---
kernel/bpf/verifier.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index f7229390c279..14ad7c6e806a 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -584,8 +584,8 @@ static void mark_reg_unknown(struct bpf_verifier_env *env,
{
if (WARN_ON(regno >= MAX_BPF_REG)) {
verbose(env, "mark_reg_unknown(regs, %u)\n", regno);
- /* Something bad happened, let's kill all regs */
- for (regno = 0; regno < MAX_BPF_REG; regno++)
+ /* Something bad happened, let's kill all regs except FP */
+ for (regno = 0; regno < BPF_REG_FP; regno++)
__mark_reg_not_init(regs + regno);
return;
}
@@ -603,8 +603,8 @@ static void mark_reg_not_init(struct bpf_verifier_env *env,
{
if (WARN_ON(regno >= MAX_BPF_REG)) {
verbose(env, "mark_reg_not_init(regs, %u)\n", regno);
- /* Something bad happened, let's kill all regs */
- for (regno = 0; regno < MAX_BPF_REG; regno++)
+ /* Something bad happened, let's kill all regs except FP */
+ for (regno = 0; regno < BPF_REG_FP; regno++)
__mark_reg_not_init(regs + regno);
return;
}
--
2.9.5
next prev parent reply other threads:[~2017-12-01 5:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-01 5:31 [PATCH net-next 0/7] bpf: verifier improvements and cleanups Alexei Starovoitov
2017-12-01 5:31 ` [PATCH net-next 1/7] bpf: fix stack state printing in verifier log Alexei Starovoitov
2017-12-01 5:31 ` [PATCH net-next 2/7] bpf: print liveness info to " Alexei Starovoitov
2017-12-01 5:31 ` Alexei Starovoitov [this message]
2017-12-01 5:31 ` [PATCH net-next 4/7] bpf: improve verifier liveness marks Alexei Starovoitov
2017-12-01 5:31 ` [PATCH net-next 5/7] bpf: improve JEQ/JNE path walking Alexei Starovoitov
2017-12-01 5:31 ` [PATCH net-next 6/7] bpf: cleanup register_is_null() Alexei Starovoitov
2017-12-01 5:31 ` [PATCH net-next 7/7] selftests/bpf: adjust test_align expected output Alexei Starovoitov
2017-12-01 10:28 ` [PATCH net-next 0/7] bpf: verifier improvements and cleanups Daniel Borkmann
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=20171201053141.3992592-4-ast@fb.com \
--to=ast@fb.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=john.fastabend@gmail.com \
--cc=kernel-team@fb.com \
--cc=netdev@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;
as well as URLs for NNTP newsgroup(s).