* [PATCH bpf-next] bpf: Handle NULL in bpf_local_storage_free.
@ 2023-04-12 17:12 Alexei Starovoitov
2023-04-12 17:50 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Alexei Starovoitov @ 2023-04-12 17:12 UTC (permalink / raw)
To: davem; +Cc: daniel, andrii, martin.lau, netdev, bpf, kernel-team
From: Alexei Starovoitov <ast@kernel.org>
During OOM bpf_local_storage_alloc() may fail to allocate 'storage' and
call to bpf_local_storage_free() with NULL pointer will cause a crash like:
[ 271718.917646] BUG: kernel NULL pointer dereference, address: 00000000000000a0
[ 271719.019620] RIP: 0010:call_rcu+0x2d/0x240
[ 271719.216274] bpf_local_storage_alloc+0x19e/0x1e0
[ 271719.250121] bpf_local_storage_update+0x33b/0x740
Fixes: 7e30a8477b0b ("bpf: Add bpf_local_storage_free()")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
---
kernel/bpf/bpf_local_storage.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/kernel/bpf/bpf_local_storage.c b/kernel/bpf/bpf_local_storage.c
index dab2ff4c99d9..47d9948d768f 100644
--- a/kernel/bpf/bpf_local_storage.c
+++ b/kernel/bpf/bpf_local_storage.c
@@ -157,6 +157,9 @@ static void bpf_local_storage_free(struct bpf_local_storage *local_storage,
struct bpf_local_storage_map *smap,
bool bpf_ma, bool reuse_now)
{
+ if (!local_storage)
+ return;
+
if (!bpf_ma) {
__bpf_local_storage_free(local_storage, reuse_now);
return;
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH bpf-next] bpf: Handle NULL in bpf_local_storage_free.
2023-04-12 17:12 [PATCH bpf-next] bpf: Handle NULL in bpf_local_storage_free Alexei Starovoitov
@ 2023-04-12 17:50 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-04-12 17:50 UTC (permalink / raw)
To: Alexei Starovoitov
Cc: davem, daniel, andrii, martin.lau, netdev, bpf, kernel-team
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:
On Wed, 12 Apr 2023 10:12:52 -0700 you wrote:
> From: Alexei Starovoitov <ast@kernel.org>
>
> During OOM bpf_local_storage_alloc() may fail to allocate 'storage' and
> call to bpf_local_storage_free() with NULL pointer will cause a crash like:
> [ 271718.917646] BUG: kernel NULL pointer dereference, address: 00000000000000a0
> [ 271719.019620] RIP: 0010:call_rcu+0x2d/0x240
> [ 271719.216274] bpf_local_storage_alloc+0x19e/0x1e0
> [ 271719.250121] bpf_local_storage_update+0x33b/0x740
>
> [...]
Here is the summary with links:
- [bpf-next] bpf: Handle NULL in bpf_local_storage_free.
https://git.kernel.org/bpf/bpf-next/c/10fd5f70c397
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] 2+ messages in thread
end of thread, other threads:[~2023-04-12 17:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-12 17:12 [PATCH bpf-next] bpf: Handle NULL in bpf_local_storage_free Alexei Starovoitov
2023-04-12 17:50 ` 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).