diff options
author | Mikhail Novosyolov <m.novosyolov@rosalinux.ru> | 2022-09-25 17:46:08 +0300 |
---|---|---|
committer | Lucas De Marchi <lucas.de.marchi@gmail.com> | 2022-10-03 06:59:41 -0700 |
commit | d5950b0b5e66a5ec1c21b638dec3974056aaabeb (patch) | |
tree | e161c23be7e71410dd23f33888dfe7bf4cde35d2 | |
parent | b4d281f962be74adfbae9d7bead6a7352033342c (diff) | |
download | kmod-d5950b0b5e66a5ec1c21b638dec3974056aaabeb.tar.gz kmod-d5950b0b5e66a5ec1c21b638dec3974056aaabeb.tar.bz2 kmod-d5950b0b5e66a5ec1c21b638dec3974056aaabeb.zip |
libkmod: do not crash on unknown signature algorithm
Example kernel module:
https://file-store.rosalinux.ru/download/7281f97e0c04c0f818ad3f936706f4a407e8dc7e
(/lib/modules/5.15.67-generic-1rosa2021.1-x86_64/kernel/drivers/usb/host/xhci-pci.ko.zst)
It is signed with Streebog 512.
libkmod v30 crashed in libkmod-module.c:2413 in this code:
n = kmod_module_info_append(list,
"sig_hashalgo", strlen("sig_hashalgo"),
sig_info.hash_algo, strlen(sig_info.hash_algo));
because strlen() got null.
-rw-r--r-- | libkmod/libkmod-signature.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/libkmod/libkmod-signature.c b/libkmod/libkmod-signature.c index 4ae5af6..092f396 100644 --- a/libkmod/libkmod-signature.c +++ b/libkmod/libkmod-signature.c @@ -278,6 +278,9 @@ static bool fill_pkcs7(const char *mem, off_t size, X509_ALGOR_get0(&o, NULL, NULL, dig_alg); sig_info->hash_algo = pkey_hash_algo[obj_to_hash_algo(o)]; + // hash algo has not been recognized + if (sig_info->hash_algo == NULL) + goto err3; sig_info->id_type = pkey_id_type[modsig->id_type]; pvt = malloc(sizeof(*pvt)); |