Skip to content

Commit 2b70de4

Browse files
borkmanngregkh
authored andcommitted
bpf, ppc64: fix out of bounds access in tail call
[ upstream commit d269176 ] While working on 16338a9 ("bpf, arm64: fix out of bounds access in tail call") I noticed that ppc64 JIT is partially affected as well. While the bound checking is correctly performed as unsigned comparison, the register with the index value however, is never truncated into 32 bit space, so e.g. a index value of 0x100000000ULL with a map of 1 element would pass with PPC_CMPLW() whereas we later on continue with the full 64 bit register value. Therefore, as we do in interpreter and other JITs truncate the value to 32 bit initially in order to fix access. Fixes: ce07614 ("powerpc/bpf: Implement support for tail calls") Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Reviewed-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> Tested-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 2a8bc53 commit 2b70de4

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

arch/powerpc/net/bpf_jit_comp64.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ static void bpf_jit_emit_tail_call(u32 *image, struct codegen_context *ctx, u32
245245
* goto out;
246246
*/
247247
PPC_LWZ(b2p[TMP_REG_1], b2p_bpf_array, offsetof(struct bpf_array, map.max_entries));
248+
PPC_RLWINM(b2p_index, b2p_index, 0, 0, 31);
248249
PPC_CMPLW(b2p_index, b2p[TMP_REG_1]);
249250
PPC_BCC(COND_GE, out);
250251

0 commit comments

Comments
 (0)