Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp229985rwn; Thu, 8 Sep 2022 00:08:05 -0700 (PDT) X-Google-Smtp-Source: AA6agR7VfiAVACFQkE23rqRXObeRA08rVkGSYHxbI+Z1J5sJbKAtUGHANksEdq5+4EFJ9cyLMz9u X-Received: by 2002:aa7:cd14:0:b0:44e:2335:fb90 with SMTP id b20-20020aa7cd14000000b0044e2335fb90mr5776325edw.152.1662620885126; Thu, 08 Sep 2022 00:08:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662620885; cv=none; d=google.com; s=arc-20160816; b=Uvuj4FccTy+tqBn2jL3NuT/DV8SE8PxvdVumSwM6eOnzCdGZsNUTYbf0oWaggLBZdi udJn6jGpjVyvuVPlsq0VAq82BwMRxv/jMwvdilTa+eWvTuaInyRbLWZ+OFXg1nSCN/r7 lxJakvxbBZdfOGNqRaWYf0c7zeDo/jIwnUQ3eIVejmmaMpsEAaHUJczoFhrvVEBuD2tT wh2U5cAvsE4A4YUuL2BtYrjIDpOyLF55GkJd4TIrNUB8aDkrmVPb/dcPie2qAU1J8IcT zfQIn4auyRObjJGTH2LLqiiC4C5rDkBrjhdepuoz6zD3etvRDY5TuJVotx7GQu7W5kTT sAPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=V+OLF8aU7ZT1/FFpaINoqQvBRss4UVp/nRcJuTyeERM=; b=iI7MYY7WVOtE9I9GWnzHUteAOcf0NTXZSJG8BQ7jvuWx/BgD26mds82x2Ra/Vb7luN p0MKXY3liwSiVlqLhxBC2XUcsB9EmBOBuDrtu6EdS5DDZgFNPvlMcI1oxM2fRI6ax5w5 SIpmGcoad66Rs37FmMBhtylPcSJ0Ifqp+onHsVgckym8xBjNS8Z4+N0VuG8J0cvHX53P dDARwetywCz7XkerPL5kpZeSPKWqL0ScHTQ7FMG+IeUyan/Meu0F6KUtJKj6B1YCMOOE mkIdPOlXaJk4bgqCOKGZfd6lV0AoYw1dsegL4GEzrWsvOcFO/RkMAXWDBjFl6eod4nBt jf6w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j15-20020a508a8f000000b00448ce617058si12693126edj.463.2022.09.08.00.07.40; Thu, 08 Sep 2022 00:08:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231153AbiIHGvj (ORCPT + 99 others); Thu, 8 Sep 2022 02:51:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230518AbiIHGv3 (ORCPT ); Thu, 8 Sep 2022 02:51:29 -0400 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF5086346; Wed, 7 Sep 2022 23:51:27 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4MNV9H0rqyz6S33F; Thu, 8 Sep 2022 14:49:39 +0800 (CST) Received: from localhost.localdomain (unknown [10.67.175.61]) by APP2 (Coremail) with SMTP id Syh0CgBXqHHskBljwcslAg--.10754S2; Thu, 08 Sep 2022 14:51:25 +0800 (CST) From: Pu Lehui To: bpf@vger.kernel.org, linux-kernel@vger.kernel.org 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 Subject: [PATCH bpf-next v2 0/2] Fix cgroup attach flags being assigned to effective progs Date: Thu, 8 Sep 2022 14:53:02 +0000 Message-Id: <20220908145304.3436139-1-pulehui@huaweicloud.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-CM-TRANSID: Syh0CgBXqHHskBljwcslAg--.10754S2 X-Coremail-Antispam: 1UD129KBjvJXoW7WFWkWF1xKw1DGFy3JFW5Wrg_yoW8Cw45pF yDA3WUt3Z8Wr9xJrWSya4jgayfKr4fAw12y3WDZr48Zry3tryDtry2k3y0yr17XFsrKw4x ZF15AFy5Gw45taDanT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvvb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M280x2IEY4vEnII2IxkI6r1a6r45M2 8lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E 3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr1j6rxdM28EF7xvwVC2z280aVAFwI0_Gc CE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxI r21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87 Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lFIxGxcIE c7CjxVA2Y2ka0xkIwI1l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2 IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v2 6r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2 IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWrJr0_WFyUJwCI42IY6I8E 87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73Uj IFyTuYvjxUIf-PUUUUU X-CM-SenderInfo: psxovxtxl6x35dzhxuhorxvhhfrp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_00,DATE_IN_FUTURE_06_12, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pu Lehui 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