[Skiboot] [PATCH 07/13] hdata/iohub: fix load of misaligned address for type 'long unsigned int', which requires 8 byte alignment

Stewart Smith stewart at linux.vnet.ibm.com
Wed Aug 23 17:21:17 AEST 2017


UBSan caught this:

hdata/test/../iohub.c:83:2: runtime error: load of misaligned address 0x7f1dc7b0210a for type 'long unsigned int', which requires 8 byte alignment
0x7f1dc7b0210a: note: pointer points here
 31 4c  58 08 31 00 04 01 00 30  00 42 50 46 02 00 00 78  00 00 00 00 00 00 00 00  00 00 00 00 00 00
              ^
    #0 0x41470a in io_get_lx_info hdata/test/../iohub.c:83
    #1 0x41759f in io_add_p8_cec_vpd hdata/test/../iohub.c:450
    #2 0x417d35 in io_parse_fru hdata/test/../iohub.c:538
    #3 0x41812a in io_parse hdata/test/../iohub.c:600
    #4 0x425aa2 in parse_hdat hdata/test/../spira.c:1337
    #5 0x43d9f8 in main hdata/test/hdata_to_dt.c:358
    #6 0x7f1dcb868509 in __libc_start_main (/lib64/libc.so.6+0x20509)
    #7 0x4019e9 in _start (/home/stewart/skiboot/hdata/test/hdata_to_dt+0x4019e9)

Signed-off-by: Stewart Smith <stewart at linux.vnet.ibm.com>
---
 hdata/iohub.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/hdata/iohub.c b/hdata/iohub.c
index aecb64085faf..79a6b07bf6c9 100644
--- a/hdata/iohub.c
+++ b/hdata/iohub.c
@@ -63,6 +63,7 @@ static bool io_get_lx_info(const void *kwvpd, unsigned int kwvpd_sz,
 {
 	const void *lxr;
 	char recname[5];
+	uint32_t lxrbuf[2] = { 0, 0 };
 
 	/* Find LXRn, where n is the index passed in*/
 	strcpy(recname, "LXR0");
@@ -80,16 +81,18 @@ static bool io_get_lx_info(const void *kwvpd, unsigned int kwvpd_sz,
 		return false;
 	}
 
-	prlog(PR_DEBUG, "CEC:     LXRn=%d LXR=%016lx\n", lx_idx,
-	      lxr ? *(unsigned long *)lxr : 0);
+	if (lxr)
+		memcpy(lxrbuf, lxr, sizeof(uint32_t)*2);
+
+	prlog(PR_DEBUG, "CEC:     LXRn=%d LXR=%08x%08x\n", lx_idx, lxrbuf[0], lxrbuf[1]);
 	prlog(PR_DEBUG, "CEC:     LX Info added to %llx\n", (long long)hn);
 
 	/* Add the LX info */
 	if (!dt_has_node_property(hn, "ibm,vpd-lx-info", NULL)) {
 		dt_add_property_cells(hn, "ibm,vpd-lx-info",
 				      lx_idx,
-				      ((uint32_t *)lxr)[0],
-				      ((uint32_t *)lxr)[1]);
+				      lxrbuf[0],
+				      lxrbuf[1]);
 	}
 
 	return true;
-- 
2.13.5



More information about the Skiboot mailing list