]> git.baikalelectronics.ru Git - kernel.git/commit
ARM: net: delegate filter to kernel interpreter when imm_offset() return value can...
authorNicolas Schichan <nschichan@freebox.fr>
Thu, 7 May 2015 15:14:21 +0000 (17:14 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sun, 10 May 2015 23:21:49 +0000 (19:21 -0400)
commit4724491497d485dbd0131291d115d6201a6c943f
treeb10da6cabb48be6b718189c7217e24fecb051b4a
parent58489be5720088a9b09592b4757ea26f57fc0c15
ARM: net: delegate filter to kernel interpreter when imm_offset() return value can't fit into 12bits.

The ARM JIT code emits "ldr rX, [pc, #offset]" to access the literal
pool. #offset maximum value is 4095 and if the generated code is too
large, the #offset value can overflow and not point to the expected
slot in the literal pool. Additionally, when overflow occurs, bits of
the overflow can end up changing the destination register of the ldr
instruction.

Fix that by detecting the overflow in imm_offset() and setting a flag
that is checked for each BPF instructions converted in
build_body(). As of now it can only be detected in the second pass. As
a result the second build_body() call can now fail, so add the
corresponding cleanup code in that case.

Using multiple literal pools in the JITed code is going to require
lots of intrusive changes to the JIT code (which would better be done
as a feature instead of fix), just delegating to the kernel BPF
interpreter in that case is a more straight forward, minimal fix and
easy to backport.

Fixes: d86c2a9a6042 ("ARM: 7259/3: net: JIT compiler for packet filters")
Signed-off-by: Nicolas Schichan <nschichan@freebox.fr>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
arch/arm/net/bpf_jit_32.c