2012-02-24 16:01:57

by Danny Kukawka

[permalink] [raw]
Subject: [PATCH 00/12] Part 2: check given MAC address, if invalid return -EADDRNOTAVAIL

Second Part of series patches to unifiy the return value of
.ndo_set_mac_address if the given address isn't valid.

These changes check if a given (MAC) address is valid in
.ndo_set_mac_address, if invalid return -EADDRNOTAVAIL
as eth_mac_addr() already does if is_valid_ether_addr() fails.

These patches are against net-next.

Danny Kukawka (12):
ethernet: .ndo_set_mac_address: check given address, if invalid
return -EADDRNOTAVAIL
cris/eth_v10: check given MAC address, if invalid return
-EADDRNOTAVAIL
dvb_net: check given MAC address, if invalid return -EADDRNOTAVAIL
fddi/skfp: check given MAC address, if invalid return -EADDRNOTAVAIL
team: check given MAC address, if invalid return -EADDRNOTAVAIL
tokenring: check given MAC address, if invalid return -EADDRNOTAVAIL
usb/rtl8150: check given MAC address, if invalid return
-EADDRNOTAVAIL
vmxnet3: check given MAC address, if invalid return -EADDRNOTAVAIL
wan/lapbether: check given MAC address, if invalid return
-EADDRNOTAVAIL
wireless: check given MAC address, if invalid return -EADDRNOTAVAIL
s390/net/qeth_l2_main: check given MAC address, if invalid return
-EADDRNOTAVAIL
rose: check given MAC address, if invalid return -EADDRNOTAVAIL

drivers/media/dvb/dvb-core/dvb_net.c | 5 ++++-
drivers/net/cris/eth_v10.c | 3 +++
drivers/net/ethernet/amd/amd8111e.c | 3 +++
drivers/net/ethernet/amd/atarilance.c | 3 +++
drivers/net/ethernet/chelsio/cxgb/cxgb2.c | 3 +++
drivers/net/ethernet/cisco/enic/enic_main.c | 3 +++
drivers/net/ethernet/freescale/fec_mpc52xx.c | 3 +++
drivers/net/ethernet/jme.c | 3 +++
drivers/net/ethernet/micrel/ks8851_mll.c | 3 +++
drivers/net/ethernet/micrel/ksz884x.c | 3 +++
drivers/net/ethernet/seeq/sgiseeq.c | 3 +++
drivers/net/ethernet/sgi/ioc3-eth.c | 3 +++
drivers/net/ethernet/tehuti/tehuti.c | 3 +++
drivers/net/fddi/skfp/skfddi.c | 3 +++
drivers/net/team/team.c | 3 +++
drivers/net/tokenring/3c359.c | 4 ++++
drivers/net/tokenring/lanstreamer.c | 4 ++++
drivers/net/tokenring/olympic.c | 4 ++++
drivers/net/tokenring/tms380tr.c | 3 +++
drivers/net/usb/rtl8150.c | 3 +++
drivers/net/vmxnet3/vmxnet3_drv.c | 3 +++
drivers/net/wan/lapbether.c | 5 +++++
drivers/net/wireless/airo.c | 3 +++
drivers/net/wireless/atmel.c | 3 +++
.../net/wireless/brcm80211/brcmfmac/dhd_linux.c | 5 ++++-
drivers/net/wireless/hostap/hostap_main.c | 3 +++
drivers/net/wireless/libertas/main.c | 3 +++
drivers/net/wireless/mwifiex/main.c | 3 +++
drivers/net/wireless/zd1201.c | 2 ++
drivers/s390/net/qeth_l2_main.c | 3 +++
net/rose/rose_dev.c | 3 +++
31 files changed, 99 insertions(+), 2 deletions(-)

--
1.7.8.3


2012-02-24 16:01:38

by Danny Kukawka

[permalink] [raw]
Subject: [PATCH 02/12] cris/eth_v10: check given MAC address, if invalid return -EADDRNOTAVAIL

Check if given address is valid in .ndo_set_mac_address, if
invalid return -EADDRNOTAVAIL as eth_mac_addr() already does
if is_valid_ether_addr() fails.

Signed-off-by: Danny Kukawka <[email protected]>
---
drivers/net/cris/eth_v10.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/net/cris/eth_v10.c b/drivers/net/cris/eth_v10.c
index 7cb2785..e450d8a 100644
--- a/drivers/net/cris/eth_v10.c
+++ b/drivers/net/cris/eth_v10.c
@@ -424,6 +424,9 @@ e100_set_mac_address(struct net_device *dev, void *p)
struct net_local *np = netdev_priv(dev);
struct sockaddr *addr = p;

+ if (!is_valid_ether_addr(addr->sa_data))
+ return -EADDRNOTAVAIL;
+
spin_lock(&np->lock); /* preemption protection */

/* remember it */
--
1.7.8.3

2012-02-24 16:01:43

by Danny Kukawka

[permalink] [raw]
Subject: [PATCH 09/12] wan/lapbether: check given MAC address, if invalid return -EADDRNOTAVAIL

Check if given address is valid in .ndo_set_mac_address/
lapbeth_set_mac_address(), if invalid return -EADDRNOTAVAIL as
eth_mac_addr() already does if is_valid_ether_addr() fails.

