[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20250506061927.95882-1-yangfeng59949@163.com>
Date: Tue, 6 May 2025 14:19:27 +0800
From: Feng Yang <yangfeng59949@....com>
To: andrii.nakryiko@...il.com
Cc: andrii@...nel.org,
ast@...nel.org,
bpf@...r.kernel.org,
daniel@...earbox.net,
davem@...emloft.net,
eddyz87@...il.com,
haoluo@...gle.com,
htejun@...com,
john.fastabend@...il.com,
jolsa@...nel.org,
kpsingh@...nel.org,
linux-kernel@...r.kernel.org,
linux-trace-kernel@...r.kernel.org,
martin.lau@...ux.dev,
mathieu.desnoyers@...icios.com,
mattbobrowski@...gle.com,
mhiramat@...nel.org,
netdev@...r.kernel.org,
rostedt@...dmis.org,
sdf@...ichev.me,
song@...nel.org,
yangfeng59949@....com,
yonghong.song@...ux.dev
Subject: Re: [PATCH v2 bpf-next] bpf: Allow some trace helpers for all prog types
On Thu, 1 May 2025 11:11:52 -0700 Andrii Nakryiko <andrii.nakryiko@...il.com> wrote:
> On Sat, Apr 26, 2025 at 11:39 PM Feng Yang <yangfeng59949@....com> wrote:
> >
> > From: Feng Yang <yangfeng@...inos.cn>
> >
> > if it works under NMI and doesn't use any context-dependent things,
> > should be fine for any program type. The detailed discussion is in [1].
> >
> > [1] https://lore.kernel.org/all/CAEf4Bza6gK3dsrTosk6k3oZgtHesNDSrDd8sdeQ-GiS6oJixQg@mail.gmail.com/
> >
> > Suggested-by: Andrii Nakryiko <andrii.nakryiko@...il.com>
> > Signed-off-by: Feng Yang <yangfeng@...inos.cn>
> > ---
> > Changes in v2:
> > - not expose compat probe read APIs to more program types.
> > - Remove the prog->sleepable check added for copy_from_user,
> > - or the summarization_freplace/might_sleep_with_might_sleep test will fail with the error "program of this type cannot use helper bpf_copy_from_user"
> > - Link to v1: https://lore.kernel.org/all/20250425080032.327477-1-yangfeng59949@163.com/
> > ---
> > kernel/bpf/cgroup.c | 6 ------
> > kernel/bpf/helpers.c | 38 +++++++++++++++++++++++++++++++++++++
> > kernel/trace/bpf_trace.c | 41 ++++------------------------------------
> > net/core/filter.c | 2 --
> > 4 files changed, 42 insertions(+), 45 deletions(-)
> >
> > diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c
> > index 84f58f3d028a..dbdad5f42761 100644
> > --- a/kernel/bpf/cgroup.c
> > +++ b/kernel/bpf/cgroup.c
> > @@ -2607,16 +2607,10 @@ const struct bpf_func_proto *
> > cgroup_current_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
> > {
> > switch (func_id) {
> > - case BPF_FUNC_get_current_uid_gid:
> > - return &bpf_get_current_uid_gid_proto;
> > - case BPF_FUNC_get_current_comm:
> > - return &bpf_get_current_comm_proto;
> > #ifdef CONFIG_CGROUP_NET_CLASSID
> > case BPF_FUNC_get_cgroup_classid:
> > return &bpf_get_cgroup_classid_curr_proto;
> > #endif
>
> this is the only one left, and again, it's just current-dependent, so
> I'd just move this into base set and got rid of
> cgroup_current_func_proto altogether (there are 5 callers, let's clean
> them up)
>
> > - case BPF_FUNC_current_task_under_cgroup:
> > - return &bpf_current_task_under_cgroup_proto;
> > default:
> > return NULL;
> > }
> > diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
> > index e3a2662f4e33..a01a2e55e17d 100644
> > --- a/kernel/bpf/helpers.c
> > +++ b/kernel/bpf/helpers.c
> > @@ -23,6 +23,7 @@
> > #include <linux/btf_ids.h>
> > #include <linux/bpf_mem_alloc.h>
> > #include <linux/kasan.h>
> > +#include <linux/bpf_verifier.h>
>
> why do we need this include?
>
> [...]
bpf_prog_check_recur in bpf_verifier.h.
Powered by blists - more mailing lists