From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C03FC65C0D for ; Thu, 1 Sep 2022 07:02:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233534AbiIAHCB (ORCPT ); Thu, 1 Sep 2022 03:02:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232891AbiIAHBA (ORCPT ); Thu, 1 Sep 2022 03:01:00 -0400 Received: from frasgout11.his.huawei.com (frasgout11.his.huawei.com [14.137.139.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 237221928D; Thu, 1 Sep 2022 00:00:45 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.18.147.227]) by frasgout11.his.huawei.com (SkyGuard) with ESMTP id 4MJBcz4dNGz9v7HB; Thu, 1 Sep 2022 14:55:15 +0800 (CST) Received: from roberto-ThinkStation-P620 (unknown [10.204.63.22]) by APP1 (Coremail) with SMTP id LxC2BwD3n5N0WBBjL7ITAA--.38593S2; Thu, 01 Sep 2022 08:00:16 +0100 (CET) Message-ID: Subject: Re: [PATCH v15 05/12] KEYS: Move KEY_LOOKUP_ to include/linux/key.h and define KEY_LOOKUP_ALL From: Roberto Sassu To: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, mykolal@fb.com, dhowells@redhat.com, jarkko@kernel.org, rostedt@goodmis.org, mingo@redhat.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, shuah@kernel.org Cc: bpf@vger.kernel.org, keyrings@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, deso@posteo.net, memxor@gmail.com, Roberto Sassu Date: Thu, 01 Sep 2022 09:00:00 +0200 In-Reply-To: <20220831165445.1071641-6-roberto.sassu@huaweicloud.com> References: <20220831165445.1071641-1-roberto.sassu@huaweicloud.com> <20220831165445.1071641-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: LxC2BwD3n5N0WBBjL7ITAA--.38593S2 X-Coremail-Antispam: 1UD129KBjvJXoW7uF1DurW8Zr4DXrW5KrWkCrg_yoW8KryrpF WDC3WFkryjyry293s7GanFya1Fk398Gr12kF9Fgwn0vFsag34xtr1xKF4ruF1FyrW7ur12 grsF9ayUuw4DA3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUk0b4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6r1S6rWUM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4 vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Jr0_JF4l84ACjcxK6xIIjxv20xvEc7Cj xVAFwI0_Cr0_Gr1UM28EF7xvwVC2z280aVAFwI0_Jr0_Gr1l84ACjcxK6I8E87Iv6xkF7I 0E14v26r4j6r4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG 6I80ewAv7VC0I7IYx2IY67AKxVWUGVWUXwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFV Cjc4AY6r1j6r4UM4x0Y48IcVAKI48JM4IIrI8v6xkF7I0E8cxan2IY04v7MxAIw28IcxkI 7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxV Cjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVW8ZVWrXwCIc40Y0x0EwIxGrwCI42IY 6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWxJVW8Jr1lIxAIcV CF04k26cxKx2IYs7xG6Fyj6rWUJwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv 6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxUOlksDUUUU X-CM-SenderInfo: purev21wro2thvvxqx5xdzvxpfor3voofrz/1tbiAQACBF1jj4J80AAAsY X-CFilter-Loop: Reflected Precedence: bulk List-ID: On Wed, 2022-08-31 at 18:54 +0200, Roberto Sassu wrote: > From: Roberto Sassu > > In preparation for the patch that introduces the > bpf_lookup_user_key() eBPF > kfunc, move KEY_LOOKUP_ definitions to include/linux/key.h, to be > able to > validate the kfunc parameters. Add them to enum key_lookup_flag, so > that > all the current ones and the ones defined in the future are > automatically > exported through BTF and available to eBPF programs. > > Also, add KEY_LOOKUP_ALL to the enum, to facilitate checking whether > a > variable contains only defined flags. > > Signed-off-by: Roberto Sassu > Reviewed-by: KP Singh > Acked-by: Jarkko Sakkinen Jarkko, I kept your ack although the code slightly changed to use the enum instead of #define. If you have more comments/suggestions, please let me know. Thanks Roberto > --- > include/linux/key.h | 6 ++++++ > security/keys/internal.h | 2 -- > 2 files changed, 6 insertions(+), 2 deletions(-) > > diff --git a/include/linux/key.h b/include/linux/key.h > index 7febc4881363..d84171f90cbd 100644 > --- a/include/linux/key.h > +++ b/include/linux/key.h > @@ -88,6 +88,12 @@ enum key_need_perm { > KEY_DEFER_PERM_CHECK, /* Special: permission check is > deferred */ > }; > > +enum key_lookup_flag { > + KEY_LOOKUP_CREATE = 0x01, /* Create special keyrings if they > don't exist */ > + KEY_LOOKUP_PARTIAL = 0x02, /* Permit partially > constructed keys to be found */ > + KEY_LOOKUP_ALL = (KEY_LOOKUP_CREATE | KEY_LOOKUP_PARTIAL), /* > OR of previous flags */ > +}; > + > struct seq_file; > struct user_struct; > struct signal_struct; > diff --git a/security/keys/internal.h b/security/keys/internal.h > index 9b9cf3b6fcbb..3c1e7122076b 100644 > --- a/security/keys/internal.h > +++ b/security/keys/internal.h > @@ -165,8 +165,6 @@ extern struct key *request_key_and_link(struct > key_type *type, > > extern bool lookup_user_key_possessed(const struct key *key, > const struct key_match_data > *match_data); > -#define KEY_LOOKUP_CREATE 0x01 > -#define KEY_LOOKUP_PARTIAL 0x02 > > extern long join_session_keyring(const char *name); > extern void key_change_session_keyring(struct callback_head *twork);