[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230427111842.2e40fe3c@gandalf.local.home>
Date: Thu, 27 Apr 2023 11:18:42 -0400
From: Steven Rostedt <rostedt@...dmis.org>
To: Yafang Shao <laoar.shao@...il.com>
Cc: ast@...nel.org, daniel@...earbox.net, andrii@...nel.org,
kafai@...com, songliubraving@...com, yhs@...com,
john.fastabend@...il.com, kpsingh@...nel.org, sdf@...gle.com,
haoluo@...gle.com, jolsa@...nel.org, mhiramat@...nel.org,
bpf@...r.kernel.org, linux-trace-kernel@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH bpf-next 5/6] bpf: Improve tracing recursion prevention
mechanism
On Thu, 27 Apr 2023 22:22:22 +0800
Yafang Shao <laoar.shao@...il.com> wrote:
> IIUC, the acquire/release pair works as follows,
>
> test_recursion_try_acquire
> [ protection area ]
> test_recursion_release
>
> After release, there will be no protection, and thus it will fail the
> tools/testing/selftests/bpf/progs/recursion.c[1] test case, because
> the recursion occurs in the bpf_prog_run() itself,
But bpf programs are allowed to recurs. Hence, you need separate logic to
detect that. The test_recursion_*() code is for cases that are not allowed
to recurs.
>
> __bpf_prog_enter
> test_recursion_try_acquire
> [...]
> test_recursion_release
> // no protection after the release
> bpf_prog_run()
> bpf_prog_run() // the recursion can't be prevented.
But I thought you can run a bpf_prog from another bpf_prog. So you don't
want to prevent it. You need other logic to detect if it was not suppose to
recurs.
-- Steve
> __bpf_prog_enter
> test_recursion_try_acquire
> [...]
> test_recursion_release
> bpf_prog_run()
> bpf_prog_run()
> __bpf_prog_enter
> test_recursion_try_acquire
> [...]
> test_recursion_release
> bpf_prog_run()
> [ And so on ... ]
>
> [1]. https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/tree/tools/testing/selftests/bpf/progs/recursion.c#n38
Powered by blists - more mailing lists