public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next v2 0/2] Fix cgroup attach flags being assigned to effective progs
@ 2022-09-08 14:53 Pu Lehui
  2022-09-08 14:53 ` [PATCH bpf-next v2 1/2] bpf, cgroup: Fix " Pu Lehui
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Pu Lehui @ 2022-09-08 14:53 UTC (permalink / raw)
  To: bpf, linux-kernel
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Quentin Monnet, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Pu Lehui

From: Pu Lehui <pulehui@huawei.com>

When root-cgroup attach multi progs and sub-cgroup attach a
override prog, bpftool will display incorrectly for the attach
flags of the sub-cgroup’s effective progs:

$ bpftool cgroup tree /sys/fs/cgroup effective
CgroupPath
ID       AttachType      AttachFlags     Name
/sys/fs/cgroup
6        cgroup_sysctl   multi           sysctl_tcp_mem
13       cgroup_sysctl   multi           sysctl_tcp_mem
/sys/fs/cgroup/cg1
20       cgroup_sysctl   override        sysctl_tcp_mem
6        cgroup_sysctl   override        sysctl_tcp_mem <- wrong
13       cgroup_sysctl   override        sysctl_tcp_mem <- wrong
/sys/fs/cgroup/cg1/cg2
20       cgroup_sysctl                   sysctl_tcp_mem
6        cgroup_sysctl                   sysctl_tcp_mem
13       cgroup_sysctl                   sysctl_tcp_mem

For cg1, obviously, the attach flags of prog6 and prog13 can not be
OVERRIDE, and the attach flags of prog6 and prog13 is meaningless for
cg1. We only need to care the attach flags of prog which attached to
cg1, other progs attach flags should be omit. After these patches,
the above situation will show as bellow:

$ bpftool cgroup tree /sys/fs/cgroup effective
CgroupPath
ID       AttachType      AttachFlags     Name
/sys/fs/cgroup
6        cgroup_sysctl   multi           sysctl_tcp_mem
13       cgroup_sysctl   multi           sysctl_tcp_mem
/sys/fs/cgroup/cg1
20       cgroup_sysctl   override        sysctl_tcp_mem
6        cgroup_sysctl                   sysctl_tcp_mem
13       cgroup_sysctl                   sysctl_tcp_mem
/sys/fs/cgroup/cg1/cg2
20       cgroup_sysctl                   sysctl_tcp_mem
6        cgroup_sysctl                   sysctl_tcp_mem
13       cgroup_sysctl                   sysctl_tcp_mem

v2:
- Limit prog_cnt to avoid overflow. (John)
- Add more detail message.

v1:
https://lore.kernel.org/bpf/20220820120234.2121044-1-pulehui@huawei.com

Pu Lehui (2):
  bpf, cgroup: Fix attach flags being assigned to effective progs
  bpftool: Fix cgroup attach flags being assigned to effective progs

 kernel/bpf/cgroup.c        | 5 ++++-
 tools/bpf/bpftool/cgroup.c | 9 +++------
 2 files changed, 7 insertions(+), 7 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-09-13 13:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-08 14:53 [PATCH bpf-next v2 0/2] Fix cgroup attach flags being assigned to effective progs Pu Lehui
2022-09-08 14:53 ` [PATCH bpf-next v2 1/2] bpf, cgroup: Fix " Pu Lehui
2022-09-08 14:53 ` [PATCH bpf-next v2 2/2] bpftool: Fix cgroup " Pu Lehui
2022-09-08 17:28 ` [PATCH bpf-next v2 0/2] " sdf
2022-09-08 19:13   ` Martin KaFai Lau
2022-09-13 13:35   ` Pu Lehui

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox