Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp4730341rwb; Tue, 20 Sep 2022 19:42:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6jHp+1Ll4NNutprjByE+xC4Qz4LueYp3RxvDYWKDVYlE3I8FzEPGeB6mO9H5EHf9hmmpeH X-Received: by 2002:a17:902:e5c9:b0:178:41d1:ef3d with SMTP id u9-20020a170902e5c900b0017841d1ef3dmr2547542plf.151.1663728155814; Tue, 20 Sep 2022 19:42:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663728155; cv=none; d=google.com; s=arc-20160816; b=BbBOT8jwJugFvBaz8xQzSEeEFLX8/5We3cLYr8jfhNH47LznZeq9VlMjNIScaAS0D5 TowCV3pIupbOg90qMGS/6eu1P4iBllbSkvYgvGVSISon1QHEM3IIjZp4IVbeXixu0RxV dnVI7NkFvq+kDkdRzUZz67dUPG2A3mfaAQFtSqWW9Mx45hqSc3fxNokKJQKhGOpjIU0V JbaBS4P1Klzn3gQ+aJ6F8ozZP1AEBRx3OdviOzQeQ0bi0KQKCLfESSHVyz0g6Oqg00YQ dfoOHRaFNHhmr8Jy4cw+mSyyz+w63CM5EP+RwAV059/sFXPuPlpg8soyLaAUh/3vAWUe WWCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=m/45bwwHTB3glYdWZbXfXQ4ohivxg3E+s7DTsTyHpUE=; b=XrUErsuec7eIhPKfSOkirm39nHdDiE2c2XIDG0ozBh6acZERVV5oKCo+02QYS+okG0 6NVkidG4bxl7jW3+3Z3ogGQDqZaEIPYdFH6lrQK0rlcbVBHfAS4mx5GQEX6e99w/Y1i0 JQyroztkVxXE2JvPTewDJsnjjpcgcCvfqStzEau/z3uZqDWX5jRcku/0DOLoEamcUgRi 3PpNPiwyXm1BVFP8kfn3LWZ0DJSR3JzrY1Dci7JYcEi9/wAEG3bmOhds/Jaf6NhmenMp K92mL1MniK73M6FTZqv9fdxKhIlULhC2kMwtxQLMLawDf4IixqF/sfHERhg9clZ/aIWE ukag== 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 l7-20020a637007000000b0043961d06b6fsi1449788pgc.598.2022.09.20.19.42.23; Tue, 20 Sep 2022 19:42:35 -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 S229741AbiIUClc (ORCPT + 99 others); Tue, 20 Sep 2022 22:41:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230154AbiIUClQ (ORCPT ); Tue, 20 Sep 2022 22:41:16 -0400 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2B115F7EA; Tue, 20 Sep 2022 19:41:14 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4MXN0L3y39z6TBmr; Wed, 21 Sep 2022 10:39:14 +0800 (CST) Received: from [10.67.109.184] (unknown [10.67.109.184]) by APP1 (Coremail) with SMTP id cCh0CgAnHjLGeSpjr0NmBA--.31580S2; Wed, 21 Sep 2022 10:41:11 +0800 (CST) Subject: Re: [PATCH bpf v4 0/2] Fix wrong cgroup attach flags being assigned to effective progs 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 References: <20220920154233.1494352-1-pulehui@huaweicloud.com> From: Pu Lehui Message-ID: <35405b07-76db-1d34-fdf2-9066ad21d142@huaweicloud.com> Date: Wed, 21 Sep 2022 10:41:10 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20220920154233.1494352-1-pulehui@huaweicloud.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-CM-TRANSID: cCh0CgAnHjLGeSpjr0NmBA--.31580S2 X-Coremail-Antispam: 1UD129KBjvJXoWxXFyrWw1xXFWrCF1UAFWfAFb_yoW5GFyrpF WkA3WYywn5Wr9xJrWSk34jqayrtr48Aw1jyasrJr48ZFyxKry0yr17C3y0yr12vFsFkr4x ZF15uF98Gw45ta7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvIb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4 vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7Cj xVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x 0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG 6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFV Cjc4AY6r1j6r4UM4x0Y48IcVAKI48JM4IIrI8v6xkF7I0E8cxan2IY04v7Mxk0xIA0c2IE e2xFo4CEbIxvr21l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxV Aqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q 6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6x kF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWrZr1j6s0DMIIF0xvEx4A2jsIE 14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf 9x07UWE__UUUUU= X-CM-SenderInfo: psxovxtxl6x35dzhxuhorxvhhfrp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,NICE_REPLY_A, SPF_HELO_NONE,SPF_NONE 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 On 2022/9/20 23:42, Pu Lehui wrote: > 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 for query with EFFECTIVE flags, exporting attach flags > does not make sense. So let's remove the AttachFlags field and the > associated logic. After these patches, the above effective cgroup > tree will show as bellow: > > # bpftool cgroup tree /sys/fs/cgroup effective > CgroupPath > ID AttachType Name > /sys/fs/cgroup > 6 cgroup_sysctl sysctl_tcp_mem > 13 cgroup_sysctl sysctl_tcp_mem > /sys/fs/cgroup/cg1 > 20 cgroup_sysctl 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 > > v4: > - Reject prog_attach_flags array when effective query. (Martin) > - Target to bpf tree. (Martin) > > v3: > https://lore.kernel.org/bpf/20220914161742.3180731-1-pulehui@huaweicloud.com > - Don't show attach flags when effective query. (John, sdf, Martin) > > v2: > https://lore.kernel.org/bpf/20220908145304.3436139-1-pulehui@huaweicloud.com > - 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: Reject prog_attach_flags array when effective query > bpftool: Fix wrong cgroup attach flags being assigned to effective > progs > > include/uapi/linux/bpf.h | 7 +++-- > kernel/bpf/cgroup.c | 28 +++++++++++------- > tools/bpf/bpftool/cgroup.c | 54 ++++++++++++++++++++++++++++++---- > tools/include/uapi/linux/bpf.h | 7 +++-- > 4 files changed, 77 insertions(+), 19 deletions(-) > selftest no pass, sorry, will fix. https://github.com/kernel-patches/bpf/actions/runs/3088351905/jobs/4995009382