Page MenuHomeFreeBSD

generic_ehci_fdt: fix driver softc size
ClosedPublic

Authored by mhorne on Jun 29 2026, 6:12 PM.
Tags
None
Referenced Files
F165631106: D57951.id180987.diff
Sat, Aug 8, 9:33 PM
F165626531: D57951.id180940.diff
Sat, Aug 8, 8:58 PM
F165511993: D57951.id180987.diff
Sat, Aug 8, 12:08 PM
F165473640: D57951.diff
Sat, Aug 8, 9:25 AM
Unknown Object (File)
Fri, Aug 7, 3:32 PM
Unknown Object (File)
Wed, Aug 5, 3:41 PM
Unknown Object (File)
Sat, Aug 1, 4:33 AM
Unknown Object (File)
Sat, Aug 1, 3:49 AM
Subscribers

Details

Summary

This subclass declares its own softc structure adding necessary members
after the embedded ehci_softc_t. The full size of the struct must be
included in the driver declaration, otherwise the allocation backing the
softc is not guaranteed to be large enough.

Reported by: KASAN

Test Plan

Testing the RISC-V KASAN implementation, I got this report:

ehci0: <Generic EHCI Controller> mem 0x4101000-0x41010ff irq 34 on simplebus0
panic: ASan: Invalid access, 8-byte write at 0xffffffc002ba7598, MallocRedZone(fb)
cpuid = 0
time = 1
KDB: stack backtrace:
db_trace_self() at db_trace_self
db_trace_self_wrapper() at db_trace_self_wrapper+0xd6
kdb_backtrace() at kdb_backtrace+0x118
vpanic() at vpanic+0x164
panic() at panic+0x8e
kasan_report() at kasan_report+0xd8
__asan_store8_noabort() at __asan_store8_noabort+0xee
generic_ehci_fdt_attach() at generic_ehci_fdt_attach+0xc2
device_attach() at device_attach+0x764
bus_generic_new_pass() at bus_generic_new_pass+0x1f2
bus_generic_new_pass() at bus_generic_new_pass+0x13e
bus_generic_new_pass() at bus_generic_new_pass+0x13e
bus_generic_new_pass() at bus_generic_new_pass+0x13e
root_bus_configure() at root_bus_configure+0x44
configure() at configure+0xc
mi_startup() at mi_startup+0x25a
va() at va+0x7c
KDB: enter: panic

With this change, accesses to e.g. sc->clk_list no longer trigger the KASAN failure.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable