* [PATCH bpf] riscv, bpf: Fix potential NULL dereference
@ 2021-10-28 12:51 Björn Töpel
2021-10-28 15:16 ` Jakub Kicinski
2021-10-28 15:40 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Björn Töpel @ 2021-10-28 12:51 UTC (permalink / raw)
To: ast, daniel, netdev, bpf; +Cc: Björn Töpel, linux-riscv
The bpf_jit_binary_free() function requires a non-NULL argument. When
the RISC-V BPF JIT fails to converge in NR_JIT_ITERATIONS steps,
jit_data->header will be NULL, which triggers a NULL
dereference. Avoid this by checking the argument, prior calling the
function.
Fixes: ca6cb5447cec ("riscv, bpf: Factor common RISC-V JIT code")
Signed-off-by: Björn Töpel <bjorn@kernel.org>
---
arch/riscv/net/bpf_jit_core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/riscv/net/bpf_jit_core.c b/arch/riscv/net/bpf_jit_core.c
index 0fee2cbaaf53..753d85bdfad0 100644
--- a/arch/riscv/net/bpf_jit_core.c
+++ b/arch/riscv/net/bpf_jit_core.c
@@ -125,7 +125,8 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
if (i == NR_JIT_ITERATIONS) {
pr_err("bpf-jit: image did not converge in <%d passes!\n", i);
- bpf_jit_binary_free(jit_data->header);
+ if (jit_data->header)
+ bpf_jit_binary_free(jit_data->header);
prog = orig_prog;
goto out_offset;
}
base-commit: 72f898ca0ab85fde6facf78b14d9f67a4a7b32d1
--
2.32.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH bpf] riscv, bpf: Fix potential NULL dereference
2021-10-28 12:51 [PATCH bpf] riscv, bpf: Fix potential NULL dereference Björn Töpel
@ 2021-10-28 15:16 ` Jakub Kicinski
2021-10-28 15:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2021-10-28 15:16 UTC (permalink / raw)
To: Björn Töpel; +Cc: ast, daniel, netdev, bpf, linux-riscv
On Thu, 28 Oct 2021 14:51:15 +0200 Björn Töpel wrote:
> The bpf_jit_binary_free() function requires a non-NULL argument. When
> the RISC-V BPF JIT fails to converge in NR_JIT_ITERATIONS steps,
> jit_data->header will be NULL, which triggers a NULL
> dereference. Avoid this by checking the argument, prior calling the
> function.
>
> Fixes: ca6cb5447cec ("riscv, bpf: Factor common RISC-V JIT code")
> Signed-off-by: Björn Töpel <bjorn@kernel.org>
Looks pretty trivial so applied to net with Daniel's off-list blessing.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH bpf] riscv, bpf: Fix potential NULL dereference
2021-10-28 12:51 [PATCH bpf] riscv, bpf: Fix potential NULL dereference Björn Töpel
2021-10-28 15:16 ` Jakub Kicinski
@ 2021-10-28 15:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-10-28 15:40 UTC (permalink / raw)
To: =?utf-8?b?QmrDtnJuIFTDtnBlbCA8Ympvcm5Aa2VybmVsLm9yZz4=?=
Cc: ast, daniel, netdev, bpf, linux-riscv
Hello:
This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 28 Oct 2021 14:51:15 +0200 you wrote:
> The bpf_jit_binary_free() function requires a non-NULL argument. When
> the RISC-V BPF JIT fails to converge in NR_JIT_ITERATIONS steps,
> jit_data->header will be NULL, which triggers a NULL
> dereference. Avoid this by checking the argument, prior calling the
> function.
>
> Fixes: ca6cb5447cec ("riscv, bpf: Factor common RISC-V JIT code")
> Signed-off-by: Björn Töpel <bjorn@kernel.org>
>
> [...]
Here is the summary with links:
- [bpf] riscv, bpf: Fix potential NULL dereference
https://git.kernel.org/netdev/net/c/27de809a3d83
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-10-28 15:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-28 12:51 [PATCH bpf] riscv, bpf: Fix potential NULL dereference Björn Töpel
2021-10-28 15:16 ` Jakub Kicinski
2021-10-28 15:40 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).