[PATCH 2/5] bios32: ensure mmap'd memory is readable before accessing it
Colin King
colin.king at canonical.com
Wed Jul 12 12:53:31 UTC 2017
From: Colin Ian King <colin.king at canonical.com>
We need to check we don't get SIGSEGV or SIGBUS errors when reading
the mmap'd data before we try and access it. Use the fwts_safe_memread
check on the data to sanity check these mappings.
Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
src/bios/bios32/bios32.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/bios/bios32/bios32.c b/src/bios/bios32/bios32.c
index e7f086f2..330f05e3 100644
--- a/src/bios/bios32/bios32.c
+++ b/src/bios/bios32/bios32.c
@@ -65,6 +65,11 @@ static int bios32_test1(fwts_framework *fw)
}
for (i = 0; i < BIOS32_SD_REGION_SIZE; i+= 16) {
+ const size_t size = sizeof(fwts_bios32_service_directory);
+
+ /* Is the region safe to read? */
+ if (fwts_safe_memread(mem, size) != FWTS_OK)
+ continue;
if ((*(mem+i) == '_') &&
(*(mem+i+1) == '3') &&
(*(mem+i+2) == '2') &&
--
2.11.0
More information about the fwts-devel
mailing list