summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLijun Pan <ljp@linux.ibm.com>2020-10-27 17:04:56 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-11-01 12:47:05 +0100
commit8cf5f59cf4a89e42fbc4896b6279e6bf165cb83d (patch)
tree2ba5af29acb5fd1c85577f90c777972fdb3cc730
parentfa14e0a603e28eb37aa0e3857d598e1bff005466 (diff)
downloadlinux-stable-8cf5f59cf4a89e42fbc4896b6279e6bf165cb83d.tar.gz
linux-stable-8cf5f59cf4a89e42fbc4896b6279e6bf165cb83d.tar.bz2
linux-stable-8cf5f59cf4a89e42fbc4896b6279e6bf165cb83d.zip
ibmvnic: fix ibmvnic_set_mac
[ Upstream commit 8fc3672a8ad3e782bac80e979bc2a2c10960cbe9 ] Jakub Kicinski brought up a concern in ibmvnic_set_mac(). ibmvnic_set_mac() does this: ether_addr_copy(adapter->mac_addr, addr->sa_data); if (adapter->state != VNIC_PROBED) rc = __ibmvnic_set_mac(netdev, addr->sa_data); So if state == VNIC_PROBED, the user can assign an invalid address to adapter->mac_addr, and ibmvnic_set_mac() will still return 0. The fix is to validate ethernet address at the beginning of ibmvnic_set_mac(), and move the ether_addr_copy to the case of "adapter->state != VNIC_PROBED". Fixes: c26eba03e407 ("ibmvnic: Update reset infrastructure to support tunable parameters") Signed-off-by: Lijun Pan <ljp@linux.ibm.com> Link: https://lore.kernel.org/r/20201027220456.71450-1-ljp@linux.ibm.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/net/ethernet/ibm/ibmvnic.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 3e0aab04d86f..f96bb3dab5a8 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -1828,9 +1828,13 @@ static int ibmvnic_set_mac(struct net_device *netdev, void *p)
int rc;
rc = 0;
- ether_addr_copy(adapter->mac_addr, addr->sa_data);
- if (adapter->state != VNIC_PROBED)
+ if (!is_valid_ether_addr(addr->sa_data))
+ return -EADDRNOTAVAIL;
+
+ if (adapter->state != VNIC_PROBED) {
+ ether_addr_copy(adapter->mac_addr, addr->sa_data);
rc = __ibmvnic_set_mac(netdev, addr->sa_data);
+ }
return rc;
}