diff options
| author | Hengqi Chen <hengqi.chen@gmail.com> | 2025-10-02 22:39:53 +0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-10-15 12:04:19 +0200 |
| commit | 5c3fc72bf4715c30b3762e5009f4999813035626 (patch) | |
| tree | dfd9786c9c70795d13cfcba3483a2072d8154d3a | |
| parent | 31bc07df75c191b04ab559f22aa7317d3d33fdb0 (diff) | |
| download | linux-5c3fc72bf4715c30b3762e5009f4999813035626.tar.gz linux-5c3fc72bf4715c30b3762e5009f4999813035626.tar.bz2 linux-5c3fc72bf4715c30b3762e5009f4999813035626.zip | |
LoongArch: BPF: Make error handling robust in arch_prepare_bpf_trampoline()
commit de2c0b7788648850b68b75f7cc8698b2749dd31e upstream.
Bail out instead of trying to perform a bpf_arch_text_copy() if
__arch_prepare_bpf_trampoline() failed.
Cc: stable@vger.kernel.org
Tested-by: Vincent Li <vincent.mc.li@gmail.com>
Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| -rw-r--r-- | arch/loongarch/net/bpf_jit.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/arch/loongarch/net/bpf_jit.c b/arch/loongarch/net/bpf_jit.c index 8d534a0dad87..a81a5d28a821 100644 --- a/arch/loongarch/net/bpf_jit.c +++ b/arch/loongarch/net/bpf_jit.c @@ -1756,7 +1756,10 @@ int arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *ro_image, jit_fill_hole(image, (unsigned int)(ro_image_end - ro_image)); ret = __arch_prepare_bpf_trampoline(&ctx, im, m, tlinks, func_addr, flags); - if (ret > 0 && validate_code(&ctx) < 0) { + if (ret < 0) + goto out; + + if (validate_code(&ctx) < 0) { ret = -EINVAL; goto out; } |
