acrn-kernel/security/integrity
Roberto Sassu f375bcf69f ima: Fix memory leak in __ima_inode_hash()
commit 8c1d6a050a upstream.

Commit f3cc6b25dc ("ima: always measure and audit files in policy") lets
measurement or audit happen even if the file digest cannot be calculated.

As a result, iint->ima_hash could have been allocated despite
ima_collect_measurement() returning an error.

Since ima_hash belongs to a temporary inode metadata structure, declared
at the beginning of __ima_inode_hash(), just add a kfree() call if
ima_collect_measurement() returns an error different from -ENOMEM (in that
case, ima_hash should not have been allocated).

Cc: stable@vger.kernel.org
Fixes: 280fe8367b ("ima: Always return a file measurement in ima_file_hash()")
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>
2023-01-07 11:11:52 +01:00
..
evm acl: move idmapping handling into posix_acl_xattr_set() 2022-08-31 16:37:58 +02:00
ima ima: Fix memory leak in __ima_inode_hash() 2023-01-07 11:11:52 +01:00
platform_certs efi: Add iMac Pro 2017 to uefi skip cert quirk 2023-01-07 11:11:51 +01:00
Kconfig integrity: Introduce a Linux keyring called machine 2022-03-08 13:55:52 +02:00
Makefile integrity: Introduce a Linux keyring called machine 2022-03-08 13:55:52 +02:00
digsig.c integrity: Fix memory leakage in keyring allocation error path 2022-12-31 13:32:11 +01:00
digsig_asymmetric.c ima: fix reference leak in asymmetric_verify() 2022-01-24 18:37:36 -05:00
iint.c
integrity.h ima: support fs-verity file digest based version 3 signatures 2022-05-05 17:41:51 -04:00
integrity_audit.c integrity: check the return value of audit_log_start() 2022-02-02 11:44:23 -05:00