Commit 64b2dd3a authored by David Daney's avatar David Daney Committed by Ralf Baechle

MIPS: BPF: Use unsigned access for unsigned SKB fields.

The SKB vlan_tci and queue_mapping fields are unsigned, don't sign
extend these in the BPF JIT.  In the vlan_tci case, the value gets
masked so the change is not needed for correctness, but do it anyway
for agreement with the types defined in struct sk_buff.
Signed-off-by: default avatarDavid Daney <david.daney@cavium.com>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Steven J. Hill <steven.hill@cavium.com>
Cc: linux-mips@linux-mips.org
Cc: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/15746/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent 4ad70153
...@@ -1156,7 +1156,7 @@ static int build_body(struct jit_ctx *ctx) ...@@ -1156,7 +1156,7 @@ static int build_body(struct jit_ctx *ctx)
BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff,
vlan_tci) != 2); vlan_tci) != 2);
off = offsetof(struct sk_buff, vlan_tci); off = offsetof(struct sk_buff, vlan_tci);
emit_half_load(r_s0, r_skb, off, ctx); emit_half_load_unsigned(r_s0, r_skb, off, ctx);
if (code == (BPF_ANC | SKF_AD_VLAN_TAG)) { if (code == (BPF_ANC | SKF_AD_VLAN_TAG)) {
emit_andi(r_A, r_s0, (u16)~VLAN_TAG_PRESENT, ctx); emit_andi(r_A, r_s0, (u16)~VLAN_TAG_PRESENT, ctx);
} else { } else {
...@@ -1183,7 +1183,7 @@ static int build_body(struct jit_ctx *ctx) ...@@ -1183,7 +1183,7 @@ static int build_body(struct jit_ctx *ctx)
BUILD_BUG_ON(offsetof(struct sk_buff, BUILD_BUG_ON(offsetof(struct sk_buff,
queue_mapping) > 0xff); queue_mapping) > 0xff);
off = offsetof(struct sk_buff, queue_mapping); off = offsetof(struct sk_buff, queue_mapping);
emit_half_load(r_A, r_skb, off, ctx); emit_half_load_unsigned(r_A, r_skb, off, ctx);
break; break;
default: default:
pr_debug("%s: Unhandled opcode: 0x%02x\n", __FILE__, pr_debug("%s: Unhandled opcode: 0x%02x\n", __FILE__,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment