Skip to content

Commit 970e421

Browse files
sm00thKernel Patches Daemon
authored and
Kernel Patches Daemon
committed
arm64: bpf: zero upper bits after rev32
Commit d63903b ("arm64: bpf: fix endianness conversion bugs") added upper bits zeroing to byteswap operations, but it assumes they will be already zeroed after rev32, which is not the case on some systems at least: [ 9757.262607] test_bpf: #312 BSWAP 16: 0x0123456789abcdef -> 0xefcd jited:1 8 PASS [ 9757.264435] test_bpf: #313 BSWAP 32: 0x0123456789abcdef -> 0xefcdab89 jited:1 ret 1460850314 != -271733879 (0x5712ce8a != 0xefcdab89)FAIL (1 times) [ 9757.266260] test_bpf: #314 BSWAP 64: 0x0123456789abcdef -> 0x67452301 jited:1 8 PASS [ 9757.268000] test_bpf: #315 BSWAP 64: 0x0123456789abcdef >> 32 -> 0xefcdab89 jited:1 8 PASS [ 9757.269686] test_bpf: #316 BSWAP 16: 0xfedcba9876543210 -> 0x1032 jited:1 8 PASS [ 9757.271380] test_bpf: #317 BSWAP 32: 0xfedcba9876543210 -> 0x10325476 jited:1 ret -1460850316 != 271733878 (0xa8ed3174 != 0x10325476)FAIL (1 times) [ 9757.273022] test_bpf: #318 BSWAP 64: 0xfedcba9876543210 -> 0x98badcfe jited:1 7 PASS [ 9757.274721] test_bpf: #319 BSWAP 64: 0xfedcba9876543210 >> 32 -> 0x10325476 jited:1 9 PASS Fixes: d63903b ("arm64: bpf: fix endianness conversion bugs") Signed-off-by: Artem Savkov <asavkov@redhat.com>
1 parent dd3e514 commit 970e421

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/arm64/net/bpf_jit_comp.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,8 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx,
944944
break;
945945
case 32:
946946
emit(A64_REV32(is64, dst, dst), ctx);
947-
/* upper 32 bits already cleared */
947+
/* zero-extend 32 bits into 64 bits */
948+
emit(A64_UXTW(is64, dst, dst), ctx);
948949
break;
949950
case 64:
950951
emit(A64_REV64(dst, dst), ctx);

0 commit comments

Comments
 (0)