Re: [PATCH bpf-next 01/11] bpf: Add a bpf keyring for program signature validation

[email protected]
Newsgroups org.kernel.vger.bpf
Message-ID <5da9714b6f6348052cb0023924690970f39cc93c0eea16f47183eb18ab3f75f8@mail.kernel.org>
> diff --git a/include/linux/verification.h b/include/linux/verification.h
> index dec7f2beabfd4..1cb59ddda2509 100644
> --- a/include/linux/verification.h
> +++ b/include/linux/verification.h
> @@ -18,6 +18,16 @@
>  #define VERIFY_USE_SECONDARY_KEYRING ((struct key *)1UL)
>  #define VERIFY_USE_PLATFORM_KEYRING  ((struct key *)2UL)
>
> +/*
> + * The id of BPF's ".bpf" keyring, reserved from the same space. It is
> + * explicitly not a sentinel like the two above as BPF resolves it to
> + * the keyring itself and passes that, so verify_pkcs7_signature() never
> + * sees this value, and system_keyring_id_check() must keep rejecting it.
> + * Left as a plain integer so that handing it over as @trusted_keys does
> + * not compile.

Does the comment accurately describe what the code enforces?

The comment states the value is "left as a plain integer so that handing
it over as @trusted_keys does not compile." Passing the integer 3 where
struct key *trusted_keys is expected triggers -Wint-conversion, but that
warning is not promoted to -Werror anywhere in scripts/Makefile.warn or
scripts/Makefile.extrawarn.

The kernel requires -Werror=implicit-function-declaration,
-Werror=implicit-int, -Werror=return-type, -Werror=strict-prototypes, and
-Werror=incompatible-pointer-types, but -Werror=int-conversion appears
nowhere. int-conversion only became a hard error by compiler default in
GCC 14 and Clang 16, while Documentation/process/changes.rst still lists
GCC 8.1 as the minimum supported version.

On a GCC 8.1-13 build, the misuse compiles with only a warning rather than
an error. Could the phrasing be adjusted to reflect that this is a warning
rather than a guaranteed compile-time failure across the full supported
toolchain range?

> + */
> +#define VERIFY_USE_BPF_KEYRING	3
> +
>  static inline int system_keyring_id_check(u64 id)
>  {
>  	if (id > (unsigned long)VERIFY_USE_PLATFORM_KEYRING)


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/32530917987
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.