[PATCH 6/8] bios: pnp: add safe memory read check on mmap'd memory region

Colin King colin.king at canonical.com
Fri Jul 14 09:52:23 UTC 2017


From: Colin Ian King <colin.king at canonical.com>

Skip unreadable mmap'd PNP memory spaces.

Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
 src/bios/pnp/pnp.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/bios/pnp/pnp.c b/src/bios/pnp/pnp.c
index ebbba34a..ca0751b1 100644
--- a/src/bios/pnp/pnp.c
+++ b/src/bios/pnp/pnp.c
@@ -94,6 +94,10 @@ static int pnp_test1(fwts_framework *fw)
 
 	for (i = 0; i < PNP_REGION_SIZE; i+= 16) {
 		pnp_header *pnp = (pnp_header*)(mem+i);
+
+		/* Skip regions that are not readable */
+		if (fwts_safe_memread(pnp, sizeof(pnp_header)) != FWTS_OK)
+			continue;
 		if ((memcmp(pnp->signature, PNP_SIGNATURE, 4) == 0) &&
 		    (fwts_checksum(mem+i, sizeof(pnp_header)) == 0)) {
 			fwts_log_info(fw, "Found PnP Installation Check structure at 0x%8.8x", PNP_REGION_START+i);
-- 
2.11.0




More information about the fwts-devel mailing list