NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/60592: random Mac address generation in genet Ethernet driver causes problems



>Number:         60592
>Category:       kern
>Synopsis:       random Mac address generation in genet Ethernet driver causes problems
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Aug 14 21:50:04 +0000 2026
>Originator:     Emmanuel
>Release:        NetBSD 11
>Organization:
NetBSD
>Environment:
arm aarch64
>Description:
https://mail-index.netbsd.org/port-arm/2026/07/26/msg009640.html

when generating random Mac addresses, our unicast bit is supposed to set to 0 and 
locally administered bit to 1. but the extraction code shifts the unicast and administered bits away

so this causes problems sometimes on machines using the genet ethernet card. 
>How-To-Repeat:
connect your genet network interface to any network.
>Fix:
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/bcmgenet.c,v
retrieving revision 1.23
diff -u -r1.23 bcmgenet.c
--- sys/dev/ic/bcmgenet.c       4 Oct 2025 04:44:20 -0000       1.23
+++ sys/dev/ic/bcmgenet.c       14 Aug 2026 21:44:19 -0000
@@ -974,11 +974,11 @@

        if (maclo == 0 && machi == 0) {
                /* Create one */
-               maclo = 0x00f2 | (cprng_strong32() & 0xffff0000);
+               maclo = cprng_strong32() & 0x0000ffff;
                machi = cprng_strong32() & 0xffff;
        }
 
-       eaddr[0] = (maclo >> 24) & 0xff;
+       eaddr[0] = (maclo >> 24) | 0xf2;
        eaddr[1] = (maclo >> 16) & 0xff;
        eaddr[2] = (maclo >>  8) & 0xff;
        eaddr[3] = (maclo >>  0) & 0xff;


This preserves the intent to zero out second byte and have a 0xf2 in first byte and randomize third and fourth byte in the Mac address generated.




Home | Main Index | Thread Index | Old Index