Patch "arm64: bpf: fix endianness conversion bugs" has been added to the 4.1-stable tree
Subsystems (4)
This is a note to let you know that I've just added the patch titled
arm64: bpf: fix endianness conversion bugs
to the 4.1-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
arm64-bpf-fix-endianness-conversion-bugs.patch
and it can be found in the queue-4.1 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
d63903bbc30c7ccad040851dfdb4da12d9a17bcfMon Sep 17 00:00:00 2001
From: Xi Wang <[email protected]>
Date: Thu, 25 Jun 2015 18:39:15 -0700
Subject: arm64: bpf: fix endianness conversion bugs
From: Xi Wang <[email protected]>
commit d63903bbc30c7ccad040851dfdb4da12d9a17bcf upstream.
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.
--- arch/arm64/net/bpf_jit.h | 4 ++++ arch/arm64/net/bpf_jit_comp.c | 22 ++++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-)
arch/arm64/net/bpf_jit.h +4 -0
@@ -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, \
arch/arm64/net/bpf_jit_comp.c +20 -2
@@ -289,23 +289,41 @@ static int build_insn(const struct bpf_icase BPF_ALU |BPF_END |BPF_FROM_BE :#ifdef CONFIG_CPU_BIG_ENDIAN if (BPF_SRC (code) ==BPF_FROM_BE ) -break ; + goto emit_bswap_uxt;#else /* !CONFIG_CPU_BIG_ENDIAN */ if (BPF_SRC (code) ==BPF_FROM_LE ) -break ; + goto emit_bswap_uxt;#endif switch (imm) {case 16 :emit (A64_REV16 (is64, dst, dst), ctx); +/* zero-extend 16 bits into 64 bits */ +emit (A64_UXTH (is64, dst, dst), ctx);break ;case 32 :emit (A64_REV32 (is64, dst, dst), ctx); +/* upper 32 bits already cleared */ break ;case 64 :emit (A64_REV64 (dst, dst), ctx);break ; }break ; +emit_bswap_uxt: +switch (imm) { +case 16 : +/* zero-extend 16 bits into 64 bits */ +emit (A64_UXTH (is64, dst, dst), ctx); +break ; +case 32 : +/* zero-extend 32 bits into 64 bits */ +emit (A64_UXTW (is64, dst, dst), ctx); +break ; +case 64 : +/* nop */ +break ; + } +break ;/* dst = imm */ case BPF_ALU |BPF_MOV |BPF_K :case BPF_ALU64 |BPF_MOV |BPF_K :
Patches currently in stable-queue which might be from [email protected] are
queue-4.1/arm64-bpf-fix-endianness-conversion-bugs.patch queue-4.1/arm64-bpf-fix-out-of-bounds-read-in-bpf2a64_offset.patch