diff options
author | Alexei Starovoitov | 2019-07-23 23:12:38 +0200 |
---|---|---|
committer | Alexei Starovoitov | 2019-07-23 23:12:38 +0200 |
commit | 7c8b87f012614697596b78841c0d0b1520b1f88a (patch) | |
tree | 1aaff1884ece785915c25780bd7d2f5666c5e941 | |
parent | bpf: fix narrower loads on s390 (diff) | |
parent | selftests/bpf: add another gso_segs access (diff) | |
download | kernel-qcow2-linux-7c8b87f012614697596b78841c0d0b1520b1f88a.tar.gz kernel-qcow2-linux-7c8b87f012614697596b78841c0d0b1520b1f88a.tar.xz kernel-qcow2-linux-7c8b87f012614697596b78841c0d0b1520b1f88a.zip |
Merge branch 'fix-gso_segs'
Eric Dumazet says:
====================
First patch changes the kernel, second patch
adds a new test.
Note that other patches might be needed to take
care of similar issues in sock_ops_convert_ctx_access()
and SOCK_OPS_GET_FIELD()
====================
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
-rw-r--r-- | net/core/filter.c | 6 | ||||
-rw-r--r-- | tools/testing/selftests/bpf/verifier/ctx_skb.c | 11 |
2 files changed, 14 insertions, 3 deletions
diff --git a/net/core/filter.c b/net/core/filter.c index 4e2a79b2fd77..7878f918b8c0 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -7455,12 +7455,12 @@ static u32 bpf_convert_ctx_access(enum bpf_access_type type, case offsetof(struct __sk_buff, gso_segs): /* si->dst_reg = skb_shinfo(SKB); */ #ifdef NET_SKBUFF_DATA_USES_OFFSET - *insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(struct sk_buff, head), - si->dst_reg, si->src_reg, - offsetof(struct sk_buff, head)); *insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(struct sk_buff, end), BPF_REG_AX, si->src_reg, offsetof(struct sk_buff, end)); + *insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(struct sk_buff, head), + si->dst_reg, si->src_reg, + offsetof(struct sk_buff, head)); *insn++ = BPF_ALU64_REG(BPF_ADD, si->dst_reg, BPF_REG_AX); #else *insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(struct sk_buff, end), diff --git a/tools/testing/selftests/bpf/verifier/ctx_skb.c b/tools/testing/selftests/bpf/verifier/ctx_skb.c index b0fda2877119..d438193804b2 100644 --- a/tools/testing/selftests/bpf/verifier/ctx_skb.c +++ b/tools/testing/selftests/bpf/verifier/ctx_skb.c @@ -975,6 +975,17 @@ .prog_type = BPF_PROG_TYPE_CGROUP_SKB, }, { + "read gso_segs from CGROUP_SKB", + .insns = { + BPF_LDX_MEM(BPF_W, BPF_REG_1, BPF_REG_1, + offsetof(struct __sk_buff, gso_segs)), + BPF_MOV64_IMM(BPF_REG_0, 0), + BPF_EXIT_INSN(), + }, + .result = ACCEPT, + .prog_type = BPF_PROG_TYPE_CGROUP_SKB, +}, +{ "write gso_segs from CGROUP_SKB", .insns = { BPF_MOV64_IMM(BPF_REG_0, 0), |