Bug 262407 - net/realtek-re-kmod: kernel panic when generating MAC address
Summary: net/realtek-re-kmod: kernel panic when generating MAC address
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Alex Dupre
Depends on:
Reported: 2022-03-07 19:48 UTC by Evgeni Golov
Modified: 2022-06-25 21:46 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (ale)


Note You need to log in before you can comment on or make changes to this bug.
Description Evgeni Golov 2022-03-07 19:48:51 UTC

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);

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.


[1] https://www.dfrobot.com/product-2242.html
Comment 1 Alex Dupre freebsd_committer 2022-03-08 08:37:26 UTC
@kib, any idea about the cause of the failure?