mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yan Zhu <zhuyan2015@126.com>
To: zohar@linux.ibm.com
Cc: dmitry.kasatkin@gmail.com, serge@hallyn.com,
	linux-kernel@vger.kernel.org, Yan Zhu <zhuyan2015@126.com>
Subject: [PATCH] ima: add check for khdr->buffer_size
Date: Wed, 30 Aug 2023 15:31:22 +0800	[thread overview]
Message-ID: <20230830073122.7522-1-zhuyan2015@126.com> (raw)

When khdr->buffer_size > size, continuing to use ima_parse_buf
may cause memory access out of bounds.

Fixes: 94c3aac567a9 ("ima: on soft reboot, restore the measurement list")

Signed-off-by: Yan Zhu <zhuyan2015@126.com>
---
 security/integrity/ima/ima_template.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/security/integrity/ima/ima_template.c b/security/integrity/ima/ima_template.c
index e5d941f48..02a38b2ee 100644
--- a/security/integrity/ima/ima_template.c
+++ b/security/integrity/ima/ima_template.c
@@ -399,6 +399,12 @@ int ima_restore_measurement_list(loff_t size, void *buf)
 		return -EINVAL;
 	}
 
+	if (khdr->buffer_size > (u64)size) {
+		pr_err("hkdr->buffer_size(%llu) is larger then size(%lld)", khdr->buffer_size,
+			size);
+		return -EINVAL;
+	}
+
 	bitmap_zero(hdr_mask, HDR__LAST);
 	bitmap_set(hdr_mask, HDR_PCR, 1);
 	bitmap_set(hdr_mask, HDR_DIGEST, 1);
-- 
2.33.0


             reply	other threads:[~2023-09-04 19:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-30  7:31 Yan Zhu [this message]
     [not found] <639b3953.170a0220.35d95.65e9@mx.google.com>
2022-12-15 15:20 ` 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=20230830073122.7522-1-zhuyan2015@126.com \
    --to=zhuyan2015@126.com \
    --cc=dmitry.kasatkin@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=serge@hallyn.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®