[PATCH 07/11] igb: Avoid uninitialized advertised variable in eee_set_cur

Subsystems: intel ethernet drivers, networking drivers, the rest

STALE4498d

4 messages, 4 authors, 2013-10-02 · open the first message on its own page

[PATCH 07/11] igb: Avoid uninitialized advertised variable in eee_set_cur

From: Andi Kleen <hidden>
Date: 2013-09-30 20:31:50

From: Andi Kleen <redacted>

eee_get_cur assumes that the output data is already zeroed. It can
read-modify-write the advertised field:

              if (ipcnfg & E1000_IPCNFG_EEE_100M_AN)
2594			edata->advertised |= ADVERTISED_100baseT_Full;

This is ok for the normal ethtool eee_get call, which always
zeroes the input data before.

But eee_set_cur also calls eee_get_cur and it did not zero the input
field. Later on it then compares agsinst the field, which can contain partial
stack garbage.

Zero the input field in eee_set_cur() too.

Cc: jeffrey.t.kirsher@intel.com
Cc: netdev@vger.kernel.org
Signed-off-by: Andi Kleen <redacted>
---
 drivers/net/ethernet/intel/igb/igb_ethtool.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c
index 48cbc83..41e37ff 100644
--- a/drivers/net/ethernet/intel/igb/igb_ethtool.c
+++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c
@@ -2652,6 +2652,8 @@ static int igb_set_eee(struct net_device *netdev,
 	    (hw->phy.media_type != e1000_media_type_copper))
 		return -EOPNOTSUPP;
 
+	memset(&eee_curr, 0, sizeof(struct ethtool_eee));
+
 	ret_val = igb_get_eee(netdev, &eee_curr);
 	if (ret_val)
 		return ret_val;
-- 
1.8.3.1

RE: [PATCH 07/11] igb: Avoid uninitialized advertised variable in eee_set_cur

From: Wyborny, Carolyn <hidden>
Date: 2013-10-01 15:00:39

quoted hunk
-----Original Message-----
From: netdev-owner@vger.kernel.org [mailto:netdev-owner@vger.kernel.org]
On Behalf Of Andi Kleen
Sent: Monday, September 30, 2013 1:29 PM
To: linux-kernel@vger.kernel.org
Cc: Andi Kleen; Kirsher, Jeffrey T; netdev@vger.kernel.org
Subject: [PATCH 07/11] igb: Avoid uninitialized advertised variable in
eee_set_cur

From: Andi Kleen <redacted>

eee_get_cur assumes that the output data is already zeroed. It can read-modify-
write the advertised field:

              if (ipcnfg & E1000_IPCNFG_EEE_100M_AN)
2594			edata->advertised |= ADVERTISED_100baseT_Full;

This is ok for the normal ethtool eee_get call, which always zeroes the input
data before.

But eee_set_cur also calls eee_get_cur and it did not zero the input field. Later
on it then compares agsinst the field, which can contain partial stack garbage.

Zero the input field in eee_set_cur() too.

Cc: jeffrey.t.kirsher@intel.com
Cc: netdev@vger.kernel.org
Signed-off-by: Andi Kleen <redacted>
---
 drivers/net/ethernet/intel/igb/igb_ethtool.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c
b/drivers/net/ethernet/intel/igb/igb_ethtool.c
index 48cbc83..41e37ff 100644
--- a/drivers/net/ethernet/intel/igb/igb_ethtool.c
+++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c
@@ -2652,6 +2652,8 @@ static int igb_set_eee(struct net_device *netdev,
 	    (hw->phy.media_type != e1000_media_type_copper))
 		return -EOPNOTSUPP;

+	memset(&eee_curr, 0, sizeof(struct ethtool_eee));
+
 	ret_val = igb_get_eee(netdev, &eee_curr);
 	if (ret_val)
 		return ret_val;
--
1.8.3.1
ACK

Thanks,

Carolyn 

Re: [PATCH 07/11] igb: Avoid uninitialized advertised variable in eee_set_cur

From: Jeff Kirsher <hidden>
Date: 2013-10-01 23:10:06

On Mon, 2013-09-30 at 13:29 -0700, Andi Kleen wrote:
From: Andi Kleen <redacted>

eee_get_cur assumes that the output data is already zeroed. It can
read-modify-write the advertised field:

              if (ipcnfg & E1000_IPCNFG_EEE_100M_AN)
2594                    edata->advertised |= ADVERTISED_100baseT_Full;

This is ok for the normal ethtool eee_get call, which always
zeroes the input data before.

But eee_set_cur also calls eee_get_cur and it did not zero the input
field. Later on it then compares agsinst the field, which can contain
partial
stack garbage.

Zero the input field in eee_set_cur() too.

Cc: jeffrey.t.kirsher@intel.com
Cc: netdev@vger.kernel.org
Signed-off-by: Andi Kleen <redacted>
---
 drivers/net/ethernet/intel/igb/igb_ethtool.c | 2 ++
 1 file changed, 2 insertions(+)
Acked-by: Jeff Kirsher <redacted>

Re: [PATCH 07/11] igb: Avoid uninitialized advertised variable in eee_set_cur

From: David Miller <davem@davemloft.net>
Date: 2013-10-02 20:33:23

From: Andi Kleen <redacted>
Date: Mon, 30 Sep 2013 13:29:08 -0700
From: Andi Kleen <redacted>

eee_get_cur assumes that the output data is already zeroed. It can
read-modify-write the advertised field:

              if (ipcnfg & E1000_IPCNFG_EEE_100M_AN)
2594			edata->advertised |= ADVERTISED_100baseT_Full;

This is ok for the normal ethtool eee_get call, which always
zeroes the input data before.

But eee_set_cur also calls eee_get_cur and it did not zero the input
field. Later on it then compares agsinst the field, which can contain partial
stack garbage.

Zero the input field in eee_set_cur() too.

Cc: jeffrey.t.kirsher@intel.com
Cc: netdev@vger.kernel.org
Signed-off-by: Andi Kleen <redacted>
Applied.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help