cpuidle: teo: Exclude cpuidle overhead from computations
[linux/fpc-iii.git] / kernel / module_signing.c
blob9d9fc678c91d6668103faced46bc2a5f47baab49
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* Module signature checker
4 * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
6 */
8 #include <linux/kernel.h>
9 #include <linux/errno.h>
10 #include <linux/module.h>
11 #include <linux/module_signature.h>
12 #include <linux/string.h>
13 #include <linux/verification.h>
14 #include <crypto/public_key.h>
15 #include "module-internal.h"
18 * Verify the signature on a module.
20 int mod_verify_sig(const void *mod, struct load_info *info)
22 struct module_signature ms;
23 size_t sig_len, modlen = info->len;
24 int ret;
26 pr_devel("==>%s(,%zu)\n", __func__, modlen);
28 if (modlen <= sizeof(ms))
29 return -EBADMSG;
31 memcpy(&ms, mod + (modlen - sizeof(ms)), sizeof(ms));
33 ret = mod_check_sig(&ms, modlen, info->name);
34 if (ret)
35 return ret;
37 sig_len = be32_to_cpu(ms.sig_len);
38 modlen -= sig_len + sizeof(ms);
39 info->len = modlen;
41 return verify_pkcs7_signature(mod, modlen, mod + modlen, sig_len,
42 VERIFY_USE_SECONDARY_KEYRING,
43 VERIFYING_MODULE_SIGNATURE,
44 NULL, NULL);