File: KEYS-Make-use-of-platform-keyring-for-module-signature.patch

package info (click to toggle)
linux 6.17.2-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 1,734,084 kB
  • sloc: ansic: 26,674,600; asm: 271,176; sh: 147,222; python: 75,910; makefile: 57,291; perl: 36,942; xml: 19,562; cpp: 5,894; yacc: 4,909; lex: 2,943; awk: 1,556; sed: 28; ruby: 25
file content (38 lines) | stat: -rw-r--r-- 1,513 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
From: Robert Holmes <robeholmes@gmail.com>
Date: Tue, 23 Apr 2019 07:39:29 +0000
Subject: [PATCH] KEYS: Make use of platform keyring for module signature
 verify
Bug-Debian: https://bugs.debian.org/935945
Bug-Debian: https://bugs.debian.org/1030200
Origin: https://src.fedoraproject.org/rpms/kernel/raw/master/f/KEYS-Make-use-of-platform-keyring-for-module-signature.patch
Forwarded: https://lore.kernel.org/linux-modules/qvgp2il2co4iyxkzxvcs4p2bpyilqsbfgcprtpfrsajwae2etc@3z2s2o52i3xg/t/#u

This allows a cert in DB to be used to sign modules,
in addition to certs in the MoK and built-in keyrings.

Signed-off-by: Robert Holmes <robeholmes@gmail.com>
Signed-off-by: Jeremy Cline <jcline@redhat.com>
[bwh: Forward-ported to 5.19: adjust filename]
[наб: reinstate for 6.1, re-write description]
---
--- a/kernel/module/signing.c
+++ b/kernel/module/signing.c
@@ -61,10 +61,17 @@
 	modlen -= sig_len + sizeof(ms);
 	info->len = modlen;
 
-	return verify_pkcs7_signature(mod, modlen, mod + modlen, sig_len,
+	ret = verify_pkcs7_signature(mod, modlen, mod + modlen, sig_len,
 				      VERIFY_USE_SECONDARY_KEYRING,
 				      VERIFYING_MODULE_SIGNATURE,
 				      NULL, NULL);
+	if (ret == -ENOKEY && IS_ENABLED(CONFIG_INTEGRITY_PLATFORM_KEYRING)) {
+		ret = verify_pkcs7_signature(mod, modlen, mod + modlen, sig_len,
+					      VERIFY_USE_PLATFORM_KEYRING,
+					      VERIFYING_MODULE_SIGNATURE,
+					      NULL, NULL);
+	}
+        return ret;
 }
 
 int module_sig_check(struct load_info *info, int flags)