eBPF-based security platform
kernel: drop the dm-verity keyring patch now upstream
Daniel Borkmann360877e378b0
diff --git a/Documentation/requirements.rst b/Documentation/requirements.rstindex 45e6c626..558c29e6 100644--- a/Documentation/requirements.rst+++ b/Documentation/requirements.rst@@ -145,9 +145,8 @@ and config mappings use verity format 1, SHA-256, 4096-byte blocks and astandard verity superblock. ``CONFIG_DM_VERITY_VERIFY_ROOTHASH_SIG`` isrequired for the config root signature. The kernel must provide the``.dm-verity`` keyring enrollment and sealing API, including-``KEY_SPEC_DM_VERITY_KEYRING``. The upstream change was posted as patch 1/3-of the bpf-next v2 series ``keys: Add well known IDs for fs-verity/dm-verity-keys``. The test-kernel build applies the local copy under ``kernel/``.+``KEY_SPEC_DM_VERITY_KEYRING``, merged for Linux 7.4 as commit+1041fca2ee8a (``keys: add KEY_SPEC_DM_VERITY_KEYRING``).Image boot uses``dm_verity.keyring_unsealed=1`` so the trusted initrd can enroll its configcertificate and seal that keyring. Built-in trusted certificates remain@@ -442,7 +441,7 @@ binary, as described in `operations <operations.rst>`__.Use the upstream development-tree ABI and options described above. Imagemode uses existing LSM hooks. A kernel predating-``KEY_SPEC_DM_VERITY_KEYRING`` needs the upstream keyring-ID patch above. The+``KEY_SPEC_DM_VERITY_KEYRING`` needs commit 1041fca2ee8a above. The`config-images <config-images.rst>`__ guide describes the two policy modes,test commands and remaining protection gaps. Run both complete policy-modesuites when validating a deployment.diff --git a/kernel/0001-keys-add-KEY-SPEC-DM-VERITY-KEYRING.patch b/kernel/0001-keys-add-KEY-SPEC-DM-VERITY-KEYRING.patchdeleted file mode 100644index eafbfe03..00000000--- a/kernel/0001-keys-add-KEY-SPEC-DM-VERITY-KEYRING.patch+++ /dev/null@@ -1,107 +0,0 @@-From: Andrew Halaney <[email protected]>-Subject: [PATCH bpf-next v2 1/3] keys: add KEY_SPEC_DM_VERITY_KEYRING-Message-Id: <20261008-ajhalaney-dmverity-key-identifier-v2-1-008456d189cb@amutable.com>--Local build copy of patch 1/3 from the upstream bpf-next v2 series-"keys: Add well known IDs for fs-verity/dm-verity keys".--diff --git a/drivers/md/dm-verity-verify-sig.c b/drivers/md/dm-verity-verify-sig.c-index b2b55c41e..da509dcdd 100644---- a/drivers/md/dm-verity-verify-sig.c-+++ b/drivers/md/dm-verity-verify-sig.c-@@ -189,11 +189,14 @@ int __init dm_verity_verify_sig_init(void)- keyring_restrict(make_key_ref(dm_verity_keyring, true), NULL, NULL))- panic("dm-verity can't seal keyring\n");--+ key_register_dm_verity_keyring(dm_verity_keyring);-+- return 0;- }-- void dm_verity_verify_sig_exit(void)- {-+ key_register_dm_verity_keyring(NULL);- key_revoke(dm_verity_keyring);- key_put(dm_verity_keyring);- }-diff --git a/include/linux/key.h b/include/linux/key.h-index dae5ba255..0289351d1 100644---- a/include/linux/key.h-+++ b/include/linux/key.h-@@ -446,6 +446,7 @@ extern int keyring_restrict(key_ref_t keyring, const char *type,- const char *restriction);-- extern void key_register_bpf_keyring(struct key *keyring);-+extern void key_register_dm_verity_keyring(struct key *keyring);-- extern struct key *key_lookup(key_serial_t id);--diff --git a/include/uapi/linux/keyctl.h b/include/uapi/linux/keyctl.h-index fa85b9760..75923941f 100644---- a/include/uapi/linux/keyctl.h-+++ b/include/uapi/linux/keyctl.h-@@ -25,6 +25,7 @@- #define KEY_SPEC_REQKEY_AUTH_KEY -7 /* - key ID for assumed request_key auth key */- #define KEY_SPEC_REQUESTOR_KEYRING -8 /* - key ID for request_key() dest keyring */- #define KEY_SPEC_BPF_KEYRING -9 /* - key ID for the BPF-specific keyring */-+#define KEY_SPEC_DM_VERITY_KEYRING -10 /* - key ID for the .dm-verity keyring */-- /* request-key default keyrings */- #define KEY_REQKEY_DEFL_NO_CHANGE -1-diff --git a/security/keys/process_keys.c b/security/keys/process_keys.c-index cf638bf1f..e9e9a64ec 100644---- a/security/keys/process_keys.c-+++ b/security/keys/process_keys.c-@@ -25,6 +25,10 @@ static DEFINE_MUTEX(key_session_mutex);- /* BPF keyring reachable through KEY_SPEC_BPF_KEYRING */- static struct key *bpf_keyring __ro_after_init;--+/* dm-verity keyring reachable through KEY_SPEC_DM_VERITY_KEYRING */-+static struct key *dm_verity_keyring;-+static DEFINE_SPINLOCK(dm_verity_keyring_lock);-+- /* The root user's tracking struct */- struct key_user root_key_user = {- .usage = REFCOUNT_INIT(3),-@@ -606,6 +610,23 @@ void key_register_bpf_keyring(struct key *keyring)- bpf_keyring = keyring;- }--+/**-+ * key_register_dm_verity_keyring - Publish the keyring for KEY_SPEC_DM_VERITY_KEYRING-+ * @keyring: The keyring to publish, or NULL to withdraw it-+ *-+ * Make @keyring reachable by userspace through the KEY_SPEC_DM_VERITY_KEYRING-+ * special key ID, so provisioning it does not require scraping /proc/keys.-+ * dm-verity can be unloaded as a module, so serialize access with-+ * dm_verity_keyring_lock.-+ */-+void key_register_dm_verity_keyring(struct key *keyring)-+{-+ spin_lock(&dm_verity_keyring_lock);-+ dm_verity_keyring = keyring;-+ spin_unlock(&dm_verity_keyring_lock);-+}-+EXPORT_SYMBOL_GPL(key_register_dm_verity_keyring);-+- /*- * Look up a key ID given us by userspace with a given permissions mask to get- * the key it refers to.-@@ -765,6 +786,17 @@ key_ref_t lookup_user_key(key_serial_t id, unsigned long lflags,- key_ref = make_key_ref(key, 0);- break;--+ case KEY_SPEC_DM_VERITY_KEYRING:-+ spin_lock(&dm_verity_keyring_lock);-+ key = dm_verity_keyring;-+ if (key)-+ __key_get(key);-+ spin_unlock(&dm_verity_keyring_lock);-+ if (!key)-+ goto error;-+ key_ref = make_key_ref(key, 0);-+ break;-+- default:- key_ref = ERR_PTR(-EINVAL);- if (id < 1)