Skip to content

Commit

Permalink
ima: Don't ignore errors from crypto_shash_update()
Browse files Browse the repository at this point in the history
commit 60386b8 upstream.

Errors returned by crypto_shash_update() are not checked in
ima_calc_boot_aggregate_tfm() and thus can be overwritten at the next
iteration of the loop. This patch adds a check after calling
crypto_shash_update() and returns immediately if the result is not zero.

Cc: stable@vger.kernel.org
Fixes: 3323eec ("integrity: IMA as an integrity service provider")
Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
robertosassu authored and gregkh committed Oct 29, 2020
1 parent ee0e071 commit dd5df08
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions security/integrity/ima/ima_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,8 @@ static int ima_calc_boot_aggregate_tfm(char *digest, u16 alg_id,
/* now accumulate with current aggregate */
rc = crypto_shash_update(shash, d.digest,
crypto_shash_digestsize(tfm));
if (rc != 0)
return rc;
}
/*
* Extend cumulative digest over TPM registers 8-9, which contain
Expand Down

0 comments on commit dd5df08

Please sign in to comment.