hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/security/integrity/evm/evm_main.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2005-2010 IBM Corporation
34 *
....@@ -5,18 +6,12 @@
56 * Mimi Zohar <zohar@us.ibm.com>
67 * Kylene Hall <kjhall@us.ibm.com>
78 *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation, version 2 of the License.
11
- *
129 * File: evm_main.c
1310 * implements evm_inode_setxattr, evm_inode_post_setxattr,
1411 * evm_inode_removexattr, and evm_verifyxattr
1512 */
1613
17
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
18
-
19
-#include <linux/module.h>
14
+#include <linux/init.h>
2015 #include <linux/crypto.h>
2116 #include <linux/audit.h>
2217 #include <linux/xattr.h>
....@@ -64,7 +59,10 @@
6459 {
6560 if (strncmp(str, "fix", 3) == 0)
6661 evm_fixmode = 1;
67
- return 0;
62
+ else
63
+ pr_err("invalid \"%s\" mode", str);
64
+
65
+ return 1;
6866 }
6967 __setup("evm=", evm_set_fixmode);
7068
....@@ -103,7 +101,8 @@
103101 return -EOPNOTSUPP;
104102
105103 list_for_each_entry_lockless(xattr, &evm_config_xattrnames, list) {
106
- error = __vfs_getxattr(dentry, inode, xattr->name, NULL, 0);
104
+ error = __vfs_getxattr(dentry, inode, xattr->name, NULL, 0,
105
+ XATTR_NOSECURITY);
107106 if (error < 0) {
108107 if (error == -ENODATA)
109108 continue;
....@@ -169,7 +168,7 @@
169168 /* check value type */
170169 switch (xattr_data->type) {
171170 case EVM_XATTR_HMAC:
172
- if (xattr_len != sizeof(struct evm_ima_xattr_data)) {
171
+ if (xattr_len != sizeof(struct evm_xattr)) {
173172 evm_status = INTEGRITY_FAIL;
174173 goto out;
175174 }
....@@ -179,7 +178,7 @@
179178 xattr_value_len, &digest);
180179 if (rc)
181180 break;
182
- rc = crypto_memneq(xattr_data->digest, digest.digest,
181
+ rc = crypto_memneq(xattr_data->data, digest.digest,
183182 SHA1_DIGEST_SIZE);
184183 if (rc)
185184 rc = -EINVAL;
....@@ -529,7 +528,7 @@
529528 const struct xattr *lsm_xattr,
530529 struct xattr *evm_xattr)
531530 {
532
- struct evm_ima_xattr_data *xattr_data;
531
+ struct evm_xattr *xattr_data;
533532 int rc;
534533
535534 if (!(evm_initialized & EVM_INIT_HMAC) ||
....@@ -540,7 +539,7 @@
540539 if (!xattr_data)
541540 return -ENOMEM;
542541
543
- xattr_data->type = EVM_XATTR_HMAC;
542
+ xattr_data->data.type = EVM_XATTR_HMAC;
544543 rc = evm_init_hmac(inode, lsm_xattr, xattr_data->digest);
545544 if (rc < 0)
546545 goto out;
....@@ -570,7 +569,6 @@
570569 {
571570 int error;
572571 struct list_head *pos, *q;
573
- struct xattr_list *xattr;
574572
575573 evm_init_config();
576574
....@@ -587,11 +585,8 @@
587585 error:
588586 if (error != 0) {
589587 if (!list_empty(&evm_config_xattrnames)) {
590
- list_for_each_safe(pos, q, &evm_config_xattrnames) {
591
- xattr = list_entry(pos, struct xattr_list,
592
- list);
588
+ list_for_each_safe(pos, q, &evm_config_xattrnames)
593589 list_del(pos);
594
- }
595590 }
596591 }
597592
....@@ -599,6 +594,3 @@
599594 }
600595
601596 late_initcall(init_evm);
602
-
603
-MODULE_DESCRIPTION("Extended Verification Module");
604
-MODULE_LICENSE("GPL");