Signed-off-by: Danny Kukawka <[email protected]>
---
drivers/net/wan/lapbether.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c
index 7beeb9b..b6d4cbc 100644
--- a/drivers/net/wan/lapbether.c
+++ b/drivers/net/wan/lapbether.c
@@ -45,6 +45,7 @@
#include <linux/module.h>
#include <linux/lapb.h>
#include <linux/init.h>
+#include <linux/etherdevice.h>

#include <net/x25device.h>

@@ -254,6 +255,10 @@ static void lapbeth_disconnected(struct net_device *dev, int reason)
static int lapbeth_set_mac_address(struct net_device *dev, void *addr)
{
struct sockaddr *sa = addr;
+
+ if (!is_valid_ether_addr(sa->sa_data))
+ return -EADDRNOTAVAIL;
+
memcpy(dev->dev_addr, sa->sa_data, dev->addr_len);
return 0;
}
--
1.7.8.3

2012-02-24 16:01:41

by Danny Kukawka

[permalink] [raw]
Subject: [PATCH 06/12] tokenring: check given MAC address, if invalid return -EADDRNOTAVAIL

Check if given address is valid in .ndo_set_mac_address, if
invalid return -EADDRNOTAVAIL as eth_mac_addr() already does
if is_valid_ether_addr() fails.

Signed-off-by: Danny Kukawka <[email protected]>
---
drivers/net/tokenring/3c359.c | 4 ++++
drivers/net/tokenring/lanstreamer.c | 4 ++++
drivers/net/tokenring/olympic.c | 4 ++++
drivers/net/tokenring/tms380tr.c | 3 +++
4 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/drivers/net/tokenring/3c359.c b/drivers/net/tokenring/3c359.c
index d7c292a..3b7034f 100644
--- a/drivers/net/tokenring/3c359.c
+++ b/drivers/net/tokenring/3c359.c
@@ -56,6 +56,7 @@
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
#include <linux/trdevice.h>
#include <linux/stddef.h>
#include <linux/init.h>
@@ -1498,6 +1499,9 @@ static int xl_set_mac_address (struct net_device *dev, void *addr)
struct sockaddr *saddr = addr ;
struct xl_private *xl_priv = netdev_priv(dev);

