From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.tipi-net.de (mail.tipi-net.de [194.13.80.246]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 779B436A009; Mon, 28 Sep 2026 10:57:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.13.80.246 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790593079; cv=none; b=V1nOqmC0fYhSI+zgnqNoIiZ3dAv1yoW7lNEPDfSqiwzD5ERtIMtPp10vhB1Dh0ElzQb1S1nWiwSzUAma52XY4zwQLDSqanuLpgAIvF/ugko4XJIFGYuF6/1TWb0JkfSC1VZnCFt+gG9gixM1G3csA2ju92HvByfYjYL28Zj534Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790593079; c=relaxed/simple; bh=mZe4RtlDxzlL/1Jg/cNzZpEgjifmuO5zgUiEjlq3n08=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=XJdJbk4fYYbB5Dpj0EMOJadW8vcy+eZ4XFhyf3Z5qV2SrYx6265gehNDpCMsm0Z9k5oTSNYk4g+C8zd76AAx4euXdQBuijPccwHyZq3GBAXvIu/uPl7GCeDoBkmhN+tvzK/qNJvHI/ICR/6HHdKfmOpsa+5v1eE4DNyJPcqEtxE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tipi-net.de; spf=pass smtp.mailfrom=tipi-net.de; dkim=pass (2048-bit key) header.d=tipi-net.de header.i=@tipi-net.de header.b=p1Gm/MvD; arc=none smtp.client-ip=194.13.80.246 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tipi-net.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tipi-net.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tipi-net.de header.i=@tipi-net.de header.b="p1Gm/MvD" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id D0D6CA4A3D; Mon, 28 Sep 2026 12:57:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tipi-net.de; s=dkim; t=1790593071; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding; bh=eizUS1I7SWWqEvkJKZQ486YrKJjLXWlR2fMDm9Hc8gE=; b=p1Gm/MvDQL322zLrWgnHtzHYMgQSjmO4flPLgQPY33mGBcKxa0cp5Ih/JwmAcMw4LQLF4E iVUGgHdvhn4Kaoca7BlvTV8U7FwK3xGU5PVOjeG7uKgXx9y9W5DxRuEAe/y+SYDKYiayaL REXviz0DK77iaU0FneR51bO7OtajavviNZRPQJs0+hj16BUJNpHAlgjXTu6vy/OwtTA1wd SJO9JfQgE1YWvjpGzZZ4CwNUkgz24DqA4FWcWG+njtuUdfIUazCo1F3AuaYRZF81FCJMxY /0KObXQdPzQankXlRWT3FvXaiPA9sCoeo30f1IRTWDJB0ng55hfAZ33CREf31A== From: Nicolai Buchwitz To: Doug Berger , Florian Fainelli , Nicolai Buchwitz , Broadcom internal kernel review list , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Justin Chen , Florian Fainelli , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net] net: bcmgenet: fix NULL dereference in set_coalesce before first open Date: Mon, 28 Sep 2026 12:56:41 +0200 Message-ID: <20260928105642.856210-1-nb@tipi-net.de> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Last-TLS-Session-Version: TLSv1.3 The Rx ring priv and index are only set in bcmgenet_init_rx_ring(), which runs at open. Setting the Rx coalescing parameters on an interface that was never opened, e.g. "ethtool -C eth0 rx-usecs 50", dereferences a NULL ring->priv. The oops happens with RTNL held, so networking stays stuck until a reboot: Unable to handle kernel paging request at virtual address 0000000000002788 pc : bcmgenet_set_rx_coalesce.isra.0+0x10/0x88 lr : bcmgenet_set_coalesce+0xe8/0x180 Call trace: bcmgenet_set_rx_coalesce.isra.0+0x10/0x88 (P) __ethnl_set_coalesce.isra.0+0x490/0x570 ethnl_set_coalesce+0x48/0xc0 ethnl_default_set_doit+0xf4/0x230 genl_family_rcv_msg_doit+0xe8/0x160 genl_rcv_msg+0x220/0x2a0 netlink_rcv_skb+0x68/0x140 genl_rcv+0x40/0x60 netlink_unicast+0x338/0x3c0 netlink_sendmsg+0x19c/0x3f8 __sock_sendmsg+0x64/0xc0 __sys_sendto+0x124/0x198 __arm64_sys_sendto+0x30/0x48 Set priv and index at probe. Writing the registers while the interface is down is harmless because open resets the MAC and bcmgenet_init_rx_coalesce() reapplies the stored values. Fixes: 9f4ca05827a2 ("net: bcmgenet: Add support for adaptive RX coalescing") Signed-off-by: Nicolai Buchwitz --- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c index f725d26e6020..e8908916558b 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c @@ -4151,8 +4151,11 @@ static int bcmgenet_probe(struct platform_device *pdev) netif_set_real_num_rx_queues(priv->dev, priv->hw_params->rx_queues + 1); /* Set default coalescing parameters */ - for (i = 0; i <= priv->hw_params->rx_queues; i++) + for (i = 0; i <= priv->hw_params->rx_queues; i++) { + priv->rx_rings[i].priv = priv; + priv->rx_rings[i].index = i; priv->rx_rings[i].rx_max_coalesced_frames = 1; + } /* Initialize u64 stats seq counter for 32bit machines */ for (i = 0; i <= GENET_MAX_MQ_CNT; i++) { -- 2.53.0