• Stanislav Fomichev's avatar
    bpftool: implement cgroup tree for BPF_LSM_CGROUP · 596f5fb2
    Stanislav Fomichev authored
    $ bpftool --nomount prog loadall $KDIR/tools/testing/selftests/bpf/lsm_cgroup.o /sys/fs/bpf/x
    $ bpftool cgroup attach /sys/fs/cgroup lsm_cgroup pinned /sys/fs/bpf/x/socket_alloc
    $ bpftool cgroup attach /sys/fs/cgroup lsm_cgroup pinned /sys/fs/bpf/x/socket_bind
    $ bpftool cgroup attach /sys/fs/cgroup lsm_cgroup pinned /sys/fs/bpf/x/socket_clone
    $ bpftool cgroup attach /sys/fs/cgroup lsm_cgroup pinned /sys/fs/bpf/x/socket_post_create
    $ bpftool cgroup tree
    CgroupPath
    ID       AttachType      AttachFlags     Name
    /sys/fs/cgroup
    6        lsm_cgroup                      socket_post_create bpf_lsm_socket_post_create
    8        lsm_cgroup                      socket_bind     bpf_lsm_socket_bind
    10       lsm_cgroup                      socket_alloc    bpf_lsm_sk_alloc_security
    11       lsm_cgroup                      socket_clone    bpf_lsm_inet_csk_clone
    
    $ bpftool cgroup detach /sys/fs/cgroup lsm_cgroup pinned /sys/fs/bpf/x/socket_post_create
    $ bpftool cgroup tree
    CgroupPath
    ID       AttachType      AttachFlags     Name
    /sys/fs/cgroup
    8        lsm_cgroup                      socket_bind     bpf_lsm_socket_bind
    10       lsm_cgroup                      socket_alloc    bpf_lsm_sk_alloc_security
    11       lsm_cgroup                      socket_clone    bpf_lsm_inet_csk_clone
    Reviewed-by: default avatarQuentin Monnet <quentin@isovalent.com>
    Acked-by: default avatarMartin KaFai Lau <kafai@fb.com>
    Signed-off-by: default avatarStanislav Fomichev <sdf@google.com>
    Link: https://lore.kernel.org/r/20220628174314.1216643-11-sdf@google.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    596f5fb2
cgroup.c 13.5 KB