summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorAlexei Starovoitov <ast@kernel.org>2026-08-29 18:17:51 -0700
committerAlexei Starovoitov <ast@kernel.org>2026-08-29 18:17:51 -0700
commit776c86a3e72265bb2e71d515995fec0992a715a8 (patch)
tree7e22aa22139b6607c3feece51bf7752f2e542370 /include/linux
parent6ae934b5b799446b58f327d723b4acd3178e9330 (diff)
parent8588fa592985accc22c6757d6397d588fe71752d (diff)
Merge branch 'bpf-keyring-and-signed-loader-ml-dsa-support'
Daniel Borkmann says: ==================== BPF keyring and signed loader ML-DSA support Add a dedicated BPF keyring which is integrated for BPF signing. It is modelled after the dm-verity keyring which was added in commit 033724b ("dm-verity: add dm-verity keyring") and which can eventually be used also via systemd through the same enrollment method as in dm-verity's case. It is selected with a new well-known keyring_id VERIFY_USE_BPF_KEYRING and gives an operator a place to enroll a BPF-only signing key at boot, specifically scoped to signed BPF program loading. Next, to demonstrate that BPF signing is algorithm agnostic, we add a few small tooling changes to support ML-DSA and integrate everything into BPF selftest for BPF CI to ensure nothing breaks with future changes. For more details, see individual commits. v3 -> v4: - Refactor the keyring dispatch a bit better wrt if/else chaining (BPF CI) - Improve selftest for bpf keyring in signed loader wrt skips (BPF CI) - selftests/bpf/config sorting (BPF CI) - Misc documentation improvement (BPF CI) v2 -> v3: - Added KEY_SPEC_BPF_KEYRING rather than VERIFY_USE_BPF_KEYRING then it can also be looked up via lookup_user_key (Christian Brauner) - Added CMS_NO_SIGNING_TIME to bpftool patch (Sashiko) v1 -> v2: - Mainly addressing LLM feedback in docs, commit message and selftests (BPF CI, sashiko) - Fix reasoning on BPF_PROG_MAX_SIGNATURE_SIZE - Add reasoning about bpftool MAX_SIG_SIZE change and pinning the CMS digest to SHA-512 - Fix misc signing.rst phrasing - Fix a potential NULL deref in bpf_keyring_lookup selftest code - Add CONFIG_CRYPTO_SHA512=y to BPF selftest config - Clean up key material on ML-DSA signed loader test failure - Refactor duplicated bpf_attr setup for bpf keyring tests - Fix wording in kernel-parameters.txt ==================== Link: https://patch.msgid.link/20260828175227.1537793-1-daniel@iogearbox.net Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/bpf.h13
-rw-r--r--include/linux/key.h2
2 files changed, 15 insertions, 0 deletions
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index c2027688be3e..3a7eb2185c35 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -1735,6 +1735,7 @@ enum bpf_sig_keyring {
BPF_SIG_KEYRING_SECONDARY,
BPF_SIG_KEYRING_PLATFORM,
BPF_SIG_KEYRING_USER,
+ BPF_SIG_KEYRING_BPF,
};
struct bpf_prog_aux {
@@ -3819,6 +3820,8 @@ struct bpf_key {
#if defined(CONFIG_KEYS) && defined(CONFIG_BPF_SYSCALL)
struct bpf_key *bpf_lookup_user_key(s32 serial, u64 flags);
struct bpf_key *bpf_lookup_system_key(u64 id);
+struct bpf_key *bpf_lookup_keyring(void);
+bool bpf_keyring_enforced(void);
void bpf_key_put(struct bpf_key *bkey);
int bpf_verify_pkcs7_signature(const struct bpf_dynptr *data_p,
const struct bpf_dynptr *sig_p,
@@ -3839,6 +3842,16 @@ static inline struct bpf_key *bpf_lookup_system_key(u64 id)
return NULL;
}
+static inline struct bpf_key *bpf_lookup_keyring(void)
+{
+ return NULL;
+}
+
+static inline bool bpf_keyring_enforced(void)
+{
+ return false;
+}
+
static inline void bpf_key_put(struct bpf_key *bkey)
{
}
diff --git a/include/linux/key.h b/include/linux/key.h
index 81b8f05c6898..bd10fe45819d 100644
--- a/include/linux/key.h
+++ b/include/linux/key.h
@@ -440,6 +440,8 @@ extern key_ref_t keyring_search(key_ref_t keyring,
extern int keyring_restrict(key_ref_t keyring, const char *type,
const char *restriction);
+extern void key_register_bpf_keyring(struct key *keyring);
+
extern struct key *key_lookup(key_serial_t id);
static inline key_serial_t key_serial(const struct key *key)