+ if (!is_valid_ether_addr(saddr->sa_data))
+ return -EADDRNOTAVAIL;
+
if (netif_running(dev)) {
printk(KERN_WARNING "%s: Cannot set mac/laa address while card is open\n", dev->name) ;
return -EIO ;
diff --git a/drivers/net/tokenring/lanstreamer.c b/drivers/net/tokenring/lanstreamer.c
index 8d71e0d..bec9290 100644
--- a/drivers/net/tokenring/lanstreamer.c
+++ b/drivers/net/tokenring/lanstreamer.c
@@ -113,6 +113,7 @@
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
#include <linux/trdevice.h>
#include <linux/stddef.h>
#include <linux/init.h>
@@ -1488,6 +1489,9 @@ static int streamer_set_mac_address(struct net_device *dev, void *addr)
struct sockaddr *saddr = addr;
struct streamer_private *streamer_priv = netdev_priv(dev);

+ if (!is_valid_ether_addr(saddr->sa_data))
+ return -EADDRNOTAVAIL;
+
if (netif_running(dev))
{
printk(KERN_WARNING "%s: Cannot set mac/laa address while card is open\n", dev->name);
diff --git a/drivers/net/tokenring/olympic.c b/drivers/net/tokenring/olympic.c
index fd8dce9..f41eb41 100644
--- a/drivers/net/tokenring/olympic.c
+++ b/drivers/net/tokenring/olympic.c
@@ -94,6 +94,7 @@
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
#include <linux/trdevice.h>
#include <linux/stddef.h>
#include <linux/init.h>
@@ -1351,6 +1352,9 @@ static int olympic_set_mac_address (struct net_device *dev, void *addr)
struct sockaddr *saddr = addr ;
struct olympic_private *olympic_priv = netdev_priv(dev);

+ if (!is_valid_ether_addr(saddr->sa_data))
+ return -EADDRNOTAVAIL;
+
if (netif_running(dev)) {
printk(KERN_WARNING "%s: Cannot set mac/laa address while card is open\n", dev->name) ;
return -EIO ;
diff --git a/drivers/net/tokenring/tms380tr.c b/drivers/net/tokenring/tms380tr.c
index 102f896..3880315 100644
--- a/drivers/net/tokenring/tms380tr.c
+++ b/drivers/net/tokenring/tms380tr.c
@@ -2203,6 +2203,9 @@ static int tms380tr_set_mac_address(struct net_device *dev, void *addr)
{
struct net_local *tp = netdev_priv(dev);
struct sockaddr *saddr = addr;
+
+ if (!is_valid_ether_addr(saddr->sa_data))
+ return -EADDRNOTAVAIL;

if (tp->AdapterOpenFlag || tp->AdapterVirtOpenFlag) {
printk(KERN_WARNING "%s: Cannot set MAC/LAA address while card is open\n", dev->name);
--
1.7.8.3

2012-02-24 16:02:45

by Danny Kukawka

[permalink] [raw]
Subject: [PATCH 11/12] s390/net/qeth_l2_main: check given MAC address, if invalid return -EADDRNOTAVAIL


Check if given address is valid in .ndo_set_mac_address/
qeth_l2_set_mac_address(), if invalid return -EADDRNOTAVAIL as
eth_mac_addr() already does if is_valid_ether_addr() fails.

Signed-off-by: Danny Kukawka <[email protected]>
---
drivers/s390/net/qeth_l2_main.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
index e5c9cf1..d10b3a4 100644
--- a/drivers/s390/net/qeth_l2_main.c
+++ b/drivers/s390/net/qeth_l2_main.c
@@ -661,6 +661,9 @@ static int qeth_l2_set_mac_address(struct net_device *dev, void *p)
struct qeth_card *card = dev->ml_priv;
int rc = 0;

+ if (!is_valid_ether_addr(addr->sa_data))
+ return -EADDRNOTAVAIL;
+
QETH_CARD_TEXT(card, 3, "setmac");

if (qeth_l2_verify_dev(dev) != QETH_REAL_CARD) {
--
1.7.8.3

2012-02-24 16:03:00

by Danny Kukawka

[permalink] [raw]
Subject: [PATCH 01/12] ethernet: .ndo_set_mac_address: check given address, if invalid return -EADDRNOTAVAIL

Check if given address is valid in .ndo_set_mac_address, if
invalid return -EADDRNOTAVAIL as eth_mac_addr() already does
if is_valid_ether_addr() fails.

Signed-off-by: Danny Kukawka <[email protected]>
---
drivers/net/ethernet/amd/amd8111e.c | 3 +++
drivers/net/ethernet/amd/atarilance.c | 3 +++
drivers/net/ethernet/chelsio/cxgb/cxgb2.c | 3 +++
drivers/net/ethernet/cisco/enic/enic_main.c | 3 +++
drivers/net/ethernet/freescale/fec_mpc52xx.c | 3 +++
drivers/net/ethernet/jme.c | 3 +++
drivers/net/ethernet/micrel/ks8851_mll.c | 3 +++
drivers/net/ethernet/micrel/ksz884x.c | 3 +++
drivers/net/ethernet/seeq/sgiseeq.c | 3 +++
drivers/net/ethernet/sgi/ioc3-eth.c | 3 +++
drivers/net/ethernet/tehuti/tehuti.c | 3 +++
11 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/drivers/net/ethernet/amd/amd8111e.c b/drivers/net/ethernet/amd/amd8111e.c
index 9f62504..b0e3603 100644
--- a/drivers/net/ethernet/amd/amd8111e.c
+++ b/drivers/net/ethernet/amd/amd8111e.c
@@ -1549,6 +1549,9 @@ static int amd8111e_set_mac_address(struct net_device *dev, void *p)
int i;
struct sockaddr *addr = p;

+ if (!is_valid_ether_addr(addr->sa_data))
+ return -EADDRNOTAVAIL;
+
memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
spin_lock_irq(&lp->lock);
/* Setting the MAC address to the device */
diff --git a/drivers/net/ethernet/amd/atarilance.c b/drivers/net/ethernet/amd/atarilance.c
index 70ed79c..a9612f7 100644
--- a/drivers/net/ethernet/amd/atarilance.c
+++ b/drivers/net/ethernet/amd/atarilance.c
@@ -1125,6 +1125,9 @@ static int lance_set_mac_address( struct net_device *dev, void *addr )
struct sockaddr *saddr = addr;
int i;

+ if (!is_valid_ether_addr(saddr->sa_data))
+ return -EADDRNOTAVAIL;
+
if (lp->cardtype != OLD_RIEBL && lp->cardtype != NEW_RIEBL)
return -EOPNOTSUPP;

diff --git a/drivers/net/ethernet/chelsio/cxgb/cxgb2.c b/drivers/net/ethernet/chelsio/cxgb/cxgb2.c
index 1d17c92..8e363ce 100644
--- a/drivers/net/ethernet/chelsio/cxgb/cxgb2.c
+++ b/drivers/net/ethernet/chelsio/cxgb/cxgb2.c
@@ -841,6 +841,9 @@ static int t1_set_mac_addr(struct net_device *dev, void *p)
struct cmac *mac = adapter->port[dev->if_port].mac;
struct sockaddr *addr = p;

+ if (!is_valid_ether_addr(addr->sa_data))
+ return -EADDRNOTAVAIL;
+
if (!mac->ops->macaddress_set)
return -EOPNOTSUPP;

diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
index e27ec1d..67a340d 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -903,6 +903,9 @@ static int enic_set_mac_address(struct net_device *netdev, void *p)
struct enic *enic = netdev_priv(netdev);
int err;

+ if (!is_valid_ether_addr(saddr->sa_data))
+ return -EADDRNOTAVAIL;
+
err = enic_dev_del_station_addr(enic);
if (err)
return err;
diff --git a/drivers/net/ethernet/freescale/fec_mpc52xx.c b/drivers/net/ethernet/freescale/fec_mpc52xx.c
index 7b34d8c..26ea3ad 100644
--- a/drivers/net/ethernet/freescale/fec_mpc52xx.c
+++ b/drivers/net/ethernet/freescale/fec_mpc52xx.c
@@ -123,6 +123,9 @@ static int mpc52xx_fec_set_mac_address(struct net_device *dev, void *addr)
{
struct sockaddr *sock = addr;

+ if (!is_valid_ether_addr(sock->sa_data))
+ return -EADDRNOTAVAIL;
+
memcpy(dev->dev_addr, sock->sa_data, dev->addr_len);

mpc52xx_fec_set_paddr(dev, sock->sa_data);
diff --git a/drivers/net/ethernet/jme.c b/drivers/net/ethernet/jme.c
index 1b86d0b..117598e 100644
--- a/drivers/net/ethernet/jme.c
+++ b/drivers/net/ethernet/jme.c
@@ -2271,6 +2271,9 @@ jme_set_macaddr(struct net_device *netdev, void *p)
struct jme_adapter *jme = netdev_priv(netdev);
struct sockaddr *addr = p;

+ if (!is_valid_ether_addr(addr->sa_data))
+ return -EADDRNOTAVAIL;
+
if (netif_running(netdev))
return -EBUSY;

diff --git a/drivers/net/ethernet/micrel/ks8851_mll.c b/drivers/net/ethernet/micrel/ks8851_mll.c
index 10d5798..82430ff 100644
--- a/drivers/net/ethernet/micrel/ks8851_mll.c
+++ b/drivers/net/ethernet/micrel/ks8851_mll.c
@@ -1239,6 +1239,9 @@ static int ks_set_mac_address(struct net_device *netdev, void *paddr)
struct sockaddr *addr = paddr;
u8 *da;

+ if (!is_valid_ether_addr(addr->sa_data))
+ return -EADDRNOTAVAIL;
+
netdev->addr_assign_type &= ~NET_ADDR_RANDOM;
memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);

diff --git a/drivers/net/ethernet/micrel/ksz884x.c b/drivers/net/ethernet/micrel/ksz884x.c
index ef723b1..db29407 100644
--- a/drivers/net/ethernet/micrel/ksz884x.c
+++ b/drivers/net/ethernet/micrel/ksz884x.c
@@ -5668,6 +5668,9 @@ static int netdev_set_mac_address(struct net_device *dev, void *addr)
struct sockaddr *mac = addr;
uint interrupt;

+ if (!is_valid_ether_addr(mac->sa_data))
+ return -EADDRNOTAVAIL;
+
if (priv->port.first_port > 0)
hw_del_addr(hw, dev->dev_addr);
else {
diff --git a/drivers/net/ethernet/seeq/sgiseeq.c b/drivers/net/ethernet/seeq/sgiseeq.c
index bb8c822..41ad6ba 100644
--- a/drivers/net/ethernet/seeq/sgiseeq.c
+++ b/drivers/net/ethernet/seeq/sgiseeq.c
@@ -163,6 +163,9 @@ static int sgiseeq_set_mac_address(struct net_device *dev, void *addr)
struct sgiseeq_private *sp = netdev_priv(dev);
struct sockaddr *sa = addr;

+ if (!is_valid_ether_addr(sa->sa_data))
+ return -EADDRNOTAVAIL;
+
memcpy(dev->dev_addr, sa->sa_data, dev->addr_len);

spin_lock_irq(&sp->tx_lock);
diff --git a/drivers/net/ethernet/sgi/ioc3-eth.c b/drivers/net/ethernet/sgi/ioc3-eth.c
index ac149d9..a069546 100644
--- a/drivers/net/ethernet/sgi/ioc3-eth.c
+++ b/drivers/net/ethernet/sgi/ioc3-eth.c
@@ -458,6 +458,9 @@ static int ioc3_set_mac_address(struct net_device *dev, void *addr)
struct ioc3_private *ip = netdev_priv(dev);
struct sockaddr *sa = addr;

+ if (!is_valid_ether_addr(sa->sa_data))
+ return -EADDRNOTAVAIL;
+
memcpy(dev->dev_addr, sa->sa_data, dev->addr_len);

spin_lock_irq(&ip->ioc3_lock);
diff --git a/drivers/net/ethernet/tehuti/tehuti.c b/drivers/net/ethernet/tehuti/tehuti.c
index ad973ff..30822ac 100644
--- a/drivers/net/ethernet/tehuti/tehuti.c
+++ b/drivers/net/ethernet/tehuti/tehuti.c
@@ -837,6 +837,9 @@ static int bdx_set_mac(struct net_device *ndev, void *p)
struct sockaddr *addr = p;

ENTER;
+
+ if (!is_valid_ether_addr(addr->sa_data))
+ return -EADDRNOTAVAIL;
/*
if (netif_running(dev))
return -EBUSY
--
1.7.8.3

2012-02-24 16:03:40

by Danny Kukawka

[permalink] [raw]
Subject: [PATCH 03/12] dvb_net: check given MAC address, if invalid return -EADDRNOTAVAIL

Check if given address is valid in .ndo_set_mac_address, if
invalid return -EADDRNOTAVAIL as eth_mac_addr() already does
if is_valid_ether_addr() fails.

Signed-off-by: Danny Kukawka <[email protected]>
---
drivers/media/dvb/dvb-core/dvb_net.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c
index 8766ce8..ebae67e 100644
--- a/drivers/media/dvb/dvb-core/dvb_net.c
+++ b/drivers/media/dvb/dvb-core/dvb_net.c
@@ -1190,7 +1190,10 @@ static void wq_restart_net_feed (struct work_struct *work)
static int dvb_net_set_mac (struct net_device *dev, void *p)
{
struct dvb_net_priv *priv = netdev_priv(dev);
- struct sockaddr *addr=p;
+ struct sockaddr *addr = p;
+
+ if (!is_valid_ether_addr(addr->sa_data))
+ return -EADDRNOTAVAIL;

memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);

--
1.7.8.3

2012-02-24 16:03:38

by Danny Kukawka

[permalink] [raw]
Subject: [PATCH 07/12] usb/rtl8150: check given MAC address, if invalid return -EADDRNOTAVAIL

Check if given address is valid in .ndo_set_mac_address/
rtl8150_set_mac_address(), if invalid return -EADDRNOTAVAIL as
eth_mac_addr() already does if is_valid_ether_addr() fails.

Signed-off-by: Danny Kukawka <[email protected]>
---
drivers/net/usb/rtl8150.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c
index 6dda2fe..aa539be 100644
--- a/drivers/net/usb/rtl8150.c
+++ b/drivers/net/usb/rtl8150.c
@@ -299,6 +299,9 @@ static int rtl8150_set_mac_address(struct net_device *netdev, void *p)
if (netif_running(netdev))
return -EBUSY;

+ if (!is_valid_ether_addr(addr->sa_data))
+ return -EADDRNOTAVAIL;
+
memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
dbg("%s: Setting MAC address to %pM\n", netdev->name, netdev->dev_addr);
/* Set the IDR registers. */
--
1.7.8.3

2012-02-24 16:04:15

by Danny Kukawka

[permalink] [raw]
Subject: [PATCH 12/12] rose: check given MAC address, if invalid return -EADDRNOTAVAIL

Check if given address is valid in .ndo_set_mac_address/
rose_set_mac_address(), if invalid return -EADDRNOTAVAIL as
eth_mac_addr() already does if is_valid_ether_addr() fails.

Signed-off-by: Danny Kukawka <[email protected]>
---
net/rose/rose_dev.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/net/rose/rose_dev.c b/net/rose/rose_dev.c
index 178ff4f..1ae8791 100644
--- a/net/rose/rose_dev.c
+++ b/net/rose/rose_dev.c
@@ -96,6 +96,9 @@ static int rose_set_mac_address(struct net_device *dev, void *addr)
struct sockaddr *sa = addr;
int err;

+ if (!is_valid_ether_addr(sa->sa_data))
+ return -EADDRNOTAVAIL;
+
if (!memcpy(dev->dev_addr, sa->sa_data, dev->addr_len))
return 0;

--
1.7.8.3

2012-02-24 16:04:07

by Danny Kukawka

[permalink] [raw]
Subject: [PATCH 10/12] wireless: check given MAC address, if invalid return -EADDRNOTAVAIL

Check if given address is valid in .ndo_set_mac_address, if
invalid return -EADDRNOTAVAIL as eth_mac_addr() already does
if is_valid_ether_addr() fails.

Signed-off-by: Danny Kukawka <[email protected]>
---
drivers/net/wireless/airo.c | 3 +++
drivers/net/wireless/atmel.c | 3 +++
.../net/wireless/brcm80211/brcmfmac/dhd_linux.c | 5 ++++-
drivers/net/wireless/hostap/hostap_main.c | 3 +++
drivers/net/wireless/libertas/main.c | 3 +++
drivers/net/wireless/mwifiex/main.c | 3 +++
drivers/net/wireless/zd1201.c | 2 ++
7 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 1c008c6..a205332 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -2320,6 +2320,9 @@ static int airo_set_mac_address(struct net_device *dev, void *p)
struct airo_info *ai = dev->ml_priv;
struct sockaddr *addr = p;

+ if (!is_valid_ether_addr(addr->sa_data))
+ return -EADDRNOTAVAIL;
+
readConfigRid(ai, 1);
memcpy (ai->config.macAddr, addr->sa_data, dev->addr_len);
set_bit (FLAG_COMMIT, &ai->flags);
diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c
index 3010cee..1abeb0e 100644
--- a/drivers/net/wireless/atmel.c
+++ b/drivers/net/wireless/atmel.c
@@ -1309,6 +1309,9 @@ static int atmel_set_mac_address(struct net_device *dev, void *p)
{
struct sockaddr *addr = p;

+ if (!is_valid_ether_addr(addr->sa_data))
+ return -EADDRNOTAVAIL;
+
memcpy (dev->dev_addr, addr->sa_data, dev->addr_len);
return atmel_open(dev);
}
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c
index db2df1f..d192758 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c
@@ -257,7 +257,10 @@ static int brcmf_netdev_set_mac_address(struct net_device *ndev, void *addr)
{
struct brcmf_if *ifp = netdev_priv(ndev);
struct brcmf_pub *drvr = ifp->drvr;
- struct sockaddr *sa = (struct sockaddr *)addr;
+ struct sockaddr *sa = addr;
+
+ if (!is_valid_ether_addr(sa->sa_data))
+ return -EADDRNOTAVAIL;

memcpy(&drvr->macvalue, sa->sa_data, ETH_ALEN);
schedule_work(&drvr->setmacaddr_work);
diff --git a/drivers/net/wireless/hostap/hostap_main.c b/drivers/net/wireless/hostap/hostap_main.c
index bfa0d54..0c475d3 100644
--- a/drivers/net/wireless/hostap/hostap_main.c
+++ b/drivers/net/wireless/hostap/hostap_main.c
@@ -713,6 +713,9 @@ static int prism2_set_mac_address(struct net_device *dev, void *p)
iface = netdev_priv(dev);
local = iface->local;

+ if (!is_valid_ether_addr(addr->sa_data))
+ return -EADDRNOTAVAIL;
+
if (local->func->set_rid(dev, HFA384X_RID_CNFOWNMACADDR, addr->sa_data,
ETH_ALEN) < 0 || local->func->reset_port(dev))
return -EINVAL;
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index 957681d..33bf268 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -297,6 +297,9 @@ int lbs_set_mac_address(struct net_device *dev, void *addr)

lbs_deb_enter(LBS_DEB_NET);

+ if (!is_valid_ether_addr(phwaddr->sa_data))
+ return -EADDRNOTAVAIL;
+
/*
* Can only set MAC address when all interfaces are down, to be written
* to the hardware when one of them is brought up.
diff --git a/drivers/net/wireless/mwifiex/main.c b/drivers/net/wireless/mwifiex/main.c
index 790a379..7b43109 100644
--- a/drivers/net/wireless/mwifiex/main.c
+++ b/drivers/net/wireless/mwifiex/main.c
@@ -485,6 +485,9 @@ mwifiex_set_mac_address(struct net_device *dev, void *addr)
struct sockaddr *hw_addr = addr;
int ret;

+ if (!is_valid_ether_addr(hw_addr->sa_data))
+ return -EADDRNOTAVAIL;
+
memcpy(priv->curr_addr, hw_addr->sa_data, ETH_ALEN);

/* Send request to firmware */
diff --git a/drivers/net/wireless/zd1201.c b/drivers/net/wireless/zd1201.c
index a66b93b..60bc0ea 100644
--- a/drivers/net/wireless/zd1201.c
+++ b/drivers/net/wireless/zd1201.c
@@ -853,6 +853,8 @@ static int zd1201_set_mac_address(struct net_device *dev, void *p)

if (!zd)
return -ENODEV;
+ if (!is_valid_ether_addr(addr->sa_data))
+ return -EADDRNOTAVAIL;

err = zd1201_setconfig(zd, ZD1201_RID_CNFOWNMACADDR,
addr->sa_data, dev->addr_len, 1);
--
1.7.8.3

2012-02-24 16:04:50

by Danny Kukawka

[permalink] [raw]
Subject: [PATCH 04/12] fddi/skfp: check given MAC address, if invalid return -EADDRNOTAVAIL

Check if given address is valid in .ndo_set_mac_address, if
invalid return -EADDRNOTAVAIL as eth_mac_addr() already does
if is_valid_ether_addr() fails.

Signed-off-by: Danny Kukawka <[email protected]>
---
drivers/net/fddi/skfp/skfddi.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/net/fddi/skfp/skfddi.c b/drivers/net/fddi/skfp/skfddi.c
index 3d9a459..1092d94 100644
--- a/drivers/net/fddi/skfp/skfddi.c
+++ b/drivers/net/fddi/skfp/skfddi.c
@@ -81,6 +81,7 @@ static const char * const boot_msg =
#include <linux/interrupt.h>
#include <linux/pci.h>
#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
#include <linux/fddidevice.h>
#include <linux/skbuff.h>
#include <linux/bitops.h>
@@ -926,6 +927,8 @@ static int skfp_ctl_set_mac_address(struct net_device *dev, void *addr)
skfddi_priv *bp = &smc->os;
unsigned long Flags;

+ if (!is_valid_ether_addr(p_sockaddr->sa_data))
+ return -EADDRNOTAVAIL;

memcpy(dev->dev_addr, p_sockaddr->sa_data, FDDI_K_ALEN);
spin_lock_irqsave(&bp->DriverLock, Flags);
--
1.7.8.3

2012-02-24 16:01:37

by Danny Kukawka

[permalink] [raw]
Subject: [PATCH 05/12] team: check given MAC address, if invalid return -EADDRNOTAVAIL

Check if given address is valid in .ndo_set_mac_address, if
invalid return -EADDRNOTAVAIL as eth_mac_addr() already does
if is_valid_ether_addr() fails.

Signed-off-by: Danny Kukawka <[email protected]>
---
drivers/net/team/team.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index 8f81805..788650c 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -868,6 +868,9 @@ static int team_set_mac_address(struct net_device *dev, void *p)
struct team_port *port;
struct sockaddr *addr = p;

+ if (!is_valid_ether_addr(addr->sa_data))
+ return -EADDRNOTAVAIL;
+
dev->addr_assign_type &= ~NET_ADDR_RANDOM;
memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
rcu_read_lock();
--
1.7.8.3

2012-02-24 16:05:43

by Danny Kukawka

[permalink] [raw]
Subject: [PATCH 08/12] vmxnet3: check given MAC address, if invalid return -EADDRNOTAVAIL

Check if given address is valid in .ndo_set_mac_address/
vmxnet3_set_mac_addr(), if invalid return -EADDRNOTAVAIL as
eth_mac_addr() already does if is_valid_ether_addr() fails.

Signed-off-by: Danny Kukawka <[email protected]>
---
drivers/net/vmxnet3/vmxnet3_drv.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
index e1562e8..bd2a7cd 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -2331,6 +2331,9 @@ vmxnet3_set_mac_addr(struct net_device *netdev, void *p)
struct sockaddr *addr = p;
struct vmxnet3_adapter *adapter = netdev_priv(netdev);

+ if (!is_valid_ether_addr(addr->sa_data))
+ return -EADDRNOTAVAIL;
+
memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
vmxnet3_write_mac_addr(adapter, addr->sa_data);

--
1.7.8.3

2012-02-24 16:12:19

by Alan

[permalink] [raw]
Subject: Re: [PATCH 12/12] rose: check given MAC address, if invalid return -EADDRNOTAVAIL

On Fri, 24 Feb 2012 17:01:22 +0100
Danny Kukawka <[email protected]> wrote:

> Check if given address is valid in .ndo_set_mac_address/
> rose_set_mac_address(), if invalid return -EADDRNOTAVAIL as
> eth_mac_addr() already does if is_valid_ether_addr() fails.

This patch series looks wrong - you cannot go blindly applying ethernet
mac address tests to device drivers without checking if they are using
802.11 type addressing at the physical level.

Alan

2012-02-24 16:32:41

by Bhavesh Davda

[permalink] [raw]
Subject: Re: [Pv-drivers] [PATCH 08/12] vmxnet3: check given MAC address, if invalid return -EADDRNOTAVAIL

Lgtm.

Reviewed-by: Bhavesh Davda <[email protected]>

- Bhavesh

(From my iPhone)


On Feb 24, 2012, at 8:01 AM, "Danny Kukawka" <[email protected]> wrote:

> Check if given address is valid in .ndo_set_mac_address/
> vmxnet3_set_mac_addr(), if invalid return -EADDRNOTAVAIL as
> eth_mac_addr() already does if is_valid_ether_addr() fails.
>
> Signed-off-by: Danny Kukawka <[email protected]>
> ---
> drivers/net/vmxnet3/vmxnet3_drv.c | 3 +++
> 1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
> index e1562e8..bd2a7cd 100644
> --- a/drivers/net/vmxnet3/vmxnet3_drv.c
> +++ b/drivers/net/vmxnet3/vmxnet3_drv.c
> @@ -2331,6 +2331,9 @@ vmxnet3_set_mac_addr(struct net_device *netdev, void *p)
> struct sockaddr *addr = p;
> struct vmxnet3_adapter *adapter = netdev_priv(netdev);
>
> + if (!is_valid_ether_addr(addr->sa_data))
> + return -EADDRNOTAVAIL;
> +
> memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
> vmxnet3_write_mac_addr(adapter, addr->sa_data);
>
> --
> 1.7.8.3
>
> _______________________________________________
> Pv-drivers mailing list
> [email protected]
> http://mailman2.vmware.com/mailman/listinfo/pv-drivers

2012-02-24 17:59:27

by Michał Mirosław

[permalink] [raw]
Subject: Re: [PATCH 00/12] Part 2: check given MAC address, if invalid return -EADDRNOTAVAIL

2012/2/24 Danny Kukawka <[email protected]>:
> Second Part of series patches to unifiy the return value of
> .ndo_set_mac_address if the given address isn't valid.
>
> These changes check if a given (MAC) address is valid in
> .ndo_set_mac_address, if invalid return -EADDRNOTAVAIL
> as eth_mac_addr() already does if is_valid_ether_addr() fails.

Why not just fix dev_set_mac_address() and make do_setlink() use that?
Checks are specific to address family, not device model I assume.

Best Regards,
Michał Mirosław

2012-02-24 20:43:57

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 12/12] rose: check given MAC address, if invalid return -EADDRNOTAVAIL

From: Alan Cox <[email protected]>
Date: Fri, 24 Feb 2012 16:13:58 +0000

> On Fri, 24 Feb 2012 17:01:22 +0100
> Danny Kukawka <[email protected]> wrote:
>
>> Check if given address is valid in .ndo_set_mac_address/
>> rose_set_mac_address(), if invalid return -EADDRNOTAVAIL as
>> eth_mac_addr() already does if is_valid_ether_addr() fails.
>
> This patch series looks wrong - you cannot go blindly applying ethernet
> mac address tests to device drivers without checking if they are using
> 802.11 type addressing at the physical level.

Right.

2012-02-25 10:13:26

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH 00/12] Part 2: check given MAC address, if invalid return -EADDRNOTAVAIL

2012/2/24 Michał Mirosław <[email protected]>:
> 2012/2/24 Danny Kukawka <[email protected]>:
>> Second Part of series patches to unifiy the return value of
>> .ndo_set_mac_address if the given address isn't valid.
>>
>> These changes check if a given (MAC) address is valid in
>> .ndo_set_mac_address, if invalid return -EADDRNOTAVAIL
>> as eth_mac_addr() already does if is_valid_ether_addr() fails.
>
> Why not just fix dev_set_mac_address() and make do_setlink() use that?

BTW, it's also called from dev_set_mac_address().

> Checks are specific to address family, not device model I assume.

Indeed, why can't this be done in one single place, instead of sprinkling these
checks over all drivers, missing all out-of-tree (note: I don't care) and all
soon-to-be-submitted drivers?

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

2012-02-25 17:27:40

by Jesper Nilsson

[permalink] [raw]
Subject: Re: [PATCH 02/12] cris/eth_v10: check given MAC address, if invalid return -EADDRNOTAVAIL

On Fri, Feb 24, 2012 at 05:01:12PM +0100, Danny Kukawka wrote:
> Check if given address is valid in .ndo_set_mac_address, if
> invalid return -EADDRNOTAVAIL as eth_mac_addr() already does
> if is_valid_ether_addr() fails.
>
> Signed-off-by: Danny Kukawka <[email protected]>

Acked-by: Jesper Nilsson <[email protected]>

/^JN - Jesper Nilsson
--
Jesper Nilsson -- jesper_at_jni.nu

2012-02-25 18:26:36

by Danny Kukawka

[permalink] [raw]
Subject: Re: [PATCH 12/12] rose: check given MAC address, if invalid return -EADDRNOTAVAIL

On Freitag, 24. Februar 2012, David Miller wrote:
> From: Alan Cox <[email protected]>
> Date: Fri, 24 Feb 2012 16:13:58 +0000
>
> > On Fri, 24 Feb 2012 17:01:22 +0100
> >
> > Danny Kukawka <[email protected]> wrote:
> >> Check if given address is valid in .ndo_set_mac_address/
> >> rose_set_mac_address(), if invalid return -EADDRNOTAVAIL as
> >> eth_mac_addr() already does if is_valid_ether_addr() fails.
> >
> > This patch series looks wrong - you cannot go blindly applying ethernet
> > mac address tests to device drivers without checking if they are using
> > 802.11 type addressing at the physical level.

Overseen this aspect ... Sorry. I'll check the patches and send an updated
version.

Do you mean 802.3 ?

Danny

2012-02-26 00:07:28

by Jiri Pirko

[permalink] [raw]
Subject: Re: [PATCH 05/12] team: check given MAC address, if invalid return -EADDRNOTAVAIL

Fri, Feb 24, 2012 at 05:01:15PM CET, [email protected] wrote:
>Check if given address is valid in .ndo_set_mac_address, if
>invalid return -EADDRNOTAVAIL as eth_mac_addr() already does
>if is_valid_ether_addr() fails.
>
>Signed-off-by: Danny Kukawka <[email protected]>
>---
> drivers/net/team/team.c | 3 +++
> 1 files changed, 3 insertions(+), 0 deletions(-)
>
>diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
>index 8f81805..788650c 100644
>--- a/drivers/net/team/team.c
>+++ b/drivers/net/team/team.c
>@@ -868,6 +868,9 @@ static int team_set_mac_address(struct net_device *dev, void *p)
> struct team_port *port;
> struct sockaddr *addr = p;
>
>+ if (!is_valid_ether_addr(addr->sa_data))
>+ return -EADDRNOTAVAIL;
>+


Wouldn't it be better to do this in one place? dev_set_mac_address()
seems like a good place...

Jirka


> dev->addr_assign_type &= ~NET_ADDR_RANDOM;
> memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
> rcu_read_lock();
>--
>1.7.8.3
>

2012-02-29 07:04:21

by Danny Kukawka

[permalink] [raw]
Subject: Re: [PATCH 00/12] Part 2: check given MAC address, if invalid return -EADDRNOTAVAIL

On Samstag, 25. Februar 2012, Geert Uytterhoeven wrote:
> 2012/2/24 Michał Mirosław <[email protected]>:
> > 2012/2/24 Danny Kukawka <[email protected]>:
> >> Second Part of series patches to unifiy the return value of
> >> .ndo_set_mac_address if the given address isn't valid.
> >>
> >> These changes check if a given (MAC) address is valid in
> >> .ndo_set_mac_address, if invalid return -EADDRNOTAVAIL
> >> as eth_mac_addr() already does if is_valid_ether_addr() fails.
> >
> > Why not just fix dev_set_mac_address() and make do_setlink() use that?
>
> BTW, it's also called from dev_set_mac_address().
>
> > Checks are specific to address family, not device model I assume.
>
> Indeed, why can't this be done in one single place, instead of sprinkling
> these checks over all drivers, missing all out-of-tree (note: I don't care)
> and all soon-to-be-submitted drivers?

Since the .ndo_set_mac_address functions are used by some drivers internally
too, you may get some new checks on other places. But I'll take a look at it.

Danny