Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp2150321rwn; Fri, 9 Sep 2022 09:10:31 -0700 (PDT) X-Google-Smtp-Source: AA6agR57mEiGs62NPDm4DcczRnPGwY1kb6JwvTWb7OKeYT6ZsRreU9LCO516GM3rGT0krkpELJMX X-Received: by 2002:a05:6402:26c4:b0:448:6e4:7cda with SMTP id x4-20020a05640226c400b0044806e47cdamr11920892edd.325.1662739830747; Fri, 09 Sep 2022 09:10:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662739830; cv=none; d=google.com; s=arc-20160816; b=XYu97fP7KwJHAi7JwpP4Vt4SuIikybe/Ffn3Eac42lCBGy3xaXcjLUCglo7OL9dpNc lSX7Qtdw5mNt13qL/bEOM6mjGNtDzZ1PnqZuFv9Bcrx52CEe99cglY00Rqjp3mob/JdM OZKGrwA5wsa7vheXuPCjElyC1Klu7winYh4qxBQBOeHMO4yA1PhqDeaw4zkR+MFzBFIc 5J61BNwkzXrLwr1yitaW85gd76jOAtBByPFBqJKYBJME74bh881hh9qJz6IUKpEwtZyu 8oo8A5syDiMJ5HmzERzgE1FNBNl+Y+onayA/Cwqmg74KGEnF69MoToN83cx2XT3EYAZY Ky2w== 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=axWEZR2AGhaBfThvLrSFA+NxQSVcKpOAZwv+H9dW4Nk=; b=k2tl9MTaKEKjgKUVcWv+G3RGHLWJu8GceYat0QTFLyzganq7WdGxCkRXkfQBhBM08I EPZl08lUTJs3WnVmNpR14ZcbOXvvZuym5EOaCP1qYW/Lj/M3FmSVdZ9/kkfle2e3Unkv fI0GWba84rp32RgFr2hGXUTT9vNwPqOiGRXPPsJRYIqBDW2CzwEQ6LjKzzWZA3um/XWA 7/0QM8ehxlBmlH/gezfSoIXP3480XIvPHLPFYCPBF4rIH8aGveghe+LdeJWRX+pJpoL+ FOy8q02GvyhSrJ9TeIGMGdefjyDs3lwcGQHOgTcu+wsuvlZTtYjHqi5cBRfZYrLRdONl Dovg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iibSQJJ4; 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 t7-20020a056402524700b0044eabb548b4si852319edd.473.2022.09.09.09.10.03; Fri, 09 Sep 2022 09:10:30 -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=iibSQJJ4; 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 S231650AbiIIQGc (ORCPT + 99 others); Fri, 9 Sep 2022 12:06:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230510AbiIIQGa (ORCPT ); Fri, 9 Sep 2022 12:06:30 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A99EB1282D5; Fri, 9 Sep 2022 09:06:29 -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 4F4C5B82584; Fri, 9 Sep 2022 16:06:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EBAB3C4347C; Fri, 9 Sep 2022 16:06:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662739587; bh=axWEZR2AGhaBfThvLrSFA+NxQSVcKpOAZwv+H9dW4Nk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=iibSQJJ4qO0hADleXEMz2q8bsHl4E5kuxqbEW814lAtB6rTghQGxlaWLayEs9BxL6 qWsyybTYDgORZqa6SMD8HdP43rhj1S8YjCOGM9LPqk1nIDUVt5ZuMgXhANuH88DKOX 95BFN5MFwjwD9ElXZwnG8HK/hMlNHfBMh1T8AIl9UALOKwpDACprIwB3Q/uJMOMGK9 sLu1xcTQkm+vu/dcD4ppCL5/l1YYFiqRqH8Y9AVLUdEQsy+oN4tgJUEMP1ZH820Oi4 mIWgpb9JtuezcGS477Kc9vOF3tkLh6WKLFdEXRqhZCKemRhAoj+tFJ1fRKxhMvAKDS 51qBZeIRP1V5g== Received: by mail-ot1-f48.google.com with SMTP id 6-20020a9d0106000000b0063963134d04so1356595otu.3; Fri, 09 Sep 2022 09:06:26 -0700 (PDT) X-Gm-Message-State: ACgBeo26VrXaTyec/izQJuIUnPTImjFNVOv1eFUaqESyTBoEi6C6AFcW 0WgF/GpLpCB37EyxNemsswUpO/bndaY6iHRZCkY= X-Received: by 2002:a9d:7c94:0:b0:636:f74b:2364 with SMTP id q20-20020a9d7c94000000b00636f74b2364mr5594298otn.165.1662739586134; Fri, 09 Sep 2022 09:06:26 -0700 (PDT) MIME-Version: 1.0 References: <20220909120736.1027040-1-roberto.sassu@huaweicloud.com> <20220909120736.1027040-8-roberto.sassu@huaweicloud.com> In-Reply-To: <20220909120736.1027040-8-roberto.sassu@huaweicloud.com> From: Song Liu Date: Fri, 9 Sep 2022 17:06:15 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v17 07/12] bpf: Add bpf_verify_pkcs7_signature() kfunc 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 , David Howells , Jarkko Sakkinen , Steven Rostedt , Ingo Molnar , paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, Shuah Khan , bpf , keyrings@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kselftest@vger.kernel.org, open list , =?UTF-8?Q?Daniel_M=C3=BCller?= , Kumar Kartikeya Dwivedi , 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 Fri, Sep 9, 2022 at 1:09 PM Roberto Sassu wrote: > > From: Roberto Sassu > > Add the bpf_verify_pkcs7_signature() kfunc, to give eBPF security modules > the ability to check the validity of a signature against supplied data, by > using user-provided or system-provided keys as trust anchor. > > The new kfunc makes it possible to enforce mandatory policies, as eBPF > programs might be allowed to make security decisions only based on data > sources the system administrator approves. > > The caller should provide the data to be verified and the signature as eBPF > dynamic pointers (to minimize the number of parameters) and a bpf_key > structure containing a reference to the keyring with keys trusted for > signature verification, obtained from bpf_lookup_user_key() or > bpf_lookup_system_key(). > > For bpf_key structures obtained from the former lookup function, > bpf_verify_pkcs7_signature() completes the permission check deferred by > that function by calling key_validate(). key_task_permission() is already > called by the PKCS#7 code. > > Signed-off-by: Roberto Sassu > Acked-by: KP Singh Acked-by: Song Liu [...]