[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87msave8kk.fsf@microsoft.com>
Date: Thu, 29 May 2025 08:32:43 -0700
From: Blaise Boscaccy <bboscaccy@...ux.microsoft.com>
To: Lukas Wunner <lukas@...ner.de>
Cc: Paul Moore <paul@...l-moore.com>, jarkko@...nel.org,
zeffron@...tgames.com, xiyou.wangcong@...il.com, kysrinivasan@...il.com,
code@...icks.com, linux-security-module@...r.kernel.org,
roberto.sassu@...wei.com, James.Bottomley@...senpartnership.com, Alexei
Starovoitov <ast@...nel.org>, Daniel Borkmann <daniel@...earbox.net>, John
Fastabend <john.fastabend@...il.com>, Andrii Nakryiko <andrii@...nel.org>,
Martin KaFai Lau <martin.lau@...ux.dev>, Eduard Zingerman
<eddyz87@...il.com>, Song Liu <song@...nel.org>, Yonghong Song
<yonghong.song@...ux.dev>, KP Singh <kpsingh@...nel.org>, Stanislav
Fomichev <sdf@...ichev.me>, Hao Luo <haoluo@...gle.com>, Jiri Olsa
<jolsa@...nel.org>, David Howells <dhowells@...hat.com>, Ignat Korchagin
<ignat@...udflare.com>, Quentin Monnet <qmo@...nel.org>, Jason Xing
<kerneljasonxing@...il.com>, Willem de Bruijn <willemb@...gle.com>, Anton
Protopopov <aspsk@...valent.com>, Jordan Rome <linux@...danrome.com>,
Martin Kelly <martin.kelly@...wdstrike.com>, Alan Maguire
<alan.maguire@...cle.com>, Matteo Croce <teknoraver@...a.com>,
bpf@...r.kernel.org, linux-kernel@...r.kernel.org,
keyrings@...r.kernel.org, linux-crypto@...r.kernel.org
Subject: Re: [PATCH 1/3] bpf: Add bpf_check_signature
Lukas Wunner <lukas@...ner.de> writes:
> On Wed, May 28, 2025 at 02:49:03PM -0700, Blaise Boscaccy wrote:
>> + if (!attr->signature_maps_size) {
>> + sha256((u8 *)prog->insnsi, prog->len * sizeof(struct bpf_insn), (u8 *)&hash);
>> + err = verify_pkcs7_signature(hash, sizeof(hash), signature, attr->signature_size,
>> + VERIFY_USE_SECONDARY_KEYRING,
>> + VERIFYING_EBPF_SIGNATURE,
>> + NULL, NULL);
>
> Has this ever been tested?
>
> It looks like it will always return -EINVAL because:
>
> verify_pkcs7_signature()
> verify_pkcs7_message_sig()
> pkcs7_verify()
>
> ... pkcs7_verify() contains a switch statement which you're not
> amending with a "case VERIFYING_EBPF_SIGNATURE" but which returns
> -EINVAL in the "default" case.
>
Looks like I missed a commit when sending this patchset. Thanks for
finding that.
> Aside from that, you may want to consider introducing a new ".ebpf"
> keyring to allow adding trusted keys specifically for eBPF verification
> without having to rely on the system keyring.
>
> Constraining oneself to sha256 doesn't seem future-proof.
>
Definitely not a bad idea, curious, how would you envision that looking
from an UAPI perspective?
> Some minor style issues in the commit message caught my eye:
>
>> This introduces signature verification for eBPF programs inside of the
>> bpf subsystem. Two signature validation schemes are included, one that
>
> Use imperative mood, avoid repetitive "This ...", e.g.
> "Introduce signature verification of eBPF programs..."
>
>> The signature check is performed before the call to
>> security_bpf_prog_load. This allows the LSM subsystem to be clued into
>> the result of the signature check, whilst granting knowledge of the
>> method and apparatus which was employed.
>
> "Perform the signature check before calling security_bpf_prog_load()
> to allow..."
>
> Thanks,
>
> Lukas
Powered by blists - more mailing lists