lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <38edb6a91d0ee90f3d656ec2c0030eee440cf355.1522479607.git.joe@perches.com>
Date:   Sat, 31 Mar 2018 00:05:16 -0700
From:   Joe Perches <joe@...ches.com>
To:     linux-kernel@...r.kernel.org
Cc:     "David S. Miller" <davem@...emloft.net>, netdev@...r.kernel.org
Subject: [PATCH 01/12] ethernet: Add generic ether_<foo>_addr addresses

Treewide there are ~60 declarations of Ethernet broadcast or zero address
use as a 6 byte array that are later used as either an output for vsprintf
extension %pM or as a source array to copy or compare.

Create const globals for these uses with EXPORT_SYMBOL for modules.

Miscellanea:

o Rename and move static const eth_reservd_addr_base from etherdevice.h
  to this new ether_addrs.c file so it is no longer oddly declared
  as static const in a .h file

Signed-off-by: Joe Perches <joe@...ches.com>
---
 include/linux/etherdevice.h | 12 ++++++++----
 net/ethernet/Makefile       |  2 +-
 net/ethernet/ether_addrs.c  | 19 +++++++++++++++++++
 3 files changed, 28 insertions(+), 5 deletions(-)
 create mode 100644 net/ethernet/ether_addrs.c

diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
index 79563840c295..85d2486b2959 100644
--- a/include/linux/etherdevice.h
+++ b/include/linux/etherdevice.h
@@ -63,10 +63,14 @@ struct sk_buff **eth_gro_receive(struct sk_buff **head,
 				 struct sk_buff *skb);
 int eth_gro_complete(struct sk_buff *skb, int nhoff);
 
+/* Generic Ethernet addresses */
+extern const u8 ether_broadcast_addr[ETH_ALEN];	/* all 0xff */
+extern const u8 ether_zero_addr[ETH_ALEN];	/* all zeros */
+
 /* Reserved Ethernet Addresses per IEEE 802.1Q */
-static const u8 eth_reserved_addr_base[ETH_ALEN] __aligned(2) =
-{ 0x01, 0x80, 0xc2, 0x00, 0x00, 0x00 };
-#define eth_stp_addr eth_reserved_addr_base
+extern const u8 ether_reserved_addr_base[ETH_ALEN];
+
+#define eth_stp_addr ether_reserved_addr_base
 
 /**
  * is_link_local_ether_addr - Determine if given Ethernet address is link-local
@@ -80,7 +84,7 @@ static const u8 eth_reserved_addr_base[ETH_ALEN] __aligned(2) =
 static inline bool is_link_local_ether_addr(const u8 *addr)
 {
 	__be16 *a = (__be16 *)addr;
-	static const __be16 *b = (const __be16 *)eth_reserved_addr_base;
+	static const __be16 *b = (const __be16 *)ether_reserved_addr_base;
 	static const __be16 m = cpu_to_be16(0xfff0);
 
 #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
diff --git a/net/ethernet/Makefile b/net/ethernet/Makefile
index 323177505404..fbbcfec2ba10 100644
--- a/net/ethernet/Makefile
+++ b/net/ethernet/Makefile
@@ -2,4 +2,4 @@
 # Makefile for the Linux Ethernet layer.
 #
 
-obj-y					+= eth.o
+obj-y					+= eth.o ether_addrs.o
diff --git a/net/ethernet/ether_addrs.c b/net/ethernet/ether_addrs.c
new file mode 100644
index 000000000000..e0b7a57628e8
--- /dev/null
+++ b/net/ethernet/ether_addrs.c
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Various const global Ethernet addresses */
+
+#include <linux/etherdevice.h>
+
+const u8 ether_broadcast_addr[ETH_ALEN] __aligned(2) = {
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+};
+EXPORT_SYMBOL(ether_broadcast_addr);
+
+const u8 ether_zero_addr[ETH_ALEN] __aligned(2) = {
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+EXPORT_SYMBOL(ether_zero_addr);
+
+const u8 ether_reserved_addr_base[ETH_ALEN] __aligned(2) = {
+	0x01, 0x80, 0xc2, 0x00, 0x00, 0x00
+};
+EXPORT_SYMBOL(ether_reserved_addr_base);
-- 
2.15.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