firmware: google: memconsole: Prevent overrun attack on coreboot console
authorJulius Werner <jwerner@chromium.org>
Tue, 23 May 2017 23:48:17 +0000 (16:48 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 May 2017 13:35:19 +0000 (15:35 +0200)
commit40fbb23881291bb57e4e25e859de8e2287426dac
treea12c143da9c024b73d03908671ac4e2dfdfa364d
parentb4a338d2b3cafa1be68d4e1903203c7e08a38ee5
firmware: google: memconsole: Prevent overrun attack on coreboot console

The recent coreboot memory console update (firmware: google: memconsole:
Adapt to new coreboot ring buffer format) introduced a small security
issue in the driver: The new driver implementation parses the memory
console structure again on every access. This is intentional so that
additional lines added concurrently by runtime firmware can be read out.

However, if an attacker can write to the structure, they could increase
the size value to a point where the driver would read potentially
sensitive memory areas from outside the original console buffer during
the next access. This can be done through /dev/mem, since the console
buffer usually resides in firmware-reserved memory that is not covered
by STRICT_DEVMEM.

This patch resolves that problem by reading the buffer's size value only
once during boot (where we can still trust the structure). Other parts
of the structure can still be modified at runtime, but the driver's
bounds checks make sure that it will never read outside the buffer.

Fixes: a5061d028 ("firmware: google: memconsole: Adapt to new coreboot ring buffer format")
Signed-off-by: Julius Werner <jwerner@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/firmware/google/memconsole-coreboot.c