coreboot/src
Raul E Rangel eb5d76a510 smm: Add canary to end of stack and die() if a stack overflow occurs
If CPU 0's stack grows to large, it will overflow into CPU 1's stack.
If CPU 0 is handling the interrupt then CPU 1 should be in an idle loop.
When the stack overflow occurs it will override the return pointer for
CPU 1, so when CPU 0 unlocks the SMI lock, CPU 1 will attempt to return
to a random address.

This method is not foolproof. If code allocates some stack variables
that overlap with the canary, and if the variables are never set, then
the canary will not be overwritten, but it will have been skipped. We
could mitigate this by adding a larger canary value if we wanted.

I chose to use the stack bottom pointer value as the canary value
because:
* It will change per CPU stack.
* Doesn't require hard coding a value that must be shared between the
  .S and .c.
* Passing the expected canary value as a parameter felt like overkill.

We can explore adding other methods of signaling that a stack overflow
had occurred in a follow up. I limited die() to debug only because
otherwise it would be very hard to track down.

TEST=built on grunt with a small and large stack size. Then verified
that one causes a stack overflow and the other does not.

Stack overflow message:
canary 0x0 != 0xcdeafc00
SMM Handler caused a stack overflow

Change-Id: I0184de7e3bfb84e0f74e1fa6a307633541f55612
Signed-off-by: Raul E Rangel <rrangel@chromium.org>
Reviewed-on: https://review.coreboot.org/27229
Reviewed-by: Martin Roth <martinroth@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2018-06-28 09:01:02 +00:00
..
acpi
arch arm64: Reimplement mmu_disable() in assembly 2018-06-26 23:59:18 +00:00
commonlib util/cbfstool: Support FIT payloads 2018-06-15 09:13:24 +00:00
console arch/x86: Drop leftover ROMCC console support 2018-06-08 03:31:12 +00:00
cpu smm: Add canary to end of stack and die() if a stack overflow occurs 2018-06-28 09:01:02 +00:00
device src: Use of device_t is deprecated 2018-06-14 09:29:31 +00:00
drivers vboot: Fix linking error with USE_OPTION_TABLE enabled 2018-06-28 08:57:05 +00:00
ec google/chromeec: Set proper dev ops 2018-06-07 06:37:12 +00:00
include smm: Add canary to end of stack and die() if a stack overflow occurs 2018-06-28 09:01:02 +00:00
lib vboot: Fix linking error with USE_OPTION_TABLE enabled 2018-06-28 08:57:05 +00:00
mainboard mb/google/poppy/variants/nautilus: Use GPP_B20 to determine SKU 2018-06-28 08:58:30 +00:00
northbridge nb/intel/i945: Remove dead code 2018-06-23 22:25:51 +00:00
security vboot: Fix linking error with USE_OPTION_TABLE enabled 2018-06-28 08:57:05 +00:00
soc mediatek/mt8183: Remove the stub flash driver that planned to use eMMC 2018-06-28 08:59:01 +00:00
southbridge sb/intel/common/firmware: Enable me_cleaner for Nehalem 2018-06-25 08:19:16 +00:00
superio src: Use of device_t is deprecated 2018-06-14 09:29:31 +00:00
vendorcode vc/amd/00670F00: Sync AGESA.h with PI blob 2018-06-13 21:20:32 +00:00
Kconfig stage_cache: Disable when APCI S3 is not possible 2018-06-27 02:20:11 +00:00