Blame SOURCES/0015-rh1264024-platform-perm-addr.patch

ab7d06
From 09fc004d3ca14f16219ac42bc87a6b8e3050dbef Mon Sep 17 00:00:00 2001
ab7d06
From: Thomas Haller <thaller@redhat.com>
ab7d06
Date: Thu, 17 Sep 2015 18:48:45 +0200
ab7d06
Subject: [PATCH 1/2] platform: stack-allocate request data for
ab7d06
 nmp_utils_ethtool_get_permanent_address()
ab7d06
ab7d06
(cherry picked from commit 2e66aea123fb6d504ab0e447d1b7bff0ba0a785b)
ab7d06
(cherry picked from commit 6839a5f9e32dc1f7c52c51a18751242baad3659b)
ab7d06
---
ab7d06
 src/platform/nm-platform-utils.c | 19 +++++++++++--------
ab7d06
 1 file changed, 11 insertions(+), 8 deletions(-)
ab7d06
ab7d06
diff --git a/src/platform/nm-platform-utils.c b/src/platform/nm-platform-utils.c
ab7d06
index b7f0947..795e23a 100644
ab7d06
--- a/src/platform/nm-platform-utils.c
ab7d06
+++ b/src/platform/nm-platform-utils.c
ab7d06
@@ -139,21 +139,24 @@ nmp_utils_ethtool_get_permanent_address (const char *ifname,
ab7d06
                                          guint8 *buf,
ab7d06
                                          size_t *length)
ab7d06
 {
ab7d06
-	gs_free struct ethtool_perm_addr *epaddr = NULL;
ab7d06
+	struct {
ab7d06
+		struct ethtool_perm_addr e;
ab7d06
+		guint8 _extra_data[NM_UTILS_HWADDR_LEN_MAX + 1];
ab7d06
+	} edata;
ab7d06
 
ab7d06
 	if (!ifname)
ab7d06
 		return FALSE;
ab7d06
 
ab7d06
-	epaddr = g_malloc0 (sizeof (*epaddr) + NM_UTILS_HWADDR_LEN_MAX);
ab7d06
-	epaddr->cmd = ETHTOOL_GPERMADDR;
ab7d06
-	epaddr->size = NM_UTILS_HWADDR_LEN_MAX;
ab7d06
+	memset (&edata, 0, sizeof (edata));
ab7d06
+	edata.e.cmd = ETHTOOL_GPERMADDR;
ab7d06
+	edata.e.size = NM_UTILS_HWADDR_LEN_MAX;
ab7d06
 
ab7d06
-	if (!ethtool_get (ifname, epaddr))
ab7d06
+	if (!ethtool_get (ifname, &edata.e))
ab7d06
 		return FALSE;
ab7d06
 
ab7d06
-	g_assert (epaddr->size <= NM_UTILS_HWADDR_LEN_MAX);
ab7d06
-	memcpy (buf, epaddr->data, epaddr->size);
ab7d06
-	*length = epaddr->size;
ab7d06
+	g_assert (edata.e.size <= NM_UTILS_HWADDR_LEN_MAX);
ab7d06
+	memcpy (buf, edata.e.data, edata.e.size);
ab7d06
+	*length = edata.e.size;
ab7d06
 	return TRUE;
ab7d06
 }
ab7d06
 
ab7d06
-- 
ab7d06
2.4.3
ab7d06
ab7d06
ab7d06
From 9097a488c8a72ac6a935a452dd9db3df9c28232c Mon Sep 17 00:00:00 2001
ab7d06
From: Thomas Haller <thaller@redhat.com>
ab7d06
Date: Thu, 17 Sep 2015 19:53:56 +0200
ab7d06
Subject: [PATCH 2/2] platform: don't accept 00:00:00:00:00:00 as valid
ab7d06
 permanent address
ab7d06
ab7d06
In nmp_utils_ethtool_get_permanent_address(), don' accept a permanent
ab7d06
address of all zeros.
ab7d06
ab7d06
https://bugzilla.redhat.com/show_bug.cgi?id=1264024
ab7d06
(cherry picked from commit 2733aacd6495f2bdba81ddda617c9a506abd9e73)
ab7d06
(cherry picked from commit 0f18a2ed23f9b6a966738d56556c15cdd6e9e44c)
ab7d06
---
ab7d06
 src/platform/nm-platform-utils.c | 7 +++++++
ab7d06
 1 file changed, 7 insertions(+)
ab7d06
ab7d06
diff --git a/src/platform/nm-platform-utils.c b/src/platform/nm-platform-utils.c
ab7d06
index 795e23a..051a873 100644
ab7d06
--- a/src/platform/nm-platform-utils.c
ab7d06
+++ b/src/platform/nm-platform-utils.c
ab7d06
@@ -143,6 +143,7 @@ nmp_utils_ethtool_get_permanent_address (const char *ifname,
ab7d06
 		struct ethtool_perm_addr e;
ab7d06
 		guint8 _extra_data[NM_UTILS_HWADDR_LEN_MAX + 1];
ab7d06
 	} edata;
ab7d06
+	guint zeros[NM_UTILS_HWADDR_LEN_MAX] = { 0 };
ab7d06
 
ab7d06
 	if (!ifname)
ab7d06
 		return FALSE;
ab7d06
@@ -155,6 +156,12 @@ nmp_utils_ethtool_get_permanent_address (const char *ifname,
ab7d06
 		return FALSE;
ab7d06
 
ab7d06
 	g_assert (edata.e.size <= NM_UTILS_HWADDR_LEN_MAX);
ab7d06
+
ab7d06
+	/* Some drivers might return a permanent address of all zeros.
ab7d06
+	 * Reject that (rh#1264024) */
ab7d06
+	if (memcmp (edata.e.data, zeros, edata.e.size) == 0)
ab7d06
+		return FALSE;
ab7d06
+
ab7d06
 	memcpy (buf, edata.e.data, edata.e.size);
ab7d06
 	*length = edata.e.size;
ab7d06
 	return TRUE;
ab7d06
-- 
ab7d06
2.4.3
ab7d06