Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1471074

[PATCH net-next 1/6] bpf: support 8-byte metafield access

From Alexei Starovoitov <ast@fb.com>
Newsgroups linux.kernel
Subject [PATCH net-next 1/6] bpf: support 8-byte metafield access
Date 2016-08-27 04:40 +0200
Message-ID <saBHj-793-13@gated-at.bofh.it> (permalink)
References <saBHj-793-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


The verifier supported only 4-byte metafields in
struct __sk_buff and struct xdp_md. The metafields in upcoming
struct bpf_perf_event are 8-byte to match register width in struct pt_regs.
Teach verifier to recognize 8-byte metafield access.
The patch doesn't affect safety of sockets and xdp programs.
They check for 4-byte only ctx access before these conditions are hit.

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
---
 kernel/bpf/verifier.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index abb61f3f6900..c1c9e441f0f5 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -2333,7 +2333,8 @@ static int do_check(struct verifier_env *env)
 			if (err)
 				return err;
 
-			if (BPF_SIZE(insn->code) != BPF_W) {
+			if (BPF_SIZE(insn->code) != BPF_W &&
+			    BPF_SIZE(insn->code) != BPF_DW) {
 				insn_idx++;
 				continue;
 			}
@@ -2642,9 +2643,11 @@ static int convert_ctx_accesses(struct verifier_env *env)
 	for (i = 0; i < insn_cnt; i++, insn++) {
 		u32 insn_delta, cnt;
 
-		if (insn->code == (BPF_LDX | BPF_MEM | BPF_W))
+		if (insn->code == (BPF_LDX | BPF_MEM | BPF_W) ||
+		    insn->code == (BPF_LDX | BPF_MEM | BPF_DW))
 			type = BPF_READ;
-		else if (insn->code == (BPF_STX | BPF_MEM | BPF_W))
+		else if (insn->code == (BPF_STX | BPF_MEM | BPF_W) ||
+			 insn->code == (BPF_STX | BPF_MEM | BPF_DW))
 			type = BPF_WRITE;
 		else
 			continue;
-- 
2.8.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH net-next 0/6] perf, bpf: add support for bpf in sw/hw perf_events Alexei Starovoitov <ast@fb.com> - 2016-08-27 04:40 +0200
  [PATCH net-next 1/6] bpf: support 8-byte metafield access Alexei Starovoitov <ast@fb.com> - 2016-08-27 04:40 +0200
    Re: [PATCH net-next 1/6] bpf: support 8-byte metafield access Daniel Borkmann <daniel@iogearbox.net> - 2016-08-30 02:00 +0200
  [PATCH net-next 6/6] samples/bpf: add sampleip example Alexei Starovoitov <ast@fb.com> - 2016-08-27 04:40 +0200
  [PATCH net-next 4/6] perf, bpf: add perf events core support for BPF_PROG_TYPE_PERF_EVENT programs Alexei Starovoitov <ast@fb.com> - 2016-08-27 04:40 +0200
    Re: [PATCH net-next 4/6] perf, bpf: add perf events core support for  BPF_PROG_TYPE_PERF_EVENT programs Peter Zijlstra <peterz@infradead.org> - 2016-08-29 14:20 +0200
      Re: [PATCH net-next 4/6] perf, bpf: add perf events core support for  BPF_PROG_TYPE_PERF_EVENT programs Alexei Starovoitov <alexei.starovoitov@gmail.com> - 2016-08-31 05:50 +0200
  [PATCH net-next 2/6] bpf: introduce BPF_PROG_TYPE_PERF_EVENT program type Alexei Starovoitov <ast@fb.com> - 2016-08-27 04:40 +0200
    Re: [PATCH net-next 2/6] bpf: introduce BPF_PROG_TYPE_PERF_EVENT  program type Daniel Borkmann <daniel@iogearbox.net> - 2016-08-30 02:20 +0200
  [PATCH net-next 5/6] samples/bpf: add perf_event+bpf example Alexei Starovoitov <ast@fb.com> - 2016-08-27 04:40 +0200
  Re: [PATCH net-next 0/6] perf, bpf: add support for bpf in sw/hw  perf_events Peter Zijlstra <peterz@infradead.org> - 2016-08-29 13:00 +0200
    Re: [PATCH net-next 0/6] perf, bpf: add support for bpf in sw/hw  perf_events Alexei Starovoitov <alexei.starovoitov@gmail.com> - 2016-08-30 01:10 +0200
  Re: [PATCH net-next 0/6] perf, bpf: add support for bpf in sw/hw  perf_events Peter Zijlstra <peterz@infradead.org> - 2016-08-29 14:20 +0200
    Re: [PATCH net-next 0/6] perf, bpf: add support for bpf in sw/hw perf_events Brendan Gregg <brendan.d.gregg@gmail.com> - 2016-08-30 04:30 +0200

csiph-web