ima: ima_modsig: Fix use-after-free bug in ima_read_modsig
Subsystems (4)
PATCH 1/1 ima: ima_modsig: Fix use-after-free bug in ima_read_modsig
hdr is being freed and then dereferenced by accessing hdr->pkcs7_msg
Fix this by copying the value returned by PTR_ERR(hdr->pkcs7_msg) into automatic variable err for its safe use after freeing hdr.
Addresses-Coverity-ID: 1485813 ("Read from pointer after free")
--- security/integrity/ima/ima_modsig.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
security/integrity/ima/ima_modsig.c +2 -1
@@ -91,8 +91,9 @@ int ima_read_modsig(enum ima_hooks func, const void *buf, loff_t buf_len, hdr->pkcs7_msg =pkcs7_parse_message (buf + buf_len, sig_len);if (IS_ERR (hdr->pkcs7_msg)) { +int err =PTR_ERR (hdr->pkcs7_msg);kfree (hdr); -return PTR_ERR (hdr->pkcs7_msg); +return err; }memcpy (hdr->raw_pkcs7, buf + buf_len, sig_len);
Signature · 1 line
2.22.0
Mimi Zohar
maintainerHi Gustavo,
Quoted 8 lines · Gustavo A. R. Silva
hdr is being freed and then dereferenced by accessing
hdr->pkcs7_msgFix this by copying the value returned by
PTR_ERR(hdr->pkcs7_msg)into automatic variable err for its safe use after freeing hdr.Addresses-Coverity-ID: 1485813 ("Read from pointer after free")
Fixes 39b07096364a ("ima: Implement support for module-style appended signatures")Signed-off-by Gustavo A. R. Silva <[email protected]>
This bug was reported Julia and addressed by Thiago on 8/7. If you would like to add your Review/Tested-by, the patch can be found in the linux-integrity next-queued-testing branch.
thanks,
Mimi
Gustavo A. R. Silva
Reviewed-byQuoted 8 lines · Mimi Zohar
Hi Gustavo,
Quoted 5 lines · Gustavo A. R. Silva
hdr is being freed and then dereferenced by accessing
hdr->pkcs7_msgFix this by copying the value returned by
PTR_ERR(hdr->pkcs7_msg)into automatic variable err for its safe use after freeing hdr.
Quoted 8 lines
Quoted 3 lines
Addresses-Coverity-ID: 1485813 ("Read from pointer after free")
Fixes 39b07096364a ("ima: Implement support for module-style appended signatures")Signed-off-by Gustavo A. R. Silva <[email protected]>This bug was reported Julia and addressed by Thiago on 8/7. If you would like to add your Review/Tested-by, the patch can be found in the linux-integrity next-queued-testing branch.
I'm glad this is fixed now. :)
Yeah, you can add my:
Thanks
--
Gustavo