[coreboot-gerrit] Patch set updated for coreboot: util/nvramtool: Bail out on unaligned multi-byte entries

Nico Huber (nico.h@gmx.de) gerrit at coreboot.org
Fri Feb 10 12:45:33 CET 2017


Nico Huber (nico.h at gmx.de) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/18246

-gerrit

commit e5c86963b8e8a69bc66ab609dc528afed282cddf
Author: Nico Huber <nico.h at gmx.de>
Date:   Thu Jan 26 23:22:46 2017 +0100

    util/nvramtool: Bail out on unaligned multi-byte entries
    
    coreboot doesn't support CMOS options that are not byte aligned but
    span multiple bytes. So treat them as error.
    
    Change-Id: I2bcff62f153932e9c6646b4ce08e8da1c1532947
    Signed-off-by: Nico Huber <nico.h at gmx.de>
---
 util/nvramtool/accessors/layout-bin.c  | 6 ++++++
 util/nvramtool/accessors/layout-text.c | 6 ++++++
 util/nvramtool/layout.c                | 3 +++
 util/nvramtool/layout.h                | 1 +
 4 files changed, 16 insertions(+)

diff --git a/util/nvramtool/accessors/layout-bin.c b/util/nvramtool/accessors/layout-bin.c
index 34507c9..fa6344b 100644
--- a/util/nvramtool/accessors/layout-bin.c
+++ b/util/nvramtool/accessors/layout-bin.c
@@ -481,6 +481,12 @@ static void try_add_cmos_table_entry(cmos_entry_t * cmos_entry)
 		 */
 		return;
 
+	case LAYOUT_MULTIBYTE_ENTRY_NOT_ALIGNED:
+		fprintf(stderr,
+			"%s: Unaligned CMOS option table entry %s spans "
+			"multiple bytes.\n", prog_name, cmos_entry->name);
+		break;
+
 	default:
 		BUG();
 	}
diff --git a/util/nvramtool/accessors/layout-text.c b/util/nvramtool/accessors/layout-text.c
index bea3b3e..b6cbc2e 100644
--- a/util/nvramtool/accessors/layout-text.c
+++ b/util/nvramtool/accessors/layout-text.c
@@ -695,6 +695,12 @@ static void try_add_layout_file_entry(const cmos_entry_t * cmos_entry)
 		 */
 		return;
 
+	case LAYOUT_MULTIBYTE_ENTRY_NOT_ALIGNED:
+		fprintf(stderr,
+			"%s: Unaligned CMOS option table entry %s spans "
+			"multiple bytes.\n", prog_name, cmos_entry->name);
+		break;
+
 	default:
 		BUG();
 	}
diff --git a/util/nvramtool/layout.c b/util/nvramtool/layout.c
index 241dd19..6fdb282 100644
--- a/util/nvramtool/layout.c
+++ b/util/nvramtool/layout.c
@@ -169,6 +169,9 @@ int add_cmos_entry(const cmos_entry_t * e, const cmos_entry_t ** conflict)
 	if (e->length < 1)
 		return LAYOUT_ENTRY_BAD_LENGTH;
 
+	if (e->bit % 8 && e->bit / 8 != (e->bit + e->length - 1) / 8)
+		return LAYOUT_MULTIBYTE_ENTRY_NOT_ALIGNED;
+
 	if ((new_entry =
 	     (cmos_entry_item_t *) malloc(sizeof(*new_entry))) == NULL)
 		out_of_memory();
diff --git a/util/nvramtool/layout.h b/util/nvramtool/layout.h
index 8a39ab9..bde0603 100644
--- a/util/nvramtool/layout.h
+++ b/util/nvramtool/layout.h
@@ -40,6 +40,7 @@
 #define LAYOUT_CHECKSUM_OVERLAPS_SUMMED_AREA (LAYOUT_RESULT_START + 7)
 #define LAYOUT_SUMMED_AREA_OUT_OF_RANGE (LAYOUT_RESULT_START + 8)
 #define LAYOUT_CHECKSUM_LOCATION_OUT_OF_RANGE (LAYOUT_RESULT_START + 9)
+#define LAYOUT_MULTIBYTE_ENTRY_NOT_ALIGNED (LAYOUT_RESULT_START + 10)
 
 typedef enum {
 	CMOS_ENTRY_ENUM = 'e',



More information about the coreboot-gerrit mailing list