hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
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;
....@@ -474,7 +473,9 @@
474473
475474 /**
476475 * evm_inode_setattr - prevent updating an invalid EVM extended attribute
476
+ * @idmap: idmap of the mount
477477 * @dentry: pointer to the affected dentry
478
+ * @attr: iattr structure containing the new file attributes
478479 *
479480 * Permit update of file attributes when files have a valid EVM signature,
480481 * except in the case of them having an immutable portable signature.
....@@ -529,7 +530,7 @@
529530 const struct xattr *lsm_xattr,
530531 struct xattr *evm_xattr)
531532 {
532
- struct evm_ima_xattr_data *xattr_data;
533
+ struct evm_xattr *xattr_data;
533534 int rc;
534535
535536 if (!(evm_initialized & EVM_INIT_HMAC) ||
....@@ -540,7 +541,7 @@
540541 if (!xattr_data)
541542 return -ENOMEM;
542543
543
- xattr_data->type = EVM_XATTR_HMAC;
544
+ xattr_data->data.type = EVM_XATTR_HMAC;
544545 rc = evm_init_hmac(inode, lsm_xattr, xattr_data->digest);
545546 if (rc < 0)
546547 goto out;
....@@ -570,7 +571,6 @@
570571 {
571572 int error;
572573 struct list_head *pos, *q;
573
- struct xattr_list *xattr;
574574
575575 evm_init_config();
576576
....@@ -587,11 +587,8 @@
587587 error:
588588 if (error != 0) {
589589 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);
590
+ list_for_each_safe(pos, q, &evm_config_xattrnames)
593591 list_del(pos);
594
- }
595592 }
596593 }
597594
....@@ -599,6 +596,3 @@
599596 }
600597
601598 late_initcall(init_evm);
602
-
603
-MODULE_DESCRIPTION("Extended Verification Module");
604
-MODULE_LICENSE("GPL");