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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 11 Sep 2009 13:20:42 -0700
From:	Joe Perches <joe@...ches.com>
To:	David Miller <davem@...emloft.net>
Cc:	shemminger@...tta.com, jeffrey.t.kirsher@...el.com,
	netdev@...r.kernel.org, gospo@...hat.com, gregory.v.rose@...el.com,
	donald.c.skidmore@...el.com
Subject: [net-next PATCH] etherdevice.h: random_ether_addr update

On Fri, 2009-09-11 at 12:15 -0700, David Miller wrote:
> From: Joe Perches <joe@...ches.com>
> Date: Thu, 10 Sep 2009 20:02:43 -0700
> > On Thu, 2009-09-10 at 19:07 -0700, Stephen Hemminger wrote:
> >> On Thu, 10 Sep 2009 18:48:27 -0700
> >> Jeff Kirsher <jeffrey.t.kirsher@...el.com> wrote:
> >> > From: Gregory Rose <gregory.v.rose@...el.com>
> >> > This patch changes the default VF MAC address generation to use an Intel
> >> > Organizational Unit Identifier (OUI), instead of a fully randomized
> >> > Ethernet address.  This is to help prevent accidental MAC address
> >> > collisions.
> > I think this not a very good idea.
> I also completely agree that this patch is not a wise move.

Perhaps this?

random_ether_address should not assign an "0x02" leading octet.

"02" has the local assignment bit set,
but is actually a value assigned via OUI.

Do not use get_random_bytes to avoid drawing down entropy pool.

Signed-off-by: Joe Perches <joe@...ches.com>

diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
index 3d7a668..ae7f261 100644
--- a/include/linux/etherdevice.h
+++ b/include/linux/etherdevice.h
@@ -121,9 +121,17 @@ static inline int is_valid_ether_addr(const u8 *addr)
  */
 static inline void random_ether_addr(u8 *addr)
 {
-	get_random_bytes (addr, ETH_ALEN);
-	addr [0] &= 0xfe;	/* clear multicast bit */
-	addr [0] |= 0x02;	/* set local assignment bit (IEEE802) */
+	int i;
+
+	/* not calling get_random_bytes to avoid using entropy */
+	do {
+		addr[0] = random32();
+	} while (addr[0] == 0 || addr[0] == 1);
+				/* get a non-zero, non-one leading octet */
+	addr[0] &= 0xfe;	/* clear multicast bit */
+	addr[0] |= 0x02;	/* set local assignment bit (IEEE802) */
+	for (i = 1; i < ETH_ALEN; i++)
+		addr[i] = random32();
 }
 
 /**


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