Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp31384rwe; Thu, 25 Aug 2022 23:22:26 -0700 (PDT) X-Google-Smtp-Source: AA6agR7s4jqIEHG3cc3m0aY+hm05Gd6RxV8jSDNG0Iv2Ho16PVTMBmCLqV3294XzSXvxqn2RlasW X-Received: by 2002:a05:6402:2b98:b0:43e:107:183d with SMTP id fj24-20020a0564022b9800b0043e0107183dmr5640019edb.366.1661494946100; Thu, 25 Aug 2022 23:22:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661494946; cv=none; d=google.com; s=arc-20160816; b=aWD65AnW8KzBq9ETQdARKR3c8WKXTSrX68+0bOXYMG2/fqQxiZ77AxqHbfHJdX2q1I ZJiVGlzmLJ7JsS3y13e544iyzdBjj8PHmzoY5IjqfWlsvfk85fx9JCI+XJdtOc4DObv7 fzMBMzX1OeZ1FeX/Cs4ekamKsMXig3v84pYyk9CHJKg4966nAzRtcFEuXQp7J8mWC+di 6vdPiHZlPTirbmtqrDelpHxuvVAz6SCVqpY+/N2ntf30yZAUzTTDd5dWKtWC5UDgUTxd cbE3DApF/y8pHoGXb8urhvuSI19gIbiy89nYrwj3B3RFfOTPhrO4avjPaiNzx3ZkJTAm EyqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=2jGej6ArX2M1Iep2OZ3zgkNB+HsEguhCr+IgXzTKpek=; b=OdX5XJcxEMx0s5WAi9viQmkAPkkhFL39ppVemZXw08ncD4uDNanYMEqVhWgckq2yOJ 8w79JinP84g/vHrZZzRNAmFZl/B9ar72cpw3W1xUQhLjRfhc/vsGxPvPRxnuHtP7npY+ fhHHaQGPRb7vPxV8pmyLRD2uTm2t6NFzfMgkDqiaxnNsl6dE/AlZpaCG+F/jv8fN/dhT T07jxwE6h/qipLDc7l2tz1tVmQyih51nipIurkwScyQWwwdQZhpr2uAyqrnOdqqwX2qQ /F9YXfsJ7m2M7p3Jm21OTzetBA4zHNxbNLRtqWzTcIE+7ytTkJehQE9x3f1lCO43rcua eTHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="uCgUQCc/"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cw6-20020a170906478600b0073dd390029asi873950ejc.535.2022.08.25.23.22.00; Thu, 25 Aug 2022 23:22:26 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="uCgUQCc/"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244728AbiHZF5D (ORCPT + 99 others); Fri, 26 Aug 2022 01:57:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230054AbiHZF5B (ORCPT ); Fri, 26 Aug 2022 01:57:01 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B230C5789; Thu, 25 Aug 2022 22:56:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7F5A6B82F5C; Fri, 26 Aug 2022 05:56:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43271C4314A; Fri, 26 Aug 2022 05:56:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661493417; bh=/FvktWWHz025DxZFW/BBwLRligmr0a9pBYK2MH9aV5Q=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=uCgUQCc/Qlk7Pi7/drdrT0yEzgE2IinbxX+THqgq2Tq5u0b5Kb6RL++DEn7XlDWwg pYwPj+IIOFPS9bL8SODw+FRZcnizjhFomi548R9lX+YLXdbaY748aaWkVEYjme6hG7 kV5JeqS6f+G69EWtgP68/6H/Ms6Afj/30OGf33XPFhiV2cmSBuhN1aEjSHsCpT0drP A4TKWrBDUKKkmluFZHkgYrgNYwkRrR5UNov35B1g5xgEiQfZL3lzJpBdRBuTNvHqiy sSDyAl6KZkWo2fKpZ5mGp01B0TUS7PiXF0UcFhNmpv9xdEClFTjZzxL33z+aBOsBrF B3BComuHnQQ1A== Received: by mail-yw1-f169.google.com with SMTP id 00721157ae682-324ec5a9e97so11435067b3.7; Thu, 25 Aug 2022 22:56:57 -0700 (PDT) X-Gm-Message-State: ACgBeo2JzkJT2fwEKc8wnwNdSGmoyvYPTovwp5l7/ioZTM8r830icmMW 6wecUxg4jG/aJUqOolAfMhrP5TCQtqfLYbsFJg4= X-Received: by 2002:a81:7489:0:b0:33e:dca7:9750 with SMTP id p131-20020a817489000000b0033edca79750mr489448ywc.73.1661493416193; Thu, 25 Aug 2022 22:56:56 -0700 (PDT) MIME-Version: 1.0 References: <20220823150035.711534-1-roberto.sassu@huaweicloud.com> <20220823150035.711534-6-roberto.sassu@huaweicloud.com> In-Reply-To: <20220823150035.711534-6-roberto.sassu@huaweicloud.com> From: Song Liu Date: Thu, 25 Aug 2022 22:56:45 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v13 05/10] bpf: Add bpf_lookup_*_key() and bpf_key_put() kfuncs To: Roberto Sassu 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 , =?UTF-8?Q?Daniel_M=C3=BCller?= , Roberto Sassu Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 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 */ >