aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm64/net/bpf_jit.h
diff options
context:
space:
mode:
authorXi Wang <xi.wang@gmail.com>2015-06-25 18:39:15 -0700
committerCatalin Marinas <catalin.marinas@arm.com>2015-06-26 14:15:39 +0100
commitd63903bbc30c7ccad040851dfdb4da12d9a17bcf (patch)
tree6ddc09f1a2289e833b51b373049649f416a586bf /arch/arm64/net/bpf_jit.h
parentarm64: bpf: fix out-of-bounds read in bpf2a64_offset() (diff)
downloadlinux-dev-d63903bbc30c7ccad040851dfdb4da12d9a17bcf.tar.xz
linux-dev-d63903bbc30c7ccad040851dfdb4da12d9a17bcf.zip
arm64: bpf: fix endianness conversion bugs
Upper bits should be zeroed in endianness conversion: - even when there's no need to change endianness (i.e., BPF_FROM_BE on big endian or BPF_FROM_LE on little endian); - after rev16. This patch fixes such bugs by emitting extra instructions to clear upper bits. Cc: Zi Shen Lim <zlim.lnx@gmail.com> Acked-by: Alexei Starovoitov <ast@plumgrid.com> Fixes: e54bcde3d69d ("arm64: eBPF JIT compiler") Cc: <stable@vger.kernel.org> # 3.18+ Signed-off-by: Xi Wang <xi.wang@gmail.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Diffstat (limited to 'arch/arm64/net/bpf_jit.h')
-rw-r--r--arch/arm64/net/bpf_jit.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/arch/arm64/net/bpf_jit.h b/arch/arm64/net/bpf_jit.h
index de0a81a539a0..98a26ce82d26 100644
--- a/arch/arm64/net/bpf_jit.h
+++ b/arch/arm64/net/bpf_jit.h
@@ -110,6 +110,10 @@
/* Rd = Rn >> shift; signed */
#define A64_ASR(sf, Rd, Rn, shift) A64_SBFM(sf, Rd, Rn, shift, (sf) ? 63 : 31)
+/* Zero extend */
+#define A64_UXTH(sf, Rd, Rn) A64_UBFM(sf, Rd, Rn, 0, 15)
+#define A64_UXTW(sf, Rd, Rn) A64_UBFM(sf, Rd, Rn, 0, 31)
+
/* Move wide (immediate) */
#define A64_MOVEW(sf, Rd, imm16, shift, type) \
aarch64_insn_gen_movewide(Rd, imm16, shift, \