[Bug 262407] net/realtek-re-kmod: kernel panic when generating MAC address

From: <bugzilla-noreply_at_freebsd.org>
Date: Mon, 07 Mar 2022 19:48:51 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=262407

            Bug ID: 262407
           Summary: net/realtek-re-kmod: kernel panic when generating MAC
                    address
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: Individual Port(s)
          Assignee: ale@FreeBSD.org
          Reporter: evgeni@debian.org
             Flags: maintainer-feedback?(ale@FreeBSD.org)
          Assignee: ale@FreeBSD.org

Ohai,

there exists hardware (like [1]) that has no ethernet address burned into the
EEPROM. Realteks driver (contrary to the one in the FreeBSD kernel, see
#262406) tries to accommodate for that by generating a random mac address:

3890-        if (!is_valid_ether_addr(eaddr)) {
3891-                device_printf(dev,"Invalid ether addr: %6D\n", eaddr,
":");
3892:                random_ether_addr(eaddr);
3893-                device_printf(dev,"Random ether addr: %6D\n", eaddr, ":");
3894-        }

However, the net/realtek-re-kmod port patches (in files/patch-if__re.c) the
`random_ether_addr` call to be 
  ether_gen_addr(sc->re_ifp, (struct ether_addr *)eaddr);
instead.

This leads to a crash on my HW, with the following trace:
KDB: stack backtrace:
#0 0xffff00000050d058 at kdb_backtrace+0x60
#1 0xffff0000004b7228 at vpanic+0x184
#2 0xffff0000004b70a0 at panic+0x44
#3 0xffff000000824d2c at data_abort+0x1d8
#4 0xffff000000805078 at handle_el1h_sync+0x78
#5 0xffff00000051434c at kvprintf+0xbb4
#6 0xffff00000051434c at kvprintf+0xbb4
#7 0xffff000000515100 at vsnprintf+0x3c
#8 0xffff0000005c70c8 at vasprintf+0x4c
#9 0xffff0000005c7190 at asprintf+0x40
#10 0xffff0000005eb284 at ether_gen_addr+0x74
#11 0xffff000001222294 at re_attach+0x1b90
#12 0xffff0000004f9254 at device_attach+0x400
#13 0xffff0000004fa770 at bus_generic_attach+0x4c
#14 0xffff000000236e08 at pci_attach+0xe0
#15 0xffff0000004f9254 at device_attach+0x400
#16 0xffff0000004fa770 at bus_generic_attach+0x4c
#17 0xffff0000004f9254 at device_attach+0x400

I am not exactly sure *what* triggers this. At first I thought it'd be the cast
of eaddr, but that *should* work.
ether_gen_addr *does* call asprintf, so it might be that?

Reverting to the original random code from Realtek works.

Thanks!

[1] https://www.dfrobot.com/product-2242.html

-- 
You are receiving this mail because:
You are the assignee for the bug.