Blame view
kernel/module_signing.c
1.06 KB
b4d0d230c treewide: Replace... |
1 |
// SPDX-License-Identifier: GPL-2.0-or-later |
106a4ee25 module: signature... |
2 3 4 5 |
/* Module signature checker * * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved. * Written by David Howells (dhowells@redhat.com) |
106a4ee25 module: signature... |
6 7 8 |
*/ #include <linux/kernel.h> |
146aa8b14 KEYS: Merge the t... |
9 |
#include <linux/errno.h> |
c8424e776 MODSIGN: Export m... |
10 11 |
#include <linux/module.h> #include <linux/module_signature.h> |
89053aa9c MODSIGN: linux/st... |
12 |
#include <linux/string.h> |
a511e1af8 KEYS: Move the po... |
13 |
#include <linux/verification.h> |
3f1e1bea3 MODSIGN: Use PKCS... |
14 |
#include <crypto/public_key.h> |
106a4ee25 module: signature... |
15 |
#include "module-internal.h" |
48ba2462a MODSIGN: Implemen... |
16 |
/* |
106a4ee25 module: signature... |
17 18 |
* Verify the signature on a module. */ |
f314dfea1 modsign: log modu... |
19 |
int mod_verify_sig(const void *mod, struct load_info *info) |
106a4ee25 module: signature... |
20 |
{ |
48ba2462a MODSIGN: Implemen... |
21 |
struct module_signature ms; |
f314dfea1 modsign: log modu... |
22 |
size_t sig_len, modlen = info->len; |
c8424e776 MODSIGN: Export m... |
23 |
int ret; |
48ba2462a MODSIGN: Implemen... |
24 |
|
0390c8835 module_signing: f... |
25 26 |
pr_devel("==>%s(,%zu) ", __func__, modlen); |
48ba2462a MODSIGN: Implemen... |
27 |
|
caabe2405 MODSIGN: Move the... |
28 |
if (modlen <= sizeof(ms)) |
48ba2462a MODSIGN: Implemen... |
29 |
return -EBADMSG; |
caabe2405 MODSIGN: Move the... |
30 |
memcpy(&ms, mod + (modlen - sizeof(ms)), sizeof(ms)); |
c8424e776 MODSIGN: Export m... |
31 32 33 34 |
ret = mod_check_sig(&ms, modlen, info->name); if (ret) return ret; |
48ba2462a MODSIGN: Implemen... |
35 36 |
sig_len = be32_to_cpu(ms.sig_len); |
c8424e776 MODSIGN: Export m... |
37 |
modlen -= sig_len + sizeof(ms); |
f314dfea1 modsign: log modu... |
38 |
info->len = modlen; |
48ba2462a MODSIGN: Implemen... |
39 |
|
e68503bd6 KEYS: Generalise ... |
40 |
return verify_pkcs7_signature(mod, modlen, mod + modlen, sig_len, |
e84cd7ee6 modsign: use all ... |
41 42 |
VERIFY_USE_SECONDARY_KEYRING, VERIFYING_MODULE_SIGNATURE, |
e68503bd6 KEYS: Generalise ... |
43 |
NULL, NULL); |
106a4ee25 module: signature... |
44 |
} |