ima: Fix a use after free in ima_read_modsig()
Subsystems (5)
PATCH 1/1 ima: Fix a use after free in ima_read_modsig()
This code frees "hdr" and then dereferences it on the next line to get the error code.
--- 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)) { + rc =PTR_ERR (hdr->pkcs7_msg);kfree (hdr); -return PTR_ERR (hdr->pkcs7_msg); +return rc; }memcpy (hdr->raw_pkcs7, buf + buf_len, sig_len);
Signature · 1 line
2.20.1
Quoted 5 lines · Dan Carpenter
This code frees "hdr" and then dereferences it on the next line to get the error code.
Fixes 39b07096364a ("ima: Implement support for module-style appended signatures")Signed-off-by Dan Carpenter <[email protected]>
Thanks, Dan. Julia already reported this. Thiago posted a patch last night. Just getting to it now. Can I add your Reviewed-by or Tested- by?
Mimi
Quoted 10 lines · Mimi Zohar
Quoted 5 lines · Dan Carpenter
This code frees "hdr" and then dereferences it on the next line to get the error code.
Fixes 39b07096364a ("ima: Implement support for module-style appended signatures")Signed-off-by Dan Carpenter <[email protected]>Thanks, Dan. Julia already reported this. Thiago posted a patch last night. Just getting to it now. Can I add your Reviewed-by or Tested- by?
I haven't seen the other patch so Reviewed-by seems like the wrong thing. I don't really need any sort of credit. I'm just going through my backlog of warnings from being out of office. Perhaps Reported-by?
regards,
dan carpenter
Quoted 8 lines · Dan Carpenter
Quoted 7 lines · Mimi Zohar
Quoted 5 lines · Dan Carpenter
This code frees "hdr" and then dereferences it on the next line to get the error code.
Fixes 39b07096364a ("ima: Implement support for module-style appended signatures")Signed-off-by Dan Carpenter <[email protected]>
Quoted 7 lines
Quoted 3 lines
Thanks, Dan. Julia already reported this. Thiago posted a patch last night. Just getting to it now. Can I add your Reviewed-by or Tested- by?
I haven't seen the other patch so Reviewed-by seems like the wrong thing. I don't really need any sort of credit. I'm just going through my backlog of warnings from being out of office. Perhaps Reported-by?
That works. FYI, your solution and Thiago's are exactly the same.[1]
Mimi
[1] https://lore.kernel.org/linux-integrity/[email protected]/T/#u