|
Anton Arapov |
c2a608 |
From 8ff32018e8dd53c26d1f0daef118037fdae58c68 Mon Sep 17 00:00:00 2001
|
|
Anton Arapov |
c2a608 |
From: Jean Delvare <jdelvare@suse.de>
|
|
Anton Arapov |
c2a608 |
Date: Wed, 1 Aug 2018 09:54:45 +0200
|
|
Anton Arapov |
c2a608 |
Subject: [PATCH 19/21] dmidecode: Avoid OOB read on invalid entry point length
|
|
Anton Arapov |
c2a608 |
|
|
Anton Arapov |
c2a608 |
Don't let the entry point checksum verification run beyond the end of
|
|
Anton Arapov |
c2a608 |
the buffer holding it (32 bytes).
|
|
Anton Arapov |
c2a608 |
|
|
Anton Arapov |
c2a608 |
This bug was discovered by Lionel Debroux using the AFL fuzzer and
|
|
Anton Arapov |
c2a608 |
AddressSanitizer.
|
|
Anton Arapov |
c2a608 |
|
|
Anton Arapov |
c2a608 |
Signed-off-by: Jean Delvare <jdelvare@suse.de>
|
|
Anton Arapov |
c2a608 |
---
|
|
Anton Arapov |
c2a608 |
dmidecode.c | 18 ++++++++++++++++++
|
|
Anton Arapov |
c2a608 |
1 file changed, 18 insertions(+)
|
|
Anton Arapov |
c2a608 |
|
|
Anton Arapov |
c2a608 |
diff --git a/dmidecode.c b/dmidecode.c
|
|
Anton Arapov |
c2a608 |
index fa6ecf1..474ca7b 100644
|
|
Anton Arapov |
c2a608 |
--- a/dmidecode.c
|
|
Anton Arapov |
c2a608 |
+++ b/dmidecode.c
|
|
Anton Arapov |
c2a608 |
@@ -4928,6 +4928,15 @@ static int smbios3_decode(u8 *buf, const char *devmem, u32 flags)
|
|
Anton Arapov |
c2a608 |
u32 ver;
|
|
Anton Arapov |
c2a608 |
u64 offset;
|
|
Anton Arapov |
c2a608 |
|
|
Anton Arapov |
c2a608 |
+ /* Don't let checksum run beyond the buffer */
|
|
Anton Arapov |
c2a608 |
+ if (buf[0x06] > 0x20)
|
|
Anton Arapov |
c2a608 |
+ {
|
|
Anton Arapov |
c2a608 |
+ fprintf(stderr,
|
|
Anton Arapov |
c2a608 |
+ "Entry point length too large (%u bytes, expected %u).\n",
|
|
Anton Arapov |
c2a608 |
+ (unsigned int)buf[0x06], 0x18U);
|
|
Anton Arapov |
c2a608 |
+ return 0;
|
|
Anton Arapov |
c2a608 |
+ }
|
|
Anton Arapov |
c2a608 |
+
|
|
Anton Arapov |
c2a608 |
if (!checksum(buf, buf[0x06]))
|
|
Anton Arapov |
c2a608 |
return 0;
|
|
Anton Arapov |
c2a608 |
|
|
Anton Arapov |
c2a608 |
@@ -4966,6 +4975,15 @@ static int smbios_decode(u8 *buf, const char *devmem, u32 flags)
|
|
Anton Arapov |
c2a608 |
{
|
|
Anton Arapov |
c2a608 |
u16 ver;
|
|
Anton Arapov |
c2a608 |
|
|
Anton Arapov |
c2a608 |
+ /* Don't let checksum run beyond the buffer */
|
|
Anton Arapov |
c2a608 |
+ if (buf[0x05] > 0x20)
|
|
Anton Arapov |
c2a608 |
+ {
|
|
Anton Arapov |
c2a608 |
+ fprintf(stderr,
|
|
Anton Arapov |
c2a608 |
+ "Entry point length too large (%u bytes, expected %u).\n",
|
|
Anton Arapov |
c2a608 |
+ (unsigned int)buf[0x05], 0x1FU);
|
|
Anton Arapov |
c2a608 |
+ return 0;
|
|
Anton Arapov |
c2a608 |
+ }
|
|
Anton Arapov |
c2a608 |
+
|
|
Anton Arapov |
c2a608 |
if (!checksum(buf, buf[0x05])
|
|
Anton Arapov |
c2a608 |
|| memcmp(buf + 0x10, "_DMI_", 5) != 0
|
|
Anton Arapov |
c2a608 |
|| !checksum(buf + 0x10, 0x0F))
|
|
Anton Arapov |
c2a608 |
--
|
|
Anton Arapov |
c2a608 |
2.17.1
|
|
Anton Arapov |
c2a608 |
|