* [PATCH bpf-next v5 0/2] bpf: enable some functions in cgroup programs @ 2024-08-13 13:28 Matteo Croce 2024-08-13 13:28 ` [PATCH bpf-next v5 1/2] bpf: enable generic kfuncs for BPF_CGROUP_* programs Matteo Croce 2024-08-13 13:28 ` [PATCH bpf-next v5 2/2] bpf: allow bpf_current_task_under_cgroup() with BPF_CGROUP_* Matteo Croce 0 siblings, 2 replies; 7+ messages in thread From: Matteo Croce @ 2024-08-13 13:28 UTC (permalink / raw) To: Andrii Nakryiko, Alexei Starovoitov, Daniel Borkmann, Steven Rostedt, Masami Hiramatsu, bpf, linux-trace-kernel Cc: linux-kernel, Matteo Croce From: Matteo Croce <teknoraver@meta.com> Enable some BPF kfuncs and the helper bpf_current_task_under_cgroup() for program types BPF_CGROUP_*. These will be used by systemd-networkd: https://github.com/systemd/systemd/pull/32212 v4->v5: Same code, but v4 had an old cover letter v3->v4: Reset all the acked-by tags because the code changed a bit. Signed-off-by: Matteo Croce <teknoraver@meta.com> Matteo Croce (2): bpf: enable generic kfuncs for BPF_CGROUP_* programs bpf: allow bpf_current_task_under_cgroup() with BPF_CGROUP_* include/linux/bpf.h | 1 + kernel/bpf/btf.c | 8 ++++++-- kernel/bpf/cgroup.c | 2 ++ kernel/bpf/helpers.c | 29 +++++++++++++++++++++++++++++ kernel/trace/bpf_trace.c | 23 ----------------------- 5 files changed, 38 insertions(+), 25 deletions(-) -- 2.46.0 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH bpf-next v5 1/2] bpf: enable generic kfuncs for BPF_CGROUP_* programs 2024-08-13 13:28 [PATCH bpf-next v5 0/2] bpf: enable some functions in cgroup programs Matteo Croce @ 2024-08-13 13:28 ` Matteo Croce 2024-08-15 22:19 ` Andrii Nakryiko 2024-08-13 13:28 ` [PATCH bpf-next v5 2/2] bpf: allow bpf_current_task_under_cgroup() with BPF_CGROUP_* Matteo Croce 1 sibling, 1 reply; 7+ messages in thread From: Matteo Croce @ 2024-08-13 13:28 UTC (permalink / raw) To: Andrii Nakryiko, Alexei Starovoitov, Daniel Borkmann, Steven Rostedt, Masami Hiramatsu, bpf, linux-trace-kernel Cc: linux-kernel, Matteo Croce From: Matteo Croce <teknoraver@meta.com> These kfuncs are enabled even in BPF_PROG_TYPE_TRACING, so they should be safe also in BPF_CGROUP_* programs. In enum btf_kfunc_hook, rename BTF_KFUNC_HOOK_CGROUP_SKB to a more generic BTF_KFUNC_HOOK_CGROUP, since it's used for all the cgroup related program types. Signed-off-by: Matteo Croce <teknoraver@meta.com> --- kernel/bpf/btf.c | 8 ++++++-- kernel/bpf/helpers.c | 6 ++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index 95426d5b634e..08d094875f00 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -212,7 +212,7 @@ enum btf_kfunc_hook { BTF_KFUNC_HOOK_TRACING, BTF_KFUNC_HOOK_SYSCALL, BTF_KFUNC_HOOK_FMODRET, - BTF_KFUNC_HOOK_CGROUP_SKB, + BTF_KFUNC_HOOK_CGROUP, BTF_KFUNC_HOOK_SCHED_ACT, BTF_KFUNC_HOOK_SK_SKB, BTF_KFUNC_HOOK_SOCKET_FILTER, @@ -8312,8 +8312,12 @@ static int bpf_prog_type_to_kfunc_hook(enum bpf_prog_type prog_type) case BPF_PROG_TYPE_SYSCALL: return BTF_KFUNC_HOOK_SYSCALL; case BPF_PROG_TYPE_CGROUP_SKB: + case BPF_PROG_TYPE_CGROUP_SOCK: + case BPF_PROG_TYPE_CGROUP_DEVICE: case BPF_PROG_TYPE_CGROUP_SOCK_ADDR: - return BTF_KFUNC_HOOK_CGROUP_SKB; + case BPF_PROG_TYPE_CGROUP_SOCKOPT: + case BPF_PROG_TYPE_CGROUP_SYSCTL: + return BTF_KFUNC_HOOK_CGROUP; case BPF_PROG_TYPE_SCHED_ACT: return BTF_KFUNC_HOOK_SCHED_ACT; case BPF_PROG_TYPE_SK_SKB: diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c index d02ae323996b..0d1d97d968b0 100644 --- a/kernel/bpf/helpers.c +++ b/kernel/bpf/helpers.c @@ -3052,6 +3052,12 @@ static int __init kfunc_init(void) ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_XDP, &generic_kfunc_set); ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, &generic_kfunc_set); ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_SYSCALL, &generic_kfunc_set); + ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_CGROUP_SKB, &generic_kfunc_set); + ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_CGROUP_SOCK, &generic_kfunc_set); + ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_CGROUP_DEVICE, &generic_kfunc_set); + ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_CGROUP_SOCK_ADDR, &generic_kfunc_set); + ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_CGROUP_SYSCTL, &generic_kfunc_set); + ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_CGROUP_SOCKOPT, &generic_kfunc_set); ret = ret ?: register_btf_id_dtor_kfuncs(generic_dtors, ARRAY_SIZE(generic_dtors), THIS_MODULE); -- 2.46.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH bpf-next v5 1/2] bpf: enable generic kfuncs for BPF_CGROUP_* programs 2024-08-13 13:28 ` [PATCH bpf-next v5 1/2] bpf: enable generic kfuncs for BPF_CGROUP_* programs Matteo Croce @ 2024-08-15 22:19 ` Andrii Nakryiko 0 siblings, 0 replies; 7+ messages in thread From: Andrii Nakryiko @ 2024-08-15 22:19 UTC (permalink / raw) To: Matteo Croce Cc: Andrii Nakryiko, Alexei Starovoitov, Daniel Borkmann, Steven Rostedt, Masami Hiramatsu, bpf, linux-trace-kernel, linux-kernel, Matteo Croce On Tue, Aug 13, 2024 at 6:28 AM Matteo Croce <technoboy85@gmail.com> wrote: > > From: Matteo Croce <teknoraver@meta.com> > > These kfuncs are enabled even in BPF_PROG_TYPE_TRACING, so they > should be safe also in BPF_CGROUP_* programs. > > In enum btf_kfunc_hook, rename BTF_KFUNC_HOOK_CGROUP_SKB to a more > generic BTF_KFUNC_HOOK_CGROUP, since it's used for all the cgroup > related program types. > > Signed-off-by: Matteo Croce <teknoraver@meta.com> > --- > kernel/bpf/btf.c | 8 ++++++-- > kernel/bpf/helpers.c | 6 ++++++ > 2 files changed, 12 insertions(+), 2 deletions(-) > > diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c > index 95426d5b634e..08d094875f00 100644 > --- a/kernel/bpf/btf.c > +++ b/kernel/bpf/btf.c > @@ -212,7 +212,7 @@ enum btf_kfunc_hook { > BTF_KFUNC_HOOK_TRACING, > BTF_KFUNC_HOOK_SYSCALL, > BTF_KFUNC_HOOK_FMODRET, > - BTF_KFUNC_HOOK_CGROUP_SKB, > + BTF_KFUNC_HOOK_CGROUP, > BTF_KFUNC_HOOK_SCHED_ACT, > BTF_KFUNC_HOOK_SK_SKB, > BTF_KFUNC_HOOK_SOCKET_FILTER, > @@ -8312,8 +8312,12 @@ static int bpf_prog_type_to_kfunc_hook(enum bpf_prog_type prog_type) > case BPF_PROG_TYPE_SYSCALL: > return BTF_KFUNC_HOOK_SYSCALL; > case BPF_PROG_TYPE_CGROUP_SKB: > + case BPF_PROG_TYPE_CGROUP_SOCK: > + case BPF_PROG_TYPE_CGROUP_DEVICE: > case BPF_PROG_TYPE_CGROUP_SOCK_ADDR: > - return BTF_KFUNC_HOOK_CGROUP_SKB; > + case BPF_PROG_TYPE_CGROUP_SOCKOPT: > + case BPF_PROG_TYPE_CGROUP_SYSCTL: > + return BTF_KFUNC_HOOK_CGROUP; > case BPF_PROG_TYPE_SCHED_ACT: > return BTF_KFUNC_HOOK_SCHED_ACT; > case BPF_PROG_TYPE_SK_SKB: > diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c > index d02ae323996b..0d1d97d968b0 100644 > --- a/kernel/bpf/helpers.c > +++ b/kernel/bpf/helpers.c > @@ -3052,6 +3052,12 @@ static int __init kfunc_init(void) > ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_XDP, &generic_kfunc_set); > ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, &generic_kfunc_set); > ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_SYSCALL, &generic_kfunc_set); > + ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_CGROUP_SKB, &generic_kfunc_set); > + ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_CGROUP_SOCK, &generic_kfunc_set); > + ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_CGROUP_DEVICE, &generic_kfunc_set); > + ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_CGROUP_SOCK_ADDR, &generic_kfunc_set); > + ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_CGROUP_SYSCTL, &generic_kfunc_set); > + ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_CGROUP_SOCKOPT, &generic_kfunc_set); So given all those CGROUP_xxx program types map to the same cgroup-generic BTF_KFUNC_HOOK_CGROUP hook, why do we need 6 repetitions of the same thing? I'd say let's keep just one (pick any, CGROUP_SKB, for example) registration. And then we should follow up with cleaning up register_btf_kfunc_id_set() to accept hook type, not program type. And then it will be clean and will make most sense. But other than that looks good to me. pw-bot: cr > ret = ret ?: register_btf_id_dtor_kfuncs(generic_dtors, > ARRAY_SIZE(generic_dtors), > THIS_MODULE); > -- > 2.46.0 > ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH bpf-next v5 2/2] bpf: allow bpf_current_task_under_cgroup() with BPF_CGROUP_* 2024-08-13 13:28 [PATCH bpf-next v5 0/2] bpf: enable some functions in cgroup programs Matteo Croce 2024-08-13 13:28 ` [PATCH bpf-next v5 1/2] bpf: enable generic kfuncs for BPF_CGROUP_* programs Matteo Croce @ 2024-08-13 13:28 ` Matteo Croce 2024-08-15 13:01 ` kernel test robot ` (2 more replies) 1 sibling, 3 replies; 7+ messages in thread From: Matteo Croce @ 2024-08-13 13:28 UTC (permalink / raw) To: Andrii Nakryiko, Alexei Starovoitov, Daniel Borkmann, Steven Rostedt, Masami Hiramatsu, bpf, linux-trace-kernel Cc: linux-kernel, Matteo Croce From: Matteo Croce <teknoraver@meta.com> The helper bpf_current_task_under_cgroup() currently is only allowed for tracing programs, allow its usage also in the BPF_CGROUP_* program types. Move the code from kernel/trace/bpf_trace.c to kernel/bpf/helpers.c, so it compiles also without CONFIG_BPF_EVENTS. This will be used in systemd-networkd to monitor the sysctl writes, and filter it's own writes from others: https://github.com/systemd/systemd/pull/32212 Signed-off-by: Matteo Croce <teknoraver@meta.com> --- include/linux/bpf.h | 1 + kernel/bpf/cgroup.c | 2 ++ kernel/bpf/helpers.c | 23 +++++++++++++++++++++++ kernel/trace/bpf_trace.c | 23 ----------------------- 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/include/linux/bpf.h b/include/linux/bpf.h index b9425e410bcb..f0192c173ed8 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -3206,6 +3206,7 @@ extern const struct bpf_func_proto bpf_sock_hash_update_proto; extern const struct bpf_func_proto bpf_get_current_cgroup_id_proto; extern const struct bpf_func_proto bpf_get_current_ancestor_cgroup_id_proto; extern const struct bpf_func_proto bpf_get_cgroup_classid_curr_proto; +extern const struct bpf_func_proto bpf_current_task_under_cgroup_proto; extern const struct bpf_func_proto bpf_msg_redirect_hash_proto; extern const struct bpf_func_proto bpf_msg_redirect_map_proto; extern const struct bpf_func_proto bpf_sk_redirect_hash_proto; diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c index 8ba73042a239..e7113d700b87 100644 --- a/kernel/bpf/cgroup.c +++ b/kernel/bpf/cgroup.c @@ -2581,6 +2581,8 @@ cgroup_current_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) case BPF_FUNC_get_cgroup_classid: return &bpf_get_cgroup_classid_curr_proto; #endif + 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 0d1d97d968b0..8502cfed2926 100644 --- a/kernel/bpf/helpers.c +++ b/kernel/bpf/helpers.c @@ -2458,6 +2458,29 @@ __bpf_kfunc long bpf_task_under_cgroup(struct task_struct *task, return ret; } +BPF_CALL_2(bpf_current_task_under_cgroup, struct bpf_map *, map, u32, idx) +{ + struct bpf_array *array = container_of(map, struct bpf_array, map); + struct cgroup *cgrp; + + if (unlikely(idx >= array->map.max_entries)) + return -E2BIG; + + cgrp = READ_ONCE(array->ptrs[idx]); + if (unlikely(!cgrp)) + return -EAGAIN; + + return task_under_cgroup_hierarchy(current, cgrp); +} + +const struct bpf_func_proto bpf_current_task_under_cgroup_proto = { + .func = bpf_current_task_under_cgroup, + .gpl_only = false, + .ret_type = RET_INTEGER, + .arg1_type = ARG_CONST_MAP_PTR, + .arg2_type = ARG_ANYTHING, +}; + /** * bpf_task_get_cgroup1 - Acquires the associated cgroup of a task within a * specific cgroup1 hierarchy. The cgroup1 hierarchy is identified by its diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index d557bb11e0ff..e4e1f5d8b2a6 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c @@ -797,29 +797,6 @@ const struct bpf_func_proto bpf_task_pt_regs_proto = { .ret_btf_id = &bpf_task_pt_regs_ids[0], }; -BPF_CALL_2(bpf_current_task_under_cgroup, struct bpf_map *, map, u32, idx) -{ - struct bpf_array *array = container_of(map, struct bpf_array, map); - struct cgroup *cgrp; - - if (unlikely(idx >= array->map.max_entries)) - return -E2BIG; - - cgrp = READ_ONCE(array->ptrs[idx]); - if (unlikely(!cgrp)) - return -EAGAIN; - - return task_under_cgroup_hierarchy(current, cgrp); -} - -static const struct bpf_func_proto bpf_current_task_under_cgroup_proto = { - .func = bpf_current_task_under_cgroup, - .gpl_only = false, - .ret_type = RET_INTEGER, - .arg1_type = ARG_CONST_MAP_PTR, - .arg2_type = ARG_ANYTHING, -}; - struct send_signal_irq_work { struct irq_work irq_work; struct task_struct *task; -- 2.46.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH bpf-next v5 2/2] bpf: allow bpf_current_task_under_cgroup() with BPF_CGROUP_* 2024-08-13 13:28 ` [PATCH bpf-next v5 2/2] bpf: allow bpf_current_task_under_cgroup() with BPF_CGROUP_* Matteo Croce @ 2024-08-15 13:01 ` kernel test robot 2024-08-15 22:23 ` Andrii Nakryiko 2024-08-16 5:45 ` kernel test robot 2 siblings, 0 replies; 7+ messages in thread From: kernel test robot @ 2024-08-15 13:01 UTC (permalink / raw) To: Matteo Croce, Andrii Nakryiko, Alexei Starovoitov, Daniel Borkmann, Steven Rostedt, Masami Hiramatsu, bpf, linux-trace-kernel Cc: oe-kbuild-all, linux-kernel, Matteo Croce Hi Matteo, kernel test robot noticed the following build errors: [auto build test ERROR on bpf-next/master] url: https://github.com/intel-lab-lkp/linux/commits/Matteo-Croce/bpf-enable-generic-kfuncs-for-BPF_CGROUP_-programs/20240815-000517 base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master patch link: https://lore.kernel.org/r/20240813132831.184362-3-technoboy85%40gmail.com patch subject: [PATCH bpf-next v5 2/2] bpf: allow bpf_current_task_under_cgroup() with BPF_CGROUP_* config: arm-randconfig-003-20240815 (https://download.01.org/0day-ci/archive/20240815/202408152026.xtFpPaaI-lkp@intel.com/config) compiler: arm-linux-gnueabi-gcc (GCC) 14.1.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240815/202408152026.xtFpPaaI-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202408152026.xtFpPaaI-lkp@intel.com/ All errors (new ones prefixed by >>): arm-linux-gnueabi-ld: kernel/trace/bpf_trace.o: in function `bpf_tracing_func_proto': >> bpf_trace.c:(.text+0x41bc): undefined reference to `bpf_current_task_under_cgroup_proto' -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH bpf-next v5 2/2] bpf: allow bpf_current_task_under_cgroup() with BPF_CGROUP_* 2024-08-13 13:28 ` [PATCH bpf-next v5 2/2] bpf: allow bpf_current_task_under_cgroup() with BPF_CGROUP_* Matteo Croce 2024-08-15 13:01 ` kernel test robot @ 2024-08-15 22:23 ` Andrii Nakryiko 2024-08-16 5:45 ` kernel test robot 2 siblings, 0 replies; 7+ messages in thread From: Andrii Nakryiko @ 2024-08-15 22:23 UTC (permalink / raw) To: Matteo Croce Cc: Andrii Nakryiko, Alexei Starovoitov, Daniel Borkmann, Steven Rostedt, Masami Hiramatsu, bpf, linux-trace-kernel, linux-kernel, Matteo Croce On Tue, Aug 13, 2024 at 6:28 AM Matteo Croce <technoboy85@gmail.com> wrote: > > From: Matteo Croce <teknoraver@meta.com> > > The helper bpf_current_task_under_cgroup() currently is only allowed for > tracing programs, allow its usage also in the BPF_CGROUP_* program types. > > Move the code from kernel/trace/bpf_trace.c to kernel/bpf/helpers.c, > so it compiles also without CONFIG_BPF_EVENTS. > > This will be used in systemd-networkd to monitor the sysctl writes, > and filter it's own writes from others: > https://github.com/systemd/systemd/pull/32212 > > Signed-off-by: Matteo Croce <teknoraver@meta.com> > --- > include/linux/bpf.h | 1 + > kernel/bpf/cgroup.c | 2 ++ > kernel/bpf/helpers.c | 23 +++++++++++++++++++++++ > kernel/trace/bpf_trace.c | 23 ----------------------- > 4 files changed, 26 insertions(+), 23 deletions(-) > > diff --git a/include/linux/bpf.h b/include/linux/bpf.h > index b9425e410bcb..f0192c173ed8 100644 > --- a/include/linux/bpf.h > +++ b/include/linux/bpf.h > @@ -3206,6 +3206,7 @@ extern const struct bpf_func_proto bpf_sock_hash_update_proto; > extern const struct bpf_func_proto bpf_get_current_cgroup_id_proto; > extern const struct bpf_func_proto bpf_get_current_ancestor_cgroup_id_proto; > extern const struct bpf_func_proto bpf_get_cgroup_classid_curr_proto; > +extern const struct bpf_func_proto bpf_current_task_under_cgroup_proto; > extern const struct bpf_func_proto bpf_msg_redirect_hash_proto; > extern const struct bpf_func_proto bpf_msg_redirect_map_proto; > extern const struct bpf_func_proto bpf_sk_redirect_hash_proto; > diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c > index 8ba73042a239..e7113d700b87 100644 > --- a/kernel/bpf/cgroup.c > +++ b/kernel/bpf/cgroup.c > @@ -2581,6 +2581,8 @@ cgroup_current_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) > case BPF_FUNC_get_cgroup_classid: > return &bpf_get_cgroup_classid_curr_proto; > #endif > + 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 0d1d97d968b0..8502cfed2926 100644 > --- a/kernel/bpf/helpers.c > +++ b/kernel/bpf/helpers.c > @@ -2458,6 +2458,29 @@ __bpf_kfunc long bpf_task_under_cgroup(struct task_struct *task, > return ret; > } > > +BPF_CALL_2(bpf_current_task_under_cgroup, struct bpf_map *, map, u32, idx) > +{ > + struct bpf_array *array = container_of(map, struct bpf_array, map); > + struct cgroup *cgrp; > + > + if (unlikely(idx >= array->map.max_entries)) > + return -E2BIG; > + > + cgrp = READ_ONCE(array->ptrs[idx]); > + if (unlikely(!cgrp)) > + return -EAGAIN; > + > + return task_under_cgroup_hierarchy(current, cgrp); > +} > + > +const struct bpf_func_proto bpf_current_task_under_cgroup_proto = { > + .func = bpf_current_task_under_cgroup, > + .gpl_only = false, > + .ret_type = RET_INTEGER, > + .arg1_type = ARG_CONST_MAP_PTR, > + .arg2_type = ARG_ANYTHING, > +}; > + > /** > * bpf_task_get_cgroup1 - Acquires the associated cgroup of a task within a > * specific cgroup1 hierarchy. The cgroup1 hierarchy is identified by its > diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c > index d557bb11e0ff..e4e1f5d8b2a6 100644 > --- a/kernel/trace/bpf_trace.c > +++ b/kernel/trace/bpf_trace.c > @@ -797,29 +797,6 @@ const struct bpf_func_proto bpf_task_pt_regs_proto = { > .ret_btf_id = &bpf_task_pt_regs_ids[0], > }; > > -BPF_CALL_2(bpf_current_task_under_cgroup, struct bpf_map *, map, u32, idx) > -{ > - struct bpf_array *array = container_of(map, struct bpf_array, map); > - struct cgroup *cgrp; > - > - if (unlikely(idx >= array->map.max_entries)) > - return -E2BIG; > - > - cgrp = READ_ONCE(array->ptrs[idx]); > - if (unlikely(!cgrp)) > - return -EAGAIN; > - > - return task_under_cgroup_hierarchy(current, cgrp); > -} > - > -static const struct bpf_func_proto bpf_current_task_under_cgroup_proto = { > - .func = bpf_current_task_under_cgroup, > - .gpl_only = false, > - .ret_type = RET_INTEGER, > - .arg1_type = ARG_CONST_MAP_PTR, > - .arg2_type = ARG_ANYTHING, > -}; > - Seems like you need to adjust bpf_tracing_func_proto() function and move BPF_FUNC_current_task_under_cgroup into #ifdef CONFIG_CGROUPS block together with cgrp_storage_get and delete. > struct send_signal_irq_work { > struct irq_work irq_work; > struct task_struct *task; > -- > 2.46.0 > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH bpf-next v5 2/2] bpf: allow bpf_current_task_under_cgroup() with BPF_CGROUP_* 2024-08-13 13:28 ` [PATCH bpf-next v5 2/2] bpf: allow bpf_current_task_under_cgroup() with BPF_CGROUP_* Matteo Croce 2024-08-15 13:01 ` kernel test robot 2024-08-15 22:23 ` Andrii Nakryiko @ 2024-08-16 5:45 ` kernel test robot 2 siblings, 0 replies; 7+ messages in thread From: kernel test robot @ 2024-08-16 5:45 UTC (permalink / raw) To: Matteo Croce, Andrii Nakryiko, Alexei Starovoitov, Daniel Borkmann, Steven Rostedt, Masami Hiramatsu, bpf, linux-trace-kernel Cc: llvm, oe-kbuild-all, linux-kernel, Matteo Croce Hi Matteo, kernel test robot noticed the following build errors: [auto build test ERROR on bpf-next/master] url: https://github.com/intel-lab-lkp/linux/commits/Matteo-Croce/bpf-enable-generic-kfuncs-for-BPF_CGROUP_-programs/20240815-000517 base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master patch link: https://lore.kernel.org/r/20240813132831.184362-3-technoboy85%40gmail.com patch subject: [PATCH bpf-next v5 2/2] bpf: allow bpf_current_task_under_cgroup() with BPF_CGROUP_* config: i386-buildonly-randconfig-002-20240816 (https://download.01.org/0day-ci/archive/20240816/202408161356.OvFB1jZi-lkp@intel.com/config) compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240816/202408161356.OvFB1jZi-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202408161356.OvFB1jZi-lkp@intel.com/ All errors (new ones prefixed by >>): >> ld.lld: error: undefined symbol: bpf_current_task_under_cgroup_proto >>> referenced by bpf_trace.c >>> kernel/trace/bpf_trace.o:(bpf_tracing_func_proto) in archive vmlinux.a -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-08-16 5:45 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-08-13 13:28 [PATCH bpf-next v5 0/2] bpf: enable some functions in cgroup programs Matteo Croce 2024-08-13 13:28 ` [PATCH bpf-next v5 1/2] bpf: enable generic kfuncs for BPF_CGROUP_* programs Matteo Croce 2024-08-15 22:19 ` Andrii Nakryiko 2024-08-13 13:28 ` [PATCH bpf-next v5 2/2] bpf: allow bpf_current_task_under_cgroup() with BPF_CGROUP_* Matteo Croce 2024-08-15 13:01 ` kernel test robot 2024-08-15 22:23 ` Andrii Nakryiko 2024-08-16 5:45 ` kernel test robot
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).