]> git.baikalelectronics.ru Git - kernel.git/commit
bpf, x32: Fix bug with ALU64 {LSH, RSH, ARSH} BPF_K shift by 0
authorLuke Nelson <lukenels@cs.washington.edu>
Sat, 29 Jun 2019 05:57:50 +0000 (22:57 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Wed, 3 Jul 2019 09:14:28 +0000 (11:14 +0200)
commit2069ac089ee586bd37ccaffe7ff8017c50c74608
treed2d6f3e67778c27a1e27c37059ac1b0a31122fd2
parentb08289c7b2e97c756439864a4bc27fd874c66e0e
bpf, x32: Fix bug with ALU64 {LSH, RSH, ARSH} BPF_K shift by 0

The current x32 BPF JIT does not correctly compile shift operations when
the immediate shift amount is 0. The expected behavior is for this to
be a no-op.

The following program demonstrates the bug. The expexceted result is 1,
but the current JITed code returns 2.

  r0 = 1
  r1 = 1
  r1 <<= 0
  if r1 == 1 goto end
  r0 = 2
end:
  exit

This patch simplifies the code and fixes the bug.

Fixes: 7d34d6cfde1f ("bpf, x86_32: add eBPF JIT compiler for ia32")
Co-developed-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Luke Nelson <luke.r.nels@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
arch/x86/net/bpf_jit_comp32.c