Skip to content

Commit 4ece312

Browse files
saschahauermimizohar
authored andcommitted
ima: fix freeing ongoing ahash_request
integrity_kernel_read() can fail in which case we forward to call ahash_request_free() on a currently running request. We have to wait for its completion before we can free the request. This was observed by interrupting a "find / -type f -xdev -print0 | xargs -0 cat 1>/dev/null" with ctrl-c on an IMA enabled filesystem. Signed-off-by: Sascha Hauer <[email protected]> Signed-off-by: Mimi Zohar <[email protected]>
1 parent f5e1040 commit 4ece312

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

security/integrity/ima/ima_crypto.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,11 @@ static int ima_calc_file_hash_atfm(struct file *file,
271271
if (rc != rbuf_len) {
272272
if (rc >= 0)
273273
rc = -EINVAL;
274+
/*
275+
* Forward current rc, do not overwrite with return value
276+
* from ahash_wait()
277+
*/
278+
ahash_wait(ahash_rc, &wait);
274279
goto out3;
275280
}
276281

0 commit comments

Comments
 (0)