public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: sdf@google.com
To: Pu Lehui <pulehui@huaweicloud.com>
Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Quentin Monnet <quentin@isovalent.com>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Song Liu <song@kernel.org>, Yonghong Song <yhs@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>, Hao Luo <haoluo@google.com>,
	Jiri Olsa <jolsa@kernel.org>, Pu Lehui <pulehui@huawei.com>
Subject: Re: [PATCH bpf-next v2 0/2] Fix cgroup attach flags being assigned to effective progs
Date: Thu, 8 Sep 2022 10:28:06 -0700	[thread overview]
Message-ID: <YxomJlABk3fzQ9bQ@google.com> (raw)
In-Reply-To: <20220908145304.3436139-1-pulehui@huaweicloud.com>

On 09/08, Pu Lehui wrote:
> 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.

John also raised a good question in v1: the flags don't seem to
make sense when requesting effective list. So maybe not export them
at all?

> 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


  parent reply	other threads:[~2022-09-08 17:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` sdf [this message]
2022-09-08 19:13   ` [PATCH bpf-next v2 0/2] " Martin KaFai Lau
2022-09-13 13:35   ` Pu Lehui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YxomJlABk3fzQ9bQ@google.com \
    --to=sdf@google.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=pulehui@huawei.com \
    --cc=pulehui@huaweicloud.com \
    --cc=quentin@isovalent.com \
    --cc=song@kernel.org \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox