aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWang YanQing <udknight@gmail.com>2018-05-10 23:06:34 -0400
committerDaniel Borkmann <daniel@iogearbox.net>2018-06-05 04:46:13 -0400
commit2b589a7e2bd3eb610a4b7f5e61393481755a4de9 (patch)
treea9e0ebdb78fa6530ee26bf7c546bef6e5482ed5f
parent34ea38ca27991466a8fff849514b4181b42ae2eb (diff)
bpf, arm32: correct check_imm24
imm24 is signed, so the right range is: [-(1<<(24 - 1)), (1<<(24 - 1)) - 1] Note: this patch also fix a typo. Fixes: 39c13c204bb1 ("arm: eBPF JIT compiler") Signed-off-by: Wang YanQing <udknight@gmail.com> Cc: Shubham Bansal <illusionist.neo@gmail.com> Cc: linux-arm-kernel@lists.infradead.org Cc: linux@armlinux.org.uk Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
-rw-r--r--arch/arm/net/bpf_jit_32.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c
index d3ea6454e775..0d542007b49d 100644
--- a/arch/arm/net/bpf_jit_32.c
+++ b/arch/arm/net/bpf_jit_32.c
@@ -84,7 +84,7 @@
84 * 84 *
85 * 1. First argument is passed using the arm 32bit registers and rest of the 85 * 1. First argument is passed using the arm 32bit registers and rest of the
86 * arguments are passed on stack scratch space. 86 * arguments are passed on stack scratch space.
87 * 2. First callee-saved arugument is mapped to arm 32 bit registers and rest 87 * 2. First callee-saved argument is mapped to arm 32 bit registers and rest
88 * arguments are mapped to scratch space on stack. 88 * arguments are mapped to scratch space on stack.
89 * 3. We need two 64 bit temp registers to do complex operations on eBPF 89 * 3. We need two 64 bit temp registers to do complex operations on eBPF
90 * registers. 90 * registers.
@@ -1192,8 +1192,8 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx)
1192 s32 jmp_offset; 1192 s32 jmp_offset;
1193 1193
1194#define check_imm(bits, imm) do { \ 1194#define check_imm(bits, imm) do { \
1195 if ((((imm) > 0) && ((imm) >> (bits))) || \ 1195 if ((imm) >= (1 << ((bits) - 1)) || \
1196 (((imm) < 0) && (~(imm) >> (bits)))) { \ 1196 (imm) < -(1 << ((bits) - 1))) { \
1197 pr_info("[%2d] imm=%d(0x%x) out of range\n", \ 1197 pr_info("[%2d] imm=%d(0x%x) out of range\n", \
1198 i, imm, imm); \ 1198 i, imm, imm); \
1199 return -EINVAL; \ 1199 return -EINVAL; \