Skip to contentSkip to conversation

module: Add log information for loading module failures

PATCH In review Yusong Gao 2 participants 2 messages Jun 19, 2024 – Jun 20, 2024 Module support

lore
Share & tools
lore

Yusong Gao

author
#0 lore raw

PATCH v2 1/1 module: Add log information for loading module failures

Add log information in kernel-space when loading module failures. Try to load the unsigned module and the module with bad signature when set 1 to /sys/module/module/parameters/sig_enforce.

Unsigned module case:
(linux) insmod unsigned.ko

[   18.714661] Loading of unsigned module is rejected

insmod: can't insert 'unsigned.ko': Key was rejected by service (linux)

Bad signature module case:
(linux) insmod bad_signature.ko
insmod: can't insert 'bad_signature.ko': Key was rejected by service (linux)

There have different logging behavior the bad signature case only log in user-space, add log info for fatal errors in module_sig_check().

---
V2: Change print level from notice to debug.

---
 kernel/module/signing.c | 1 +
 1 file changed, 1 insertion(+)
kernel/module/signing.c +1 -0
index a2ff4242e623..b0c7b30e4d89 100644
@@ -113,6 +113,7 @@ int module_sig_check(struct load_info *info, int flags)
 		 * unparseable signatures, and signature check failures --
 		 * even if signatures aren't required.
 		 */
+		pr_debug("Loading module failed (errno=%d)\n", -err);
 		return err;
 	}
 
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 30 lines · Yusong Gao

Add log information in kernel-space when loading module failures. Try to load the unsigned module and the module with bad signature when set 1 to /sys/module/module/parameters/sig_enforce.

Unsigned module case:
(linux) insmod unsigned.ko

[   18.714661] Loading of unsigned module is rejected

insmod: can't insert 'unsigned.ko': Key was rejected by service (linux)

Bad signature module case:
(linux) insmod bad_signature.ko
insmod: can't insert 'bad_signature.ko': Key was rejected by service (linux)

There have different logging behavior the bad signature case only log in user-space, add log info for fatal errors in module_sig_check().

---
V2: Change print level from notice to debug.

---
 kernel/module/signing.c | 1 +
 1 file changed, 1 insertion(+)
kernel/module/signing.c +0 -0
index a2ff4242e623..b0c7b30e4d89 100644

kernel/module/signing.c int module_sig_check(struct load_info *info, int flags) · line 116

Quoted 4 lines
kernel/module/signing.c +1 -0
@@ -113,6 +113,7 @@ int module_sig_check(struct load_info *info, int flags)
 		 * unparseable signatures, and signature check failures --
 		 * even if signatures aren't required.
 		 */
+		pr_debug("Loading module failed (errno=%d)\n", -err);

There are so many debug message, this doesn't help explain why, ie, tha this is a signature issue.

Luis