diff options
author | Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> | 2022-02-14 11:41:37 +0100 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2022-03-07 14:04:57 +0100 |
commit | 0ffdbce6f4a89bb7c0002904d6438ec83cf05ce7 (patch) | |
tree | e88144eb98064f6eda5a1cd6fae4fa41d0f56c5c /arch/powerpc/net/bpf_jit_comp32.c | |
parent | powerpc/bpf: Emit a single branch instruction for known short branch ranges (diff) | |
download | linux-0ffdbce6f4a89bb7c0002904d6438ec83cf05ce7.tar.xz linux-0ffdbce6f4a89bb7c0002904d6438ec83cf05ce7.zip |
powerpc/bpf: Handle large branch ranges with BPF_EXIT
In some scenarios, it is possible that the program epilogue is outside
the branch range for a BPF_EXIT instruction. Instead of rejecting such
programs, emit epilogue as an alternate exit point from the program.
Track the location of the same so that subsequent exits can take either
of the two paths.
Reported-by: Jordan Niethe <jniethe5@gmail.com>
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/33aa2e92645a92712be23b18035a2c6dcb92ff8d.1644834730.git.naveen.n.rao@linux.vnet.ibm.com
Diffstat (limited to 'arch/powerpc/net/bpf_jit_comp32.c')
-rw-r--r-- | arch/powerpc/net/bpf_jit_comp32.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/arch/powerpc/net/bpf_jit_comp32.c b/arch/powerpc/net/bpf_jit_comp32.c index 5ba5340a6387..8e743b7bf8f5 100644 --- a/arch/powerpc/net/bpf_jit_comp32.c +++ b/arch/powerpc/net/bpf_jit_comp32.c @@ -937,8 +937,11 @@ int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, struct codegen_context * * the epilogue. If we _are_ the last instruction, * we'll just fall through to the epilogue. */ - if (i != flen - 1) - PPC_JMP(exit_addr); + if (i != flen - 1) { + ret = bpf_jit_emit_exit_insn(image, ctx, _R0, exit_addr); + if (ret) + return ret; + } /* else fall through to the epilogue */ break; |