Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp70194rwe; Fri, 26 Aug 2022 00:26:09 -0700 (PDT) X-Google-Smtp-Source: AA6agR4WaWoGVeDKF408u0M2Xe7F73gfdhgAzv9I5NaVArkcG/xNwYzMcyP7/7KIsBnMWMZfPMbT X-Received: by 2002:a17:902:f610:b0:172:990e:33cd with SMTP id n16-20020a170902f61000b00172990e33cdmr2451264plg.145.1661498768859; Fri, 26 Aug 2022 00:26:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661498768; cv=none; d=google.com; s=arc-20160816; b=enkSQA+Wx9WVHCxBInkoNRBte6u5CuURbZJwJuq7SP2Q8sYXuC9qy3CaKDn0BSQR6Q 35oUhfhketTmYajhOWmNp/OROWvBtGrwjKnvJVFS45gaqz+iJ+tPWB2j8IQGkNXICQe9 t0Rk3vLHSZIoOsCXWD/36viYYUHuH4hjTuWIyJwtLhyA6vcxl2LdrqlGH/imr/oh+Ijn KIEFZUwbQ2aJKi5Yjs3G8zgvqgM0yuO2Kk8A+EK27QSPfwyd/sVzpK8pbl+0sd27+Qov 1qx9DZ/aEtM4FdveKggUgpkhWBnEhyKVichWyoPK4jl+nhaW39LB6z4YxFfjOS8LN9gj E+2w== 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=2sMFHHXDJf/x0tddAJIQTfry9f0GQFVtxwOb/PxzVY4=; b=zM6dNsgH+DKHPGxkDFKuxIZ5xFH14VkFfqFuNr2ZrCj0gyfOthgN3wBfk6OJNcTfPh 36XUELQYAn19TiiBH7rxgBK6hXq6ZM5W65168uysQzgQuavTmDRnd4oOzCbvgyI+H374 B3Rb808maxvHcF/2+BejzX2CN4TZGZ6kN2j4ZzuM16XipbCJTltVlaFJcG1o/8zwVwA0 uy7bIkgMzbSTNNjbcNCncRjbvkgD2Qiy4k2Ue9+j8cnZo0O4mQRlQzavzZN99kh7ZNl1 PBDNYhqUPrgZjqXtAOiJ178+UTPlnvPDnsZOy1rQokJWtM2VSuH4U0qQjhSP+b2j30qC D61g== 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 k191-20020a636fc8000000b0041b671665a6si1114295pgc.76.2022.08.26.00.25.55; Fri, 26 Aug 2022 00:26:08 -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 S245207AbiHZHWO (ORCPT + 99 others); Fri, 26 Aug 2022 03:22:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234047AbiHZHWM (ORCPT ); Fri, 26 Aug 2022 03:22:12 -0400 Received: from frasgout11.his.huawei.com (frasgout11.his.huawei.com [14.137.139.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B37302C10A; Fri, 26 Aug 2022 00:22:10 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.18.147.227]) by frasgout11.his.huawei.com (SkyGuard) with ESMTP id 4MDWNZ51Pzz9v7Gh; Fri, 26 Aug 2022 15:16:46 +0800 (CST) Received: from roberto-ThinkStation-P620 (unknown [10.204.63.22]) by APP1 (Coremail) with SMTP id LxC2BwDnthJ4dAhj+iNOAA--.37625S2; Fri, 26 Aug 2022 08:21:41 +0100 (CET) Message-ID: <67c4a5e7cf363a6c9b79a436690c4c3f469652de.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:21:25 +0200 In-Reply-To: References: <20220823150035.711534-1-roberto.sassu@huaweicloud.com> <20220823150035.711534-6-roberto.sassu@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: LxC2BwDnthJ4dAhj+iNOAA--.37625S2 X-Coremail-Antispam: 1UD129KBjvJXoW7uryUZry5Jw4ftr1fCF4fGrg_yoW8XF1fpF W8CF4FkFs5Ka47CF9av3WavrySgw4v9r17K3srWr1Utr9Fkr1kGr4kCr4a9ry5Arn29r18 WryYgF43Cry5Z37anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkFb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6r1S6rWUM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4 vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Jr0_JF4l84ACjcxK6xIIjxv20xvEc7Cj xVAFwI0_Cr0_Gr1UM28EF7xvwVC2z280aVAFwI0_Jr0_Gr1l84ACjcxK6I8E87Iv6xkF7I 0E14v26r4j6r4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG 6I80ewAv7VC0I7IYx2IY67AKxVWUGVWUXwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFV Cjc4AY6r1j6r4UM4x0Y48IcVAKI48JM4IIrI8v6xkF7I0E8cxan2IY04v7MxAIw28IcxkI 7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxV Cjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVW8ZVWrXwCIc40Y0x0EwIxGrwCI42IY 6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWxJVW8Jr1lIxAIcV CF04k26cxKx2IYs7xG6rWUJVWrZr1UMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2 jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07UQZ2-UUUUU= X-CM-SenderInfo: purev21wro2thvvxqx5xdzvxpfor3voofrz/1tbiAgAQBF1jj35RKgABsj 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 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. Thanks Roberto