File seabios-mptable-Don-t-create-mptable-if-.patch of Package qemu.12301

From 9ee2e26255661a191b0ff9fa276d545ce59845c2 Mon Sep 17 00:00:00 2001
From: Kevin O'Connor <kevin@koconnor.net>
Date: Mon, 3 Aug 2015 10:16:39 -0400
Subject: [PATCH] mptable: Don't create mptable if it is very large

Very large mptable structures can fill up the space in the f-segment
and cause other important f-segment allocations to fail.  Limit the
maximum size of the mptable to prevent this.

On QEMU, with the current maximum size of 600 bytes, the mptable will
not be created in configurations of ~20 cpus or more.  The mptable is
rarely used in modern OSes so this should not be a problem.

Reported-by: Huaitong Han <huaitong.han@intel.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
[BR: bsc#954864 - patch modified to remove debug printout - size issue!]
Signed-off-by: Bruce Rogers <brogers@suse.com>
---
 src/config.h        | 2 ++
 src/fw/biostables.c | 3 +++
 2 files changed, 7 insertions(+)

diff --git a/src/config.h b/src/config.h
index 4bfebe8..6c47f16 100644
--- a/src/config.h
+++ b/src/config.h
@@ -22,6 +22,8 @@
 #define BUILD_MAX_EXTDRIVE 16
 // Number of bytes the smbios may be and still live in the f-segment
 #define BUILD_MAX_SMBIOS_FSEG     600
+// Maximum number of bytes the mptable may be and still be copied to f-segment
+#define BUILD_MAX_MPTABLE_FSEG    600
 
 #define BUILD_MODEL_ID      0xFC
 #define BUILD_SUBMODEL_ID   0x00
diff --git a/src/fw/biostables.c b/src/fw/biostables.c
index 450aca2..71a1a0d 100644
--- a/src/fw/biostables.c
+++ b/src/fw/biostables.c
@@ -54,6 +54,9 @@ copy_mptable(void *pos)
         return;
     u32 length = p->length * 16;
     u16 mpclength = ((struct mptable_config_s *)p->physaddr)->length;
+    if (length + mpclength > BUILD_MAX_MPTABLE_FSEG) {
+        return;
+    }
     // Allocate final memory location.  (In theory the config
     // structure can go in high memory, but Linux kernels before
     // v2.6.30 crash with that.)
-- 
1.9.0

openSUSE Build Service is sponsored by