summaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorMatt Bobrowski <mattbobrowski@google.com>2023-01-04 03:41:44 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-03-10 09:34:15 +0100
commit7327b30a00842768f18345e21e35a3625ce9b2fe (patch)
treec6683f3e1289695e7bf77aca9b3cb9ad3aec922b /security
parent1beb41094bbf3c38edfb16b4ee0ed8ac7ca5e253 (diff)
downloadlinux-stable-7327b30a00842768f18345e21e35a3625ce9b2fe.tar.gz
linux-stable-7327b30a00842768f18345e21e35a3625ce9b2fe.tar.bz2
linux-stable-7327b30a00842768f18345e21e35a3625ce9b2fe.zip
ima: fix error handling logic when file measurement failed
commit 6dc387d52eb67f45d68caa263704fa4e39ef8e76 upstream. Restore the error handling logic so that when file measurement fails, the respective iint entry is not left with the digest data being populated with zeroes. Fixes: 54f03916fb89 ("ima: permit fsverity's file digests in the IMA measurement list") Cc: stable@vger.kernel.org # 5.19 Signed-off-by: Matt Bobrowski <mattbobrowski@google.com> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'security')
-rw-r--r--security/integrity/ima/ima_api.c2
-rw-r--r--security/integrity/ima/ima_main.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
index c1e76282b5ee..1e3a7a4f8833 100644
--- a/security/integrity/ima/ima_api.c
+++ b/security/integrity/ima/ima_api.c
@@ -292,7 +292,7 @@ int ima_collect_measurement(struct integrity_iint_cache *iint,
result = ima_calc_file_hash(file, &hash.hdr);
}
- if (result == -ENOMEM)
+ if (result && result != -EBADF && result != -EINVAL)
goto out;
length = sizeof(hash.hdr) + hash.hdr.length;
diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
index 4a207a3ef7ef..e44d2dbb47fd 100644
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -335,7 +335,7 @@ static int process_measurement(struct file *file, const struct cred *cred,
hash_algo = ima_get_hash_algo(xattr_value, xattr_len);
rc = ima_collect_measurement(iint, file, buf, size, hash_algo, modsig);
- if (rc == -ENOMEM)
+ if (rc != 0 && rc != -EBADF && rc != -EINVAL)
goto out_locked;
if (!pathbuf) /* ima_rdwr_violation possibly pre-fetched */