mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wang Haoran <wanghr2026@mail.zgclab.edu.cn>
To: justin.chen@broadcom.com, florian.fainelli@broadcom.com
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com,
	bcm-kernel-feedback-list@broadcom.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, wanghr2026@mail.zgclab.edu.cn
Subject: [PATCH] net: bcmasp: avoid refcount drain on probe
Date: Thu, 19 Nov 2026 16:15:02 +0800	[thread overview]
Message-ID: <1795076102979-9-385853cc@mail.zgclab.edu.cn> (raw)

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.


             reply	other threads:[~2026-11-19  8:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19  8:15 Wang Haoran [this message]
2026-11-19  8:18 ` netdev-bot+sinfo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1795076102979-9-385853cc@mail.zgclab.edu.cn \
    --to=wanghr2026@mail.zgclab.edu.cn \
    --cc=andrew+netdev@lunn.ch \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=florian.fainelli@broadcom.com \
    --cc=justin.chen@broadcom.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®