diff options
author | Matt Bobrowski <mattbobrowski@google.com> | 2023-01-04 04:41:56 +0100 |
---|---|---|
committer | Mimi Zohar <zohar@linux.ibm.com> | 2023-01-18 19:21:50 +0100 |
commit | 62622dab0a285033e971641b781bc917d5939ce6 (patch) | |
tree | 7a90ee9d2df55a8b25f4b0a9abc2c89e72d24bc3 /security | |
parent | ima: fix error handling logic when file measurement failed (diff) | |
download | linux-62622dab0a285033e971641b781bc917d5939ce6.tar.xz linux-62622dab0a285033e971641b781bc917d5939ce6.zip |
ima: return IMA digest value only when IMA_COLLECTED flag is set
The IMA_COLLECTED flag indicates whether the IMA subsystem has
successfully collected a measurement for a given file object. Ensure
that we return the respective digest value stored within the iint
entry only when this flag has been set.
Failing to check for the presence of this flag exposes consumers of
this IMA API to receive potentially undesired IMA digest values when
an erroneous condition has been experienced in some of the lower level
IMA API code.
Signed-off-by: Matt Bobrowski <mattbobrowski@google.com>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
Diffstat (limited to 'security')
-rw-r--r-- | security/integrity/ima/ima_main.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c index b1ae0f2751f1..1d40cdfa23d5 100644 --- a/security/integrity/ima/ima_main.c +++ b/security/integrity/ima/ima_main.c @@ -563,7 +563,7 @@ static int __ima_inode_hash(struct inode *inode, struct file *file, char *buf, * ima_file_hash can be called when ima_collect_measurement has still * not been called, we might not always have a hash. */ - if (!iint->ima_hash) { + if (!iint->ima_hash || !(iint->flags & IMA_COLLECTED)) { mutex_unlock(&iint->mutex); return -EOPNOTSUPP; } |