Re: [PATCH v3 1/2] bpf: Add bpf_verify_signature() helper

From: Alexei Starovoitov
Date: Fri Jun 10 2022 - 12:21:05 EST


On Fri, Jun 10, 2022 at 6:59 AM Roberto Sassu <roberto.sassu@xxxxxxxxxx> wrote:
>
> Since the maximum number of parameters of an eBPF helper is 5, the keyring
> and signature types share one (keyring ID: low 16 bits, signature type:
> high 16 bits).
...
> + * long bpf_verify_signature(u8 *data, u32 datalen, u8 *sig, u32 siglen, u32 info)
> + * Description
> + * Verify a signature of length *siglen* against the supplied data
> + * with length *datalen*. *info* contains the keyring identifier
> + * (low 16 bits) and the signature type (high 16 bits). The keyring
> + * identifier can have the following values (some defined in
> + * verification.h): 0 for the primary keyring (immutable keyring of
> + * system keys); 1 for both the primary and secondary keyring
> + * (where keys can be added only if they are vouched for by
> + * existing keys in those keyrings); 2 for the platform keyring
> + * (primarily used by the integrity subsystem to verify a kexec'ed
> + * kerned image and, possibly, the initramfs signature); 0xffff for
> + * the session keyring (for testing purposes).

Muxing all kinds of info in the 5th arg isn't great.
It's better to use dynptr here for data and sig.
It will free up two extra arguments.