From nobody Sat Feb 7 17:41:54 2026 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 60204944E for ; Sat, 11 Jan 2025 00:32:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736555565; cv=none; b=Z8e0hdTv6suHnDzkj/gHBzk+PNgSIGDPPIimFoAsnOvENWih71+TXHJjfXXwqw/2mmMcanQRQOABJuex+sJxNvqEo65FRddFMV4o+5pcpBcv013ScHeR7TujBs3GsTI1YlThi80DBpYRop58z5KDq8vDCkqHu1tXu0jc0M9wj1c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736555565; c=relaxed/simple; bh=DGi0rKgB7DG2bkLrv9jz4E08p86wxkjC2IMrGQoH3dE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=OfGx1QW8Iu5PwdVFA6i8exXZtrXxFqO4SaBQaTYcQeEa909A+mDviBKJw+/GGJbp0Wk15yxBjhg7YYbKSD1T+JR6jZWHiHa2xNesVvOZyhRjp+F2OMBmyAUQ5QJW74MaUlmuKIOd67UYjd+GOYokro4u0ebcSIIlFwlkmYWSq/k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jsperbeck.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=BnJvqBt3; arc=none smtp.client-ip=209.85.216.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jsperbeck.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="BnJvqBt3" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2f129f7717fso4834088a91.0 for ; Fri, 10 Jan 2025 16:32:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736555564; x=1737160364; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=L0ccI2zo+APIVeQ/eCX8t3sD4HMDr7ZQ98Pm9MsBru4=; b=BnJvqBt3qH7lNLgVZzp+Ye1Lg0C3IEnWrXbyDHEgLr73gnwirkC+M8VNKcbUmLvT3U sim4AxJdRZaK9ARpp4xEM2WLjZ4NzCTCAYsUDaL0hfhj/6II0CPNx6sRXFGGR3cTl+5e Hd5CLMwKASb9JZa9I3N91G9mk+0EKCh8fk83k4aBgX5k21VcQdOgTbIHPgvKZJjgqaSB YD57VxDw3bEOt5l06Ro3+GrSNlRTQ9kW+8ZU+kh1G8NJzHRVyTc8G+lCs2nEwRpDrz77 ZLh0+mkGzNNiRmJJuagn8Ya5CoEuiLmXpMJGRrtNdhN09XKx38gyd/1fT+QG743u8dAp nwlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736555564; x=1737160364; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=L0ccI2zo+APIVeQ/eCX8t3sD4HMDr7ZQ98Pm9MsBru4=; b=Mzwc38rMbwjJpw7XYPqm2F8JaYz9nRdG6t+WMv7BLGdwslcO7l2xTsZkoYbMuqRNRS 18SxcA93tT+x9Anvfaz6kNf2/hmMnsffTxH6s8sVBRCz94QYWDe3+OWUVEkSUlD2L0fF EzS2X1nCVFEn2I54C7AwkOqVCusZjIO+7kW2jmlhZKb4cfiKUiOJ/od9RbfyWr1YQZ8h GSQ43Q12cZDf1+5m+jqpXvbRYnyMAUKnlXZLHYRgTwN8/DR524fDuxy6qi4T/LrbHZPN qfLjizpspW2y4aX4yPqHbi/7IyK94/NUpA5jCMzJX/b5QJYGoaAMRcfqbETvWXxgtL0F 1TXw== X-Forwarded-Encrypted: i=1; AJvYcCUQmWKLk3FqZxqD+TKgU2ZqRAFhcJKb/TUAEI0vnhbnjTadhGRWhpJNpb8GXVS4iltplV4XS+iLS/nJsa4=@vger.kernel.org X-Gm-Message-State: AOJu0YzdeOh3v7nEyevJfGkH6v9faIpGWHb+v2nkJYQ/aMUaVp0Yssz+ iup1p5AY7Vc6ipzS9AV/olp7RS8mEsTq7vUc31b1VTLU0JLTW0rmhYCPCPkb88zCcbifefSsFwq DF5GYS0g8FGl9BQ== X-Google-Smtp-Source: AGHT+IGBJUuz4cLHmBPMbT9IP/ci24ipV/UzhpNwl/X0DuSKrbCqNkm+OWr6ossZVsJNH0iUQ6Gs3HRq/HW8/gk= X-Received: from pjboh12.prod.google.com ([2002:a17:90b:3a4c:b0:2da:5868:311c]) (user=jsperbeck job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:520e:b0:2f2:ab09:c256 with SMTP id 98e67ed59e1d1-2f548f424b1mr19646846a91.33.1736555563687; Fri, 10 Jan 2025 16:32:43 -0800 (PST) Date: Fri, 10 Jan 2025 16:32:38 -0800 In-Reply-To: <20250110-wildebeest-of-optimal-unity-06c308@leitao> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250110-wildebeest-of-optimal-unity-06c308@leitao> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog Message-ID: <20250111003238.2669538-1-jsperbeck@google.com> Subject: [PATCH v2] net: netpoll: ensure skb_pool list is always initialized From: John Sperbeck To: Breno Leitao Cc: "David S . Miller" , Eric Dumazet , Paolo Abeni , netdev@vger.kernel.org, Simon Horman , linux-kernel@vger.kernel.org, kuba@kernel.org, jsperbeck@google.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When __netpoll_setup() is called directly, instead of through netpoll_setup(), the np->skb_pool list head isn't initialized. If skb_pool_flush() is later called, then we hit a NULL pointer in skb_queue_purge_reason(). This can be seen with this repro, when CONFIG_NETCONSOLE is enabled as a module: ip tuntap add mode tap tap0 ip link add name br0 type bridge ip link set dev tap0 master br0 modprobe netconsole netconsole=3D4444@10.0.0.1/br0,9353@10.0.0.2/ rmmod netconsole The backtrace is: BUG: kernel NULL pointer dereference, address: 0000000000000008 #PF: supervisor write access in kernel mode #PF: error_code(0x0002) - not-present page ... ... ... Call Trace: __netpoll_free+0xa5/0xf0 br_netpoll_cleanup+0x43/0x50 [bridge] do_netpoll_cleanup+0x43/0xc0 netconsole_netdev_event+0x1e3/0x300 [netconsole] unregister_netdevice_notifier+0xd9/0x150 cleanup_module+0x45/0x920 [netconsole] __se_sys_delete_module+0x205/0x290 do_syscall_64+0x70/0x150 entry_SYSCALL_64_after_hwframe+0x76/0x7e Move the skb_pool list setup and initial skb fill into __netpoll_setup(). Fixes: 221a9c1df790 ("net: netpoll: Individualize the skb pool") Signed-off-by: John Sperbeck Reviewed-by: Breno Leitao --- net/core/netpoll.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/net/core/netpoll.c b/net/core/netpoll.c index 2e459b9d88eb..96a6ed37d4cc 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c @@ -627,6 +627,8 @@ int __netpoll_setup(struct netpoll *np, struct net_devi= ce *ndev) const struct net_device_ops *ops; int err; =20 + skb_queue_head_init(&np->skb_pool); + if (ndev->priv_flags & IFF_DISABLE_NETPOLL) { np_err(np, "%s doesn't support polling, aborting\n", ndev->name); @@ -662,6 +664,9 @@ int __netpoll_setup(struct netpoll *np, struct net_devi= ce *ndev) strscpy(np->dev_name, ndev->name, IFNAMSIZ); npinfo->netpoll =3D np; =20 + /* fill up the skb queue */ + refill_skbs(np); + /* last thing to do is link it to the net device structure */ rcu_assign_pointer(ndev->npinfo, npinfo); =20 @@ -681,8 +686,6 @@ int netpoll_setup(struct netpoll *np) struct in_device *in_dev; int err; =20 - skb_queue_head_init(&np->skb_pool); - rtnl_lock(); if (np->dev_name[0]) { struct net *net =3D current->nsproxy->net_ns; @@ -782,9 +785,6 @@ int netpoll_setup(struct netpoll *np) } } =20 - /* fill up the skb queue */ - refill_skbs(np); - err =3D __netpoll_setup(np, ndev); if (err) goto flush; --=20 2.47.1.613.gc27f4b7a9f-goog