Netdev List
 help / color / mirror / Atom feed
* [PATCH] net: bcmasp: avoid refcount drain on probe
@ 2026-11-19  8:15 Wang Haoran
  2026-11-19  8:18 ` netdev-bot+sinfo
  0 siblings, 1 reply; 2+ messages in thread
From: Wang Haoran @ 2026-11-19  8:15 UTC (permalink / raw)
  To: justin.chen, florian.fainelli
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni,
	bcm-kernel-feedback-list, netdev, linux-kernel, wanghr2026

bcmasp_probe() calls of_find_node_by_name(dev->of_node, "ethernet-ports"),
which unconditionally drops the from-node reference the caller never held.
Every probe or bind cycle that reaches the port scan, including ones that
later fail with "No ports found", drains the asp node refcount by one. Once
it hits zero, of_node_release() deadlocks in its error printk (%pOF on the
parent while holding devtree_lock with IRQs off), so the machine freezes
silently with nothing on the console.

Use of_get_child_by_name() which leaves the parent reference alone.

Signed-off-by: Wang Haoran <wanghr2026@mail.zgclab.edu.cn>
Fixes: 490cb412007d ("net: bcmasp: Add support for ASP2.0 Ethernet controller")
---

diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp.c b/drivers/net/ethernet/broadcom/asp2/bcmasp.c
index a59a006cea3a..af9e14214987 100644
--- a/drivers/net/ethernet/broadcom/asp2/bcmasp.c
+++ b/drivers/net/ethernet/broadcom/asp2/bcmasp.c
@@ -1342,7 +1342,7 @@ static int bcmasp_probe(struct platform_device *pdev)
 
 	bcmasp_init_wol(priv);
 
-	ports_node = of_find_node_by_name(dev->of_node, "ethernet-ports");
+	ports_node = of_get_child_by_name(dev->of_node, "ethernet-ports");
 	if (!ports_node) {
 		dev_warn(dev, "No ports found\n");
 		ret = -EINVAL;

---

PoC reproduction (7.4.0-rc2, arm64 QEMU virt, unmodified kernel):

Device tree injection, spliced into the QEMU virt machine DT:

    reserved-memory { #address-cells = <2>; #size-cells = <2>; ranges;
        asp-regs@7f000000 { no-map; reg = <0x0 0x7f000000 0x0 0x200000>; }; };

    asp@7f000000 { compatible = "brcm,asp-v2.2"; reg = <0x0 0x7f000000 0x0 0x200000>;
        interrupt-parent = <&gpio0>; interrupts = <4 2>; };

The node has no ethernet-ports child, so every probe passes through the
of_find_node_by_name() call and then fails with "No ports found".

Trigger (repeated bind cycles):

    modprobe bcm-asp
    echo "7f000000.asp" > /sys/bus/platform/drivers/brcm,asp-v2/bind
    echo "7f000000.asp" > /sys/bus/platform/drivers/brcm,asp-v2/bind

Result:

    brcm,asp-v2 7f000000.asp: Failed to init WoL irq: -6
    brcm,asp-v2 7f000000.asp: No ports found
    MARK: probe1 done
    MARK: bind -> probe2
    MARK: bind -> probe3
    (no further output)

The third probe drives the asp node refcount to zero and the machine
freezes inside of_node_release().

Control: with the same DT minus the interrupt properties the probe fails
before this call and three or more bind cycles run clean.

Note: the PoC was generated with AI assistance and the vulnerability was
found by static analysis. The device tree is trusted input (a bad DT
requires root or physical access), so this is not a security fix, but it
prevents a potential resource leak or system failure on a failed probe or
an old or malformed DT.


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-19  8:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19  8:15 [PATCH] net: bcmasp: avoid refcount drain on probe Wang Haoran
2026-11-19  8:18 ` netdev-bot+sinfo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox