Skip to content

Commit 688965a

Browse files
saschahauergregkh
authored andcommitted
ima: fix freeing ongoing ahash_request
[ Upstream commit 4ece312 ] 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 <s.hauer@pengutronix.de> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 4190c07 commit 688965a

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎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)