archive mirror
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <>
To: Mimi Zohar <>,
	Dmitry Kasatkin <>,
	James Morris <>,
	"Serge E. Hallyn" <>,
	Thiago Jung Bauermann <>
	"Gustavo A. R. Silva" <>
Subject: [PATCH][next] ima: ima_modsig: Fix use-after-free bug in ima_read_modsig
Date: Sun, 11 Aug 2019 18:55:07 -0500	[thread overview]
Message-ID: <20190811235507.GA9587@embeddedor> (raw)

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")
Fixes: 39b07096364a ("ima: Implement support for module-style appended signatures")
Signed-off-by: Gustavo A. R. Silva <>
 security/integrity/ima/ima_modsig.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/security/integrity/ima/ima_modsig.c b/security/integrity/ima/ima_modsig.c
index c412e31d1714..e681d4326145 100644
--- a/security/integrity/ima/ima_modsig.c
+++ b/security/integrity/ima/ima_modsig.c
@@ -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);
-		return PTR_ERR(hdr->pkcs7_msg);
+		return err;
 	memcpy(hdr->raw_pkcs7, buf + buf_len, sig_len);

             reply	other threads:[~2019-08-12  0:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-11 23:55 Gustavo A. R. Silva [this message]
2019-08-28 13:50 ` [PATCH][next] ima: ima_modsig: Fix use-after-free bug in ima_read_modsig Mimi Zohar
2019-08-28 18:55   ` Gustavo A. R. Silva

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190811235507.GA9587@embeddedor \ \ \ \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).