Skip to content

Commit 6dc387d

Browse files
mattbobrowskimimizohar
authored andcommitted
ima: fix error handling logic when file measurement failed
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: 54f0391 ("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>
1 parent 5dc4c99 commit 6dc387d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

security/integrity/ima/ima_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ int ima_collect_measurement(struct integrity_iint_cache *iint,
292292
result = ima_calc_file_hash(file, &hash.hdr);
293293
}
294294

295-
if (result == -ENOMEM)
295+
if (result && result != -EBADF && result != -EINVAL)
296296
goto out;
297297

298298
length = sizeof(hash.hdr) + hash.hdr.length;

security/integrity/ima/ima_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ static int process_measurement(struct file *file, const struct cred *cred,
337337
hash_algo = ima_get_hash_algo(xattr_value, xattr_len);
338338

339339
rc = ima_collect_measurement(iint, file, buf, size, hash_algo, modsig);
340-
if (rc == -ENOMEM)
340+
if (rc != 0 && rc != -EBADF && rc != -EINVAL)
341341
goto out_locked;
342342

343343
if (!pathbuf) /* ima_rdwr_violation possibly pre-fetched */

0 commit comments

Comments
 (0)