Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * Module signature checker
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  * Written by David Howells (dhowells@redhat.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/printk.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/module_signature.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <asm/byteorder.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)  * mod_check_sig - check that the given signature is sane
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)  * @ms:		Signature to check.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)  * @file_len:	Size of the file to which @ms is appended.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)  * @name:	What is being checked. Used for error messages.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) int mod_check_sig(const struct module_signature *ms, size_t file_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 		  const char *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 	if (be32_to_cpu(ms->sig_len) >= file_len - sizeof(*ms))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 		return -EBADMSG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	if (ms->id_type != PKEY_ID_PKCS7) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 		pr_err("%s: not signed with expected PKCS#7 message\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 		       name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 		return -ENOPKG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	if (ms->algo != 0 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	    ms->hash != 0 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	    ms->signer_len != 0 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	    ms->key_id_len != 0 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	    ms->__pad[0] != 0 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	    ms->__pad[1] != 0 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	    ms->__pad[2] != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 		pr_err("%s: PKCS#7 signature info has unexpected non-zero params\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 		       name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 		return -EBADMSG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) }