Thread (54 messages) 54 messages, 5 authors, 2022-05-31

Re: [PATCH bpf-next v7 05/11] bpf: implement BPF_PROG_QUERY for BPF_LSM_CGROUP

From: Andrii Nakryiko <hidden>
Date: 2022-05-23 23:24:13
Also in: bpf

On Wed, May 18, 2022 at 3:55 PM Stanislav Fomichev [off-list ref] wrote:
quoted hunk ↗ jump to hunk
We have two options:
1. Treat all BPF_LSM_CGROUP the same, regardless of attach_btf_id
2. Treat BPF_LSM_CGROUP+attach_btf_id as a separate hook point

I was doing (2) in the original patch, but switching to (1) here:

* bpf_prog_query returns all attached BPF_LSM_CGROUP programs
regardless of attach_btf_id
* attach_btf_id is exported via bpf_prog_info

Signed-off-by: Stanislav Fomichev <redacted>
---
 include/uapi/linux/bpf.h |   5 ++
 kernel/bpf/cgroup.c      | 103 +++++++++++++++++++++++++++------------
 kernel/bpf/syscall.c     |   4 +-
 3 files changed, 81 insertions(+), 31 deletions(-)
diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index b9d2d6de63a7..432fc5f49567 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -1432,6 +1432,7 @@ union bpf_attr {
                __u32           attach_flags;
                __aligned_u64   prog_ids;
                __u32           prog_cnt;
+               __aligned_u64   prog_attach_flags; /* output: per-program attach_flags */
        } query;

        struct { /* anonymous struct used by BPF_RAW_TRACEPOINT_OPEN command */
@@ -5911,6 +5912,10 @@ struct bpf_prog_info {
        __u64 run_cnt;
        __u64 recursion_misses;
        __u32 verified_insns;
+       /* BTF ID of the function to attach to within BTF object identified
+        * by btf_id.
+        */
+       __u32 attach_btf_func_id;
it's called attach_btf_id for PROG_LOAD command, keep it consistently
named (and a bit more generic)?
 } __attribute__((aligned(8)));

 struct bpf_map_info {
[...]
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help