BPF List
 help / color / mirror / Atom feed
* [PATCHv2 bpf] bpf: Set run context for rawtp test_run callback
@ 2024-06-04 15:00 Jiri Olsa
  2024-06-04 17:50 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Jiri Olsa @ 2024-06-04 15:00 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko
  Cc: syzbot+3ab78ff125b7979e45f9, bpf, Martin KaFai Lau, Song Liu,
	Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
	Hao Luo, Masami Hiramatsu

syzbot reported crash when rawtp program executed through the
test_run interface calls bpf_get_attach_cookie helper or any
other helper that touches task->bpf_ctx pointer.

Setting the run context (task->bpf_ctx pointer) for test_run
callback.

Fixes: 7adfc6c9b315 ("bpf: Add bpf_get_attach_cookie() BPF helper to access bpf_cookie value")
Reported-by: syzbot+3ab78ff125b7979e45f9@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=3ab78ff125b7979e45f9
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
v2 changes:
  - setting run context for test_run callback instead of
    using __bpf_trace_run [Alexei]

 net/bpf/test_run.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
index f6aad4ed2ab2..36ae54f57bf5 100644
--- a/net/bpf/test_run.c
+++ b/net/bpf/test_run.c
@@ -727,10 +727,16 @@ static void
 __bpf_prog_test_run_raw_tp(void *data)
 {
 	struct bpf_raw_tp_test_run_info *info = data;
+	struct bpf_trace_run_ctx run_ctx = {};
+	struct bpf_run_ctx *old_run_ctx;
+
+	old_run_ctx = bpf_set_run_ctx(&run_ctx.run_ctx);
 
 	rcu_read_lock();
 	info->retval = bpf_prog_run(info->prog, info->ctx);
 	rcu_read_unlock();
+
+	bpf_reset_run_ctx(old_run_ctx);
 }
 
 int bpf_prog_test_run_raw_tp(struct bpf_prog *prog,
-- 
2.45.1


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

* Re: [PATCHv2 bpf] bpf: Set run context for rawtp test_run callback
  2024-06-04 15:00 [PATCHv2 bpf] bpf: Set run context for rawtp test_run callback Jiri Olsa
@ 2024-06-04 17:50 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-06-04 17:50 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: ast, daniel, andrii, syzbot+3ab78ff125b7979e45f9, bpf, kafai,
	songliubraving, yhs, john.fastabend, kpsingh, sdf, haoluo,
	mhiramat

Hello:

This patch was applied to bpf/bpf.git (master)
by Andrii Nakryiko <andrii@kernel.org>:

On Tue,  4 Jun 2024 17:00:24 +0200 you wrote:
> syzbot reported crash when rawtp program executed through the
> test_run interface calls bpf_get_attach_cookie helper or any
> other helper that touches task->bpf_ctx pointer.
> 
> Setting the run context (task->bpf_ctx pointer) for test_run
> callback.
> 
> [...]

Here is the summary with links:
  - [PATCHv2,bpf] bpf: Set run context for rawtp test_run callback
    https://git.kernel.org/bpf/bpf/c/f472e923bf4b

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:[~2024-06-04 17:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-04 15:00 [PATCHv2 bpf] bpf: Set run context for rawtp test_run callback Jiri Olsa
2024-06-04 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