Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp104525rwe; Fri, 26 Aug 2022 01:20:10 -0700 (PDT) X-Google-Smtp-Source: AA6agR4wuEq/EiwdsH13qGiU9DR4pWMbAmKxjIZa//Ms4fQJU+MHlliK6yov3ITEdqO2Pxc9wynh X-Received: by 2002:a17:90a:4a91:b0:1fd:64ce:f8d5 with SMTP id f17-20020a17090a4a9100b001fd64cef8d5mr1370079pjh.40.1661502009930; Fri, 26 Aug 2022 01:20:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661502009; cv=none; d=google.com; s=arc-20160816; b=tBNEkZnMQ93/x8mP8MUhgBDVW7kEVq+6tpCI5FciAKNMK1M7z6x+Rmz9qja0KZD1aO c9Jd3rivAwQKTMAKxS1eZfMo8pDVNVvxQnG7XL3giYHsaZ2w4SKTkrjUb1U199shEi+d /jqgPvsdmPX/xhOi0psvwpqkChrASewD05M4hdkWr0Hd3L26yna387s11qFzczV3nDzm mgjaRD+Mam1ppSlBjoSvZ7hx26Pyp8VgQMJtZq1QeqXqMBHBx3ksoXJGCYgIEswy0GQZ ViNmfBfmfsiUHVBt9QftdQmGj4WhKWbNI71u/M0UOQfWUWw4oX8A/Cj1ZFBJ3ILOI0Hv s5FA== 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 :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=91bXEaNz2KDQ3mb3KGBRLpazOS2YrjIYhGzznEHqm4I=; b=Y9cRx6S9R0o8RYmi2hPSalQuw0ayIgKkjSt0CLs9S+/bRaS2FS3LatGmaZnOkIJs7o 3rmLBdo32/nJu9lYiBTq8f0hR1Y7uBDXOSf7Q/ytQW0At7GbwkyGUhcMuSdVgXZM8HBA uakh3wnqf2wKkLqtKpLvkaU9hDPHGC7xKVWXE93U2WzES88/iQnFkw9BTn8VeAXJ6kRG 2VBwgMPOe5cSvKhu4UsG/Qy39hRlaKHXj+F6oBUk7HWkM/nbfKcVLTxEVF53uTWRwjBf RM30QzNGL1orqCmZZjwfPqQN85VMyOdtJYn2Kl6Uk3wMls/xsviJhMzGlJVxOM28kT0Q fGPg== 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 y8-20020a170902700800b0016d1a182e17si1015651plk.425.2022.08.26.01.19.57; Fri, 26 Aug 2022 01:20:09 -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 S245501AbiHZHdB (ORCPT + 99 others); Fri, 26 Aug 2022 03:33:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245416AbiHZHcX (ORCPT ); Fri, 26 Aug 2022 03:32:23 -0400 Received: from frasgout12.his.huawei.com (frasgout12.his.huawei.com [14.137.139.154]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E5EDD39A9; Fri, 26 Aug 2022 00:32:20 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.18.147.229]) by frasgout12.his.huawei.com (SkyGuard) with ESMTP id 4MDWf62tdRz9v7Gg; Fri, 26 Aug 2022 15:28:30 +0800 (CST) Received: from roberto-ThinkStation-P620 (unknown [10.204.63.22]) by APP1 (Coremail) with SMTP id LxC2BwD3xhLYdghjuylOAA--.37523S2; Fri, 26 Aug 2022 08:31:50 +0100 (CET) Message-ID: <2b1961925a6f0e10a75b6aa23ed1a014edfcd99e.camel@huaweicloud.com> Subject: Re: [PATCH v13 05/10] bpf: Add bpf_lookup_*_key() and bpf_key_put() kfuncs From: Roberto Sassu To: Song Liu Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Jonathan Corbet , David Howells , Jarkko Sakkinen , Steven Rostedt , Ingo Molnar , paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, Shuah Khan , bpf , Linux Doc Mailing List , keyrings@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kselftest@vger.kernel.org, open list , Daniel =?ISO-8859-1?Q?M=FCller?= , Roberto Sassu Date: Fri, 26 Aug 2022 09:31:32 +0200 In-Reply-To: References: <20220823150035.711534-1-roberto.sassu@huaweicloud.com> <20220823150035.711534-6-roberto.sassu@huaweicloud.com> <67c4a5e7cf363a6c9b79a436690c4c3f469652de.camel@huaweicloud.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5-0ubuntu1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-CM-TRANSID: LxC2BwD3xhLYdghjuylOAA--.37523S2 X-Coremail-Antispam: 1UD129KBjvJXoW7Ww4DtryDXr1DAr18WFWktFb_yoW8Zry3pF yUGF4rCF4kXry7Ar9av34avF9ayw4vgr1jg3srWw1jyF9F9F18Kr1UGF43uryrArn7Cr1U WrWYgFW3ur13AwUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkFb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6r1S6rWUM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4 vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Jr0_JF4l84ACjcxK6xIIjxv20xvEc7Cj xVAFwI0_Cr0_Gr1UM28EF7xvwVC2z280aVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv6xkF7I 0E14v26r4j6r4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG 6I80ewAv7VC0I7IYx2IY67AKxVWUGVWUXwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFV Cjc4AY6r1j6r4UM4x0Y48IcVAKI48JM4IIrI8v6xkF7I0E8cxan2IY04v7MxAIw28IcxkI 7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxV Cjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVW8ZVWrXwCIc40Y0x0EwIxGrwCI42IY 6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWxJVW8Jr1lIxAIcV CF04k26cxKx2IYs7xG6rWUJVWrZr1UMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2 jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07UQZ2-UUUUU= X-CM-SenderInfo: purev21wro2thvvxqx5xdzvxpfor3voofrz/1tbiAQAQBF1jj4JPsQABsZ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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 On Fri, 2022-08-26 at 00:25 -0700, Song Liu wrote: > On Fri, Aug 26, 2022 at 12:22 AM Roberto Sassu > wrote: > > On Thu, 2022-08-25 at 22:56 -0700, Song Liu wrote: > > > On Tue, Aug 23, 2022 at 8:02 AM Roberto Sassu > > > wrote: > > > > From: Roberto Sassu > > > > > > > > Add the bpf_lookup_user_key(), bpf_lookup_system_key() and > > > > bpf_key_put() > > > > kfuncs, to respectively search a key with a given key handle > > > > serial > > > > number > > > > and flags, obtain a key from a pre-determined ID defined in > > > > include/linux/verification.h, and cleanup. > > > > > > > > Introduce system_keyring_id_check() to validate the keyring ID > > > > parameter of > > > > bpf_lookup_system_key(). > > > > > > > > Signed-off-by: Roberto Sassu > > > > --- > > > > include/linux/bpf.h | 6 ++ > > > > include/linux/verification.h | 8 +++ > > > > kernel/trace/bpf_trace.c | 135 > > > > +++++++++++++++++++++++++++++++++++ > > > > 3 files changed, 149 insertions(+) > > > > > > > > diff --git a/include/linux/bpf.h b/include/linux/bpf.h > > > > index 6041304b402e..991da09a5858 100644 > > > > --- a/include/linux/bpf.h > > > > +++ b/include/linux/bpf.h > > > > @@ -2586,4 +2586,10 @@ static inline void > > > > bpf_cgroup_atype_get(u32 > > > > attach_btf_id, int cgroup_atype) {} > > > > static inline void bpf_cgroup_atype_put(int cgroup_atype) {} > > > > #endif /* CONFIG_BPF_LSM */ > > > > > > > > +#ifdef CONFIG_KEYS > > > > > > Do we need to declare struct key here? > > > > > > > +struct bpf_key { > > > > + struct key *key; > > > > + bool has_ref; > > > > +}; > > > > +#endif /* CONFIG_KEYS */ > > > > #endif /* _LINUX_BPF_H */ > > > > > > > > If there is a better place, I will move there. > > I guess you misunderstood. I meant we need > > struct key; > > struct bpf_key { > struct key *key; > bool has_ref; > }; > > Otherwise, we may get some warning with certain config. Argh, thanks! Will add it. Roberto