[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20230830073122.7522-1-zhuyan2015@126.com>
Date: Wed, 30 Aug 2023 15:31:22 +0800
From: Yan Zhu <zhuyan2015@....com>
To: zohar@...ux.ibm.com
Cc: dmitry.kasatkin@...il.com, serge@...lyn.com,
linux-kernel@...r.kernel.org, Yan Zhu <zhuyan2015@....com>
Subject: [PATCH] ima: add check for khdr->buffer_size
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@....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
Powered by blists - more mailing lists