]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ima: Fix a potential integer overflow in ima_appraise_measurement
authorHuaxin Lu <luhuaxin1@huawei.com>
Tue, 5 Jul 2022 05:14:17 +0000 (13:14 +0800)
committerMimi Zohar <zohar@linux.ibm.com>
Thu, 7 Jul 2022 15:50:25 +0000 (11:50 -0400)
When the ima-modsig is enabled, the rc passed to evm_verifyxattr() may be
negative, which may cause the integer overflow problem.

Fixes: d4a23e1f9d4a ("ima: Implement support for module-style appended signatures")
Signed-off-by: Huaxin Lu <luhuaxin1@huawei.com>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
security/integrity/ima/ima_appraise.c

index cdb84dccd24e01bf13152c0fe7168af5ba8088e8..bde74fcecee38e9207d601c7b47bb1b814856bba 100644 (file)
@@ -514,7 +514,8 @@ int ima_appraise_measurement(enum ima_hooks func,
                goto out;
        }
 
-       status = evm_verifyxattr(dentry, XATTR_NAME_IMA, xattr_value, rc, iint);
+       status = evm_verifyxattr(dentry, XATTR_NAME_IMA, xattr_value,
+                                rc < 0 ? 0 : rc, iint);
        switch (status) {
        case INTEGRITY_PASS:
        case INTEGRITY_PASS_IMMUTABLE: