0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <linux/errno.h>
0010 #include <linux/printk.h>
0011 #include <linux/module_signature.h>
0012 #include <asm/byteorder.h>
0013
0014
0015
0016
0017
0018
0019
0020
0021 int mod_check_sig(const struct module_signature *ms, size_t file_len,
0022 const char *name)
0023 {
0024 if (be32_to_cpu(ms->sig_len) >= file_len - sizeof(*ms))
0025 return -EBADMSG;
0026
0027 if (ms->id_type != PKEY_ID_PKCS7) {
0028 pr_err("%s: not signed with expected PKCS#7 message\n",
0029 name);
0030 return -ENOPKG;
0031 }
0032
0033 if (ms->algo != 0 ||
0034 ms->hash != 0 ||
0035 ms->signer_len != 0 ||
0036 ms->key_id_len != 0 ||
0037 ms->__pad[0] != 0 ||
0038 ms->__pad[1] != 0 ||
0039 ms->__pad[2] != 0) {
0040 pr_err("%s: PKCS#7 signature info has unexpected non-zero params\n",
0041 name);
0042 return -EBADMSG;
0043 }
0044
0045 return 0;
0046 }