Thread (20 messages) 20 messages, 3 authors, 2024-08-22

Re: [PATCH V2 net-next 11/11] net: add is_valid_ether_addr check in dev_set_mac_address

From: Jakub Kicinski <kuba@kernel.org>
Date: 2024-08-21 01:55:09
Also in: lkml

On Tue, 20 Aug 2024 22:01:54 +0800 Jijie Shao wrote:
quoted hunk ↗ jump to hunk
core need test the mac_addr not every driver need to do.

Signed-off-by: Jijie Shao <shaojijie@huawei.com>
---
 net/core/dev.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/net/core/dev.c b/net/core/dev.c
index e7260889d4cb..2e19712184bc 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -9087,6 +9087,8 @@ int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa,
 		return -EOPNOTSUPP;
 	if (sa->sa_family != dev->type)
 		return -EINVAL;
+	if (!is_valid_ether_addr(sa->sa_data))
+		return -EADDRNOTAVAIL;
not every netdev is for an Ethernet device
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help