public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bpf: fix range_tree_set error handling
@ 2025-01-06 23:15 Soma Nakata
  2025-01-07  6:15 ` Hou Tao
  2025-01-08 17:40 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Soma Nakata @ 2025-01-06 23:15 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa
  Cc: Soma Nakata, bpf, linux-kernel

`range_tree_set` might fail and return -ENOMEM,
causing subsequent `bpf_arena_alloc_pages` to fail.
Added the error handling.

Signed-off-by: Soma Nakata <soma.nakata@somane.sakura.ne.jp>
---
 kernel/bpf/arena.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/kernel/bpf/arena.c b/kernel/bpf/arena.c
index 41a76ca56040..4b22a651b5d5 100644
--- a/kernel/bpf/arena.c
+++ b/kernel/bpf/arena.c
@@ -138,7 +138,11 @@ static struct bpf_map *arena_map_alloc(union bpf_attr *attr)
 	INIT_LIST_HEAD(&arena->vma_list);
 	bpf_map_init_from_attr(&arena->map, attr);
 	range_tree_init(&arena->rt);
-	range_tree_set(&arena->rt, 0, attr->max_entries);
+	err = range_tree_set(&arena->rt, 0, attr->max_entries);
+	if (err) {
+		bpf_map_area_free(arena);
+		goto err;
+	}
 	mutex_init(&arena->lock);
 
 	return &arena->map;
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] bpf: fix range_tree_set error handling
  2025-01-06 23:15 [PATCH] bpf: fix range_tree_set error handling Soma Nakata
@ 2025-01-07  6:15 ` Hou Tao
  2025-01-08 17:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Hou Tao @ 2025-01-07  6:15 UTC (permalink / raw)
  To: Soma Nakata
  Cc: bpf, linux-kernel, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu,
	Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
	Hao Luo, Jiri Olsa



On 1/7/2025 7:15 AM, Soma Nakata wrote:
> `range_tree_set` might fail and return -ENOMEM,
> causing subsequent `bpf_arena_alloc_pages` to fail.
> Added the error handling.
>
> Signed-off-by: Soma Nakata <soma.nakata@somane.sakura.ne.jp>
> ---
>  kernel/bpf/arena.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/bpf/arena.c b/kernel/bpf/arena.c
> index 41a76ca56040..4b22a651b5d5 100644
> --- a/kernel/bpf/arena.c
> +++ b/kernel/bpf/arena.c
> @@ -138,7 +138,11 @@ static struct bpf_map *arena_map_alloc(union bpf_attr *attr)
>  	INIT_LIST_HEAD(&arena->vma_list);
>  	bpf_map_init_from_attr(&arena->map, attr);
>  	range_tree_init(&arena->rt);
> -	range_tree_set(&arena->rt, 0, attr->max_entries);
> +	err = range_tree_set(&arena->rt, 0, attr->max_entries);
> +	if (err) {
> +		bpf_map_area_free(arena);
> +		goto err;
> +	}
>  	mutex_init(&arena->lock);
>  
>  	return &arena->map;

The fix is straightforward, so

Acked-by: Hou Tao <houtao1@huawei.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] bpf: fix range_tree_set error handling
  2025-01-06 23:15 [PATCH] bpf: fix range_tree_set error handling Soma Nakata
  2025-01-07  6:15 ` Hou Tao
@ 2025-01-08 17:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-01-08 17:40 UTC (permalink / raw)
  To: Soma Nakata
  Cc: ast, daniel, andrii, martin.lau, eddyz87, song, yonghong.song,
	john.fastabend, kpsingh, sdf, haoluo, jolsa, bpf, linux-kernel

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:

On Tue,  7 Jan 2025 08:15:35 +0900 you wrote:
> `range_tree_set` might fail and return -ENOMEM,
> causing subsequent `bpf_arena_alloc_pages` to fail.
> Added the error handling.
> 
> Signed-off-by: Soma Nakata <soma.nakata@somane.sakura.ne.jp>
> ---
>  kernel/bpf/arena.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)

Here is the summary with links:
  - bpf: fix range_tree_set error handling
    https://git.kernel.org/bpf/bpf-next/c/b8b1e3001626

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:[~2025-01-08 17:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-06 23:15 [PATCH] bpf: fix range_tree_set error handling Soma Nakata
2025-01-07  6:15 ` Hou Tao
2025-01-08 17: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