]> git.ipfire.org Git - thirdparty/openwrt.git/commit
realtek: RTL838x harden ethernet driver against fuzzying 19679/head
authorMarkus Stockhausen <markus.stockhausen@gmx.de>
Tue, 5 Aug 2025 15:46:40 +0000 (11:46 -0400)
committerRobert Marko <robimarko@gmail.com>
Mon, 11 Aug 2025 13:18:09 +0000 (15:18 +0200)
commit0724412c58896b765fff77d63907729d298fbb67
tree6739c687b7e109eaaa38da83d9ea5894d7b4da51
parent6152381880c57cd4dbfec3185342d52f44d57cf5
realtek: RTL838x harden ethernet driver against fuzzying

While checking setup routines for stability and completeness,
random RTL838x SoC I/O areas were intentionally overwritten.
As soon as L2_CTRL_1->FAST_AGE_OUT is set to 1, the system
stalls during bootup. Analysis shows that it loops endlessly
in rtl838x_hw_stop()

/* Flush L2 address cache */
if (priv->family_id == RTL8380_FAMILY_ID) {
for (int i = 0; i <= priv->cpu_port; i++) {
sw_w32(1 << 26 | 1 << 23 | i << 5, priv->r->l2_tbl_flush_ctrl);
do { } while (sw_r32(priv->r->l2_tbl_flush_ctrl) & (1 << 26));
}

This is exactly the same logic as in the vendor GPL. There
are no hints about possible timeouts or issues. The reason is
still unclear. Nevertheless harden the function for further fuzzy
tests. Do this by resetting the configuration value to its SoC
default.

Additionally convert some shifts to BIT() for better readability.

Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Link: https://github.com/openwrt/openwrt/pull/19679
Signed-off-by: Robert Marko <robimarko@gmail.com>
target/linux/realtek/files-6.12/drivers/net/ethernet/rtl838x_eth.c
target/linux/realtek/files-6.12/drivers/net/ethernet/rtl838x_eth.h