summaryrefslogtreecommitdiff
path: root/src/mainboard/lenovo
diff options
context:
space:
mode:
authorPatrick Rudolph <patrick.rudolph@9elements.com>2020-05-06 11:58:45 +0200
committerPatrick Georgi <pgeorgi@google.com>2020-08-21 07:51:07 +0000
commit9f8f11513a5db45b224f764525eae9c64fcfe360 (patch)
treebe1b5a603cc8d19e96ef0bf31037e9975c6a6c8b /src/mainboard/lenovo
parent37ac368c780568628e45c6fa93aaa55a2030c06b (diff)
downloadcoreboot-9f8f11513a5db45b224f764525eae9c64fcfe360.tar.xz
SMM: Validate more user-provided pointers
Mitigate issues presented in "Digging Into The Core of Boot" found by "Yuriy Bulygin" and "Oleksandr Bazhaniuk" at RECON-MTL-2017. Validate user-provided pointers using the newly-added functions. This protects SMM from ring0 attacks. Change-Id: I8a347ccdd20816924bf1bceb3b24bf7b22309312 Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com> Signed-off-by: Christian Walter <christian.walter@9elements.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/41086 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Diffstat (limited to 'src/mainboard/lenovo')
-rw-r--r--src/mainboard/lenovo/t60/smihandler.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/src/mainboard/lenovo/t60/smihandler.c b/src/mainboard/lenovo/t60/smihandler.c
index fe732a32b5..69ffe33209 100644
--- a/src/mainboard/lenovo/t60/smihandler.c
+++ b/src/mainboard/lenovo/t60/smihandler.c
@@ -2,6 +2,7 @@
#include <arch/io.h>
#include <device/pci_ops.h>
+#include <device/pci_def.h>
#include <console/console.h>
#include <cpu/x86/smm.h>
#include <southbridge/intel/i82801gx/nvs.h>
@@ -16,24 +17,32 @@
static void mainboard_smi_brightness_down(void)
{
- u8 *bar;
- if ((bar = (u8 *)pci_read_config32(PCI_DEV(1, 0, 0), 0x18))) {
- printk(BIOS_DEBUG, "bar: %08X, level %02X\n", (unsigned int)bar, *(bar+LVTMA_BL_MOD_LEVEL));
- *(bar+LVTMA_BL_MOD_LEVEL) &= 0xf0;
- if (*(bar+LVTMA_BL_MOD_LEVEL) > 0x10)
- *(bar+LVTMA_BL_MOD_LEVEL) -= 0x10;
- }
+ uint32_t reg32 = pci_read_config32(PCI_DEV(1, 0, 0), PCI_BASE_ADDRESS_2) & ~0xf;
+ u8 *bar = (void *)(uintptr_t)reg32;
+
+ /* Validate pointer before using it */
+ if (!bar || smm_points_to_smram(bar, LVTMA_BL_MOD_LEVEL + sizeof(uint8_t)))
+ return;
+
+ printk(BIOS_DEBUG, "bar: %p, level %02X\n", bar, *(bar+LVTMA_BL_MOD_LEVEL));
+ *(bar+LVTMA_BL_MOD_LEVEL) &= 0xf0;
+ if (*(bar+LVTMA_BL_MOD_LEVEL) > 0x10)
+ *(bar+LVTMA_BL_MOD_LEVEL) -= 0x10;
}
static void mainboard_smi_brightness_up(void)
{
- u8 *bar;
- if ((bar = (u8 *)pci_read_config32(PCI_DEV(1, 0, 0), 0x18))) {
- printk(BIOS_DEBUG, "bar: %08X, level %02X\n", (unsigned int)bar, *(bar+LVTMA_BL_MOD_LEVEL));
- *(bar+LVTMA_BL_MOD_LEVEL) |= 0x0f;
- if (*(bar+LVTMA_BL_MOD_LEVEL) < 0xf0)
- *(bar+LVTMA_BL_MOD_LEVEL) += 0x10;
- }
+ uint32_t reg32 = pci_read_config32(PCI_DEV(1, 0, 0), PCI_BASE_ADDRESS_2) & ~0xf;
+ u8 *bar = (void *)(uintptr_t)reg32;
+
+ /* Validate pointer before using it */
+ if (!bar || smm_points_to_smram(bar, LVTMA_BL_MOD_LEVEL + sizeof(uint8_t)))
+ return;
+
+ printk(BIOS_DEBUG, "bar: %p, level %02X\n", bar, *(bar+LVTMA_BL_MOD_LEVEL));
+ *(bar+LVTMA_BL_MOD_LEVEL) |= 0x0f;
+ if (*(bar+LVTMA_BL_MOD_LEVEL) < 0xf0)
+ *(bar+LVTMA_BL_MOD_LEVEL) += 0x10;
}
int mainboard_io_trap_handler(int smif)