summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorXi Wang <xi.wang@gmail.com>2015-05-08 06:39:51 +0100
committerWill Deacon <will.deacon@arm.com>2015-05-08 16:15:07 +0100
commit1e4df6b7208140f3c49f316d33a409d3a161f350 (patch)
treefdc3195d8e5d8bc5fa87bee6c2dc7c2d5f20e3fc /arch
parent326a780317d572711f70d53054502e86a1ff5317 (diff)
downloadop-kernel-dev-1e4df6b7208140f3c49f316d33a409d3a161f350.zip
op-kernel-dev-1e4df6b7208140f3c49f316d33a409d3a161f350.tar.gz
arm64: bpf: fix signedness bug in loading 64-bit immediate
Consider "(u64)insn1.imm << 32 | imm" in the arm64 JIT. Since imm is signed 32-bit, it is sign-extended to 64-bit, losing the high 32 bits. The fix is to convert imm to u32 first, which will be zero-extended to u64 implicitly. Cc: Zi Shen Lim <zlim.lnx@gmail.com> Cc: Alexei Starovoitov <ast@plumgrid.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: <stable@vger.kernel.org> Fixes: 30d3d94cc3d5 ("arm64: bpf: add 'load 64-bit immediate' instruction") Signed-off-by: Xi Wang <xi.wang@gmail.com> [will: removed non-arm64 bits and redundant casting] Signed-off-by: Will Deacon <will.deacon@arm.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm64/net/bpf_jit_comp.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
index edba042..dc6a484 100644
--- a/arch/arm64/net/bpf_jit_comp.c
+++ b/arch/arm64/net/bpf_jit_comp.c
@@ -487,7 +487,7 @@ emit_cond_jmp:
return -EINVAL;
}
- imm64 = (u64)insn1.imm << 32 | imm;
+ imm64 = (u64)insn1.imm << 32 | (u32)imm;
emit_a64_mov_i64(dst, imm64, ctx);
return 1;
OpenPOWER on IntegriCloud