From: Brendan Jackman <jackmanb@google.com>
To: bpf@vger.kernel.org
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii.nakryiko@gmail.com>,
KP Singh <kpsingh@chromium.org>,
Florent Revest <revest@chromium.org>,
linux-kernel@vger.kernel.org,
Brendan Jackman <jackmanb@google.com>, Yonghong Song <yhs@fb.com>,
John Fastabend <john.fastabend@gmail.com>
Subject: [PATCH bpf-next v5 05/11] bpf: Move BPF_STX reserved field check into BPF_STX verifier code
Date: Tue, 15 Dec 2020 12:18:10 +0000 [thread overview]
Message-ID: <20201215121816.1048557-7-jackmanb@google.com> (raw)
In-Reply-To: <20201215121816.1048557-1-jackmanb@google.com>
I can't find a reason why this code is in resolve_pseudo_ldimm64;
since I'll be modifying it in a subsequent commit, tidy it up.
Signed-off-by: Brendan Jackman <jackmanb@google.com>
Acked-by: Yonghong Song <yhs@fb.com>
Acked-by: John Fastabend <john.fastabend@gmail.com>
---
kernel/bpf/verifier.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index d562268c1fd1..48e398667a69 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -9528,6 +9528,12 @@ static int do_check(struct bpf_verifier_env *env)
} else if (class == BPF_STX) {
enum bpf_reg_type *prev_dst_type, dst_reg_type;
+ if (((BPF_MODE(insn->code) != BPF_MEM &&
+ BPF_MODE(insn->code) != BPF_ATOMIC) || insn->imm != 0)) {
+ verbose(env, "BPF_STX uses reserved fields\n");
+ return -EINVAL;
+ }
+
if (BPF_MODE(insn->code) == BPF_ATOMIC) {
err = check_atomic(env, env->insn_idx, insn);
if (err)
@@ -9940,13 +9946,6 @@ static int resolve_pseudo_ldimm64(struct bpf_verifier_env *env)
return -EINVAL;
}
- if (BPF_CLASS(insn->code) == BPF_STX &&
- ((BPF_MODE(insn->code) != BPF_MEM &&
- BPF_MODE(insn->code) != BPF_ATOMIC) || insn->imm != 0)) {
- verbose(env, "BPF_STX uses reserved fields\n");
- return -EINVAL;
- }
-
if (insn[0].code == (BPF_LD | BPF_IMM | BPF_DW)) {
struct bpf_insn_aux_data *aux;
struct bpf_map *map;
--
2.29.2.684.gfbc64c5ab5-goog
next prev parent reply other threads:[~2020-12-15 12:22 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-15 12:18 [PATCH bpf-next v4 00/11] Atomics for eBPF Brendan Jackman
2020-12-15 12:18 ` [PATCH bpf-next v5 01/11] bpf: x86: Factor out emission of ModR/M for *(reg + off) Brendan Jackman
2020-12-15 12:18 ` [PATCH bpf-next v2] libbpf: Expose libbpf ringbufer epoll_fd Brendan Jackman
2020-12-15 18:35 ` Andrii Nakryiko
2020-12-15 12:18 ` [PATCH bpf-next v5 02/11] bpf: x86: Factor out emission of REX byte Brendan Jackman
2020-12-15 12:18 ` [PATCH bpf-next v5 03/11] bpf: x86: Factor out a lookup table for some ALU opcodes Brendan Jackman
2020-12-15 12:18 ` [PATCH bpf-next v5 04/11] bpf: Rename BPF_XADD and prepare to encode other atomics in .imm Brendan Jackman
2020-12-15 14:05 ` Björn Töpel
2020-12-15 12:18 ` Brendan Jackman [this message]
2020-12-15 12:18 ` [PATCH bpf-next v5 06/11] bpf: Add BPF_FETCH field / create atomic_fetch_add instruction Brendan Jackman
2020-12-15 12:18 ` [PATCH bpf-next v5 07/11] bpf: Add instructions for atomic_[cmp]xchg Brendan Jackman
2020-12-16 6:47 ` Yonghong Song
2020-12-15 12:18 ` [PATCH bpf-next v5 08/11] bpf: Pull out a macro for interpreting atomic ALU operations Brendan Jackman
2020-12-15 12:18 ` [PATCH bpf-next v5 09/11] bpf: Add bitwise atomic instructions Brendan Jackman
2020-12-16 6:53 ` Yonghong Song
2020-12-15 12:18 ` [PATCH bpf-next v5 10/11] bpf: Add tests for new BPF atomic operations Brendan Jackman
2020-12-15 12:18 ` [PATCH bpf-next v5 11/11] bpf: Document new atomic instructions Brendan Jackman
2020-12-16 7:08 ` Yonghong Song
2020-12-16 11:44 ` Brendan Jackman
2020-12-16 15:25 ` Yonghong Song
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=20201215121816.1048557-7-jackmanb@google.com \
--to=jackmanb@google.com \
--cc=andrii.nakryiko@gmail.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=kpsingh@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=revest@chromium.org \
--cc=yhs@fb.com \
/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).