linux-modules.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix segmentation fault on empty signature key
@ 2015-02-14 23:34 Tobias Stoeckmann
  2015-02-15 11:46 ` Lucas De Marchi
  2015-02-18 18:22 ` Lucas De Marchi
  0 siblings, 2 replies; 3+ messages in thread
From: Tobias Stoeckmann @ 2015-02-14 23:34 UTC (permalink / raw)
  To: linux-modules

[-- Attachment #1: Type: text/plain, Size: 1104 bytes --]

Hi,

a segmentation fault occurs if a module has an empty key attached to
its signature.

This happens because it's assumed that at least one key byte is
available, subtracting it in libkmod-module line 2249.  This -1 value
is casted to an unsigned data type later on, resulting in illegal
memory access.

Attached please find a proof of concept module, tested on amd64:

tobias:~$ modinfo 0sig.ko
filename:       /home/tobias/0sig.ko
Segmentation fault

Tobias
---
 libkmod/libkmod-module.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
index 30f15ca..ca703a7 100644
--- a/libkmod/libkmod-module.c
+++ b/libkmod/libkmod-module.c
@@ -2246,7 +2246,8 @@ KMOD_EXPORT int kmod_module_get_info(const struct kmod_module *mod, struct kmod_
 				key_hex[i * 3 + 2] = ':';
 		}
 		n = kmod_module_info_append(list, "sig_key", strlen("sig_key"),
-				key_hex, sig_info.key_id_len * 3 - 1);
+				key_hex, sig_info.key_id_len == 0 ? 0 :
+				sig_info.key_id_len * 3 - 1);
 		free(key_hex);
 		if (n == NULL)
 			goto list_error;
-- 
2.3.0


[-- Attachment #2: 0sig.ko --]
[-- Type: application/octet-stream, Size: 336 bytes --]

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-02-18 18:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-14 23:34 [PATCH] Fix segmentation fault on empty signature key Tobias Stoeckmann
2015-02-15 11:46 ` Lucas De Marchi
2015-02-18 18:22 ` Lucas De Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).