All of lore.kernel.org
 help / color / mirror / Atom feed
From: <luhuaxin1@huawei.com>
To: <linux-integrity@vger.kernel.org>
Cc: <zohar@linux.ibm.com>, <dmitry.kasatkin@gmail.com>
Subject: [PATCH v2] ima: Fix a potential integer overflow in ima_appraise_measurement
Date: Tue, 5 Jul 2022 13:14:17 +0800	[thread overview]
Message-ID: <20220705051417.2114-1-luhuaxin1@huawei.com> (raw)

From: Huaxin Lu <luhuaxin1@huawei.com>

When the ima-modsig is enabled, the rc passed to evm_verifyxattr() may be
negative, which may cause the integer overflow problem.

Signed-off-by: Huaxin Lu <luhuaxin1@huawei.com>
---
 security/integrity/ima/ima_appraise.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c
index 3fb378017f9d..956fb0f4c006 100644
--- a/security/integrity/ima/ima_appraise.c
+++ b/security/integrity/ima/ima_appraise.c
@@ -412,7 +412,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:
-- 
2.33.0


             reply	other threads:[~2022-07-05  7:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-05  5:14 luhuaxin1 [this message]
2022-07-07 21:39 ` [PATCH v2] ima: Fix a potential integer overflow in ima_appraise_measurement Mimi Zohar

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=20220705051417.2114-1-luhuaxin1@huawei.com \
    --to=luhuaxin1@huawei.com \
    --cc=dmitry.kasatkin@gmail.com \
    --cc=linux-integrity@vger.kernel.org \
    --cc=zohar@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* 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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.