[PATCH 3/4] module: search the key only by keyid

From: Dmitry Kasatkin
Date: Fri Oct 03 2014 - 05:11:16 EST


Latest KEYS code change the way keys identified and module
signing keys are not searchable anymore with original id.

This patch fixes this problem without change module signature
data.

Signed-off-by: Dmitry Kasatkin <d.kasatkin@xxxxxxxxxxx>
---
kernel/module_signing.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/kernel/module_signing.c b/kernel/module_signing.c
index be5b8fa..f329de8 100644
--- a/kernel/module_signing.c
+++ b/kernel/module_signing.c
@@ -134,26 +134,20 @@ static struct key *request_asymmetric_key(const char *signer, size_t signer_len,
const u8 *key_id, size_t key_id_len)
{
key_ref_t key;
- size_t i;
char *id, *q;

pr_devel("==>%s(,%zu,,%zu)\n", __func__, signer_len, key_id_len);

/* Construct an identifier. */
- id = kmalloc(signer_len + 2 + key_id_len * 2 + 1, GFP_KERNEL);
+ id = kmalloc(2 + 1 + key_id_len * 2 + 1, GFP_KERNEL);
if (!id)
return ERR_PTR(-ENOKEY);

- memcpy(id, signer, signer_len);
-
- q = id + signer_len;
+ q = id;
+ *q++ = 'i';
+ *q++ = 'd';
*q++ = ':';
- *q++ = ' ';
- for (i = 0; i < key_id_len; i++) {
- *q++ = hex_asc[*key_id >> 4];
- *q++ = hex_asc[*key_id++ & 0x0f];
- }
-
+ q = bin2hex(q, key_id, key_id_len);
*q = 0;

pr_debug("Look up: \"%s\"\n", id);
--
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/