Skip to content

Commit 556d971

Browse files
bauermannmimizohar
authored andcommitted
ima: Fix use after free in ima_read_modsig()
If we can't parse the PKCS7 in the appended modsig, we will free the modsig structure and then access one of its members to determine the error value. Fixes: 39b0709 ("ima: Implement support for module-style appended signatures") Reported-by: kbuild test robot <[email protected]> Reported-by: Julia Lawall <[email protected]> Reported-by: Dan Carpenter <[email protected]> Signed-off-by: Thiago Jung Bauermann <[email protected]> Reviewed-by: Gustavo A. R. Silva <[email protected]> Signed-off-by: Mimi Zohar <[email protected]>
1 parent 70433f6 commit 556d971

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

security/integrity/ima/ima_modsig.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@ int ima_read_modsig(enum ima_hooks func, const void *buf, loff_t buf_len,
9191

9292
hdr->pkcs7_msg = pkcs7_parse_message(buf + buf_len, sig_len);
9393
if (IS_ERR(hdr->pkcs7_msg)) {
94+
rc = PTR_ERR(hdr->pkcs7_msg);
9495
kfree(hdr);
95-
return PTR_ERR(hdr->pkcs7_msg);
96+
return rc;
9697
}
9798

9899
memcpy(hdr->raw_pkcs7, buf + buf_len, sig_len);

0 commit comments

Comments
 (0)