From nobody Thu Apr 9 16:35:00 2026 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 BE39C37BE6C for ; Sat, 7 Mar 2026 20:51:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772916682; cv=none; b=DZFXKt79+rZFzxv1XHmXqGLiN+MhD5WOot7R3VTBeEoxkjo1OT09JY5Y1Oy2467QMm9+OMrcvgAh6iIXTx+Avaotu040d2fM2ZMNEHSdelw+6veF/mKeIRqzXxDWRc9o5cMaT9ytIEMHtuyycu/kHiaGY/OD5TxqkmcoHHdwh5g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772916682; c=relaxed/simple; bh=6ZQFRvZdst5dX9ooPrNy2xeyWgmUkbigP/SKL7rpSfM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ww2PQxwMW8KgopXuOdWTs0eFqyySeEoSaJQuEvCZXBtq82pr58F+wKzQ8hEPUoQOCI7ia2+EvX4pu68GuD3WrD0nc0F4dRkRMAYHRFIEt8E6+X4g4Us/VPIhxJpQpUTy6a6AqkbF29lmh4H7zflaY2nTh/EyYmheMh+mN3djZ3c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=EFEbyQPF; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="EFEbyQPF" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-4852afd42ceso12036895e9.2 for ; Sat, 07 Mar 2026 12:51:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1772916673; x=1773521473; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=/sq24Ds5yyXWvt9Wqdyycsxol0O37NiUOJjceeuBF7w=; b=EFEbyQPFVkdmEbXFHIgdKb6x3PV1GD0BiLS3VK+Ae0oOoMgWWt9IK459EoE7UNWUTL s+Ppow+1Q626SoErzf1a2Nsq9DWo0F9O/9eNR0kd/CjHpBKip2E37eW44rVeWr65qEYC yBHeK1RObfgiEXjWTBsLHyWLxtkeYuXypbD8tRM+G/uwzhC/rst3sxJZEHSc5pO2Msj0 oYEEtF7eEbdwPGKDB1ki+vdo/5utNBUKILHVhDhZw0mrtT6iSURoXBr+LzPJPflXh15d c/vZ48gUK9LtUl9mpO3zMQlGQVM6AHoPhL8zKVynmESjGZqEVWlMxn3k87MgvFWzPwkv WZLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772916673; x=1773521473; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=/sq24Ds5yyXWvt9Wqdyycsxol0O37NiUOJjceeuBF7w=; b=UkpD/teCV/xzj/0nwD9XxEC0pfFlKil0kf6VeIaQXWnV68XOZm+jF8HJ2S1dv09iPa 02QLgwlTIm6IzeSq00h8Uj1V6rNWN1EyiqAxGzgFBMUIwoFc8JTjlCaISMmhbwPquxX4 9KQQmxrZ+XXNUYLst73osIaDNF67ttuhT4UhkAoigAIIbDzIbKA6DG7g+Ku3e1dZyzpo 7AyInsLiwHkfc17uHWMyOCUgxJBqUdeOqWSU+0ve1vaAfbKQebIeRJ+jRCworEUoiLEQ 2Pqvwb1WOKUrVEeDsyKf7q4l7Trom7ksgbpUZ4qyr55VkYM+1Woje3JzBLnuOPMetzr9 NcCg== X-Forwarded-Encrypted: i=1; AJvYcCW8W09rLo8X7ddLkQcF7f3+UbtY6Z9avUpR2ZEV13JLsgDcTLc10zLuwc7HZsCGPq0W63NoIbKB0YK5f9c=@vger.kernel.org X-Gm-Message-State: AOJu0YyOllRstadegMIyK29wHclvmDyjLrfmk+yZ0Jih9dVWqNxkqi59 0SQjaKOgXymULsz7ocA26kz2mI+DPFSMDbYvJ5n6VR8+p6xB3b41q6sGoOerI5+rlEY= X-Gm-Gg: ATEYQzxn3jF0FU0EwhHys40x9wuldoqTX9Rc/VImAp4RYSgBYcJqiEDuHiQC8MM0RES BwjGbxa8AKj4HnvVRiTougMz0Es8+9EvH7gmpAVtIwKMr7LWhzI2qX34yESRbG22p5WoolWJYlU gTiG3M0EnzRyJYIgNR5eAsPEVe6Ff+GWfbdpuYA5dPwNgIUZAsxx8Xn9w5Ocjs+XahEbGxZA/FB ZHCdN7gm4WjLAL+DqDrGa5PcqtoFZZtwyrgvCBSKZAr8W77usru4VVKK5AsBE9wIzFKfmghn1p4 3f4Jsvo9c2KCC/7FLVRXHq5WvHbY0mFn+6WISp2XE1R5BRmQLSVRXd5x4aMIt4GaHpxJ/EwJccq QLlGit4Uci5oLWJGPXF4tqUJNUd4B6qFQyXpye6cZfsExKP/7lbG/8ZXthDOizv7PlqImvuvrXQ D5bklv22mpLcNywd+gvLIG X-Received: by 2002:a05:600c:1908:b0:480:3a72:524a with SMTP id 5b1f17b1804b1-4852695943emr115413335e9.19.1772916673054; Sat, 07 Mar 2026 12:51:13 -0800 (PST) Received: from localhost ([189.99.238.164]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-56b0f889ed2sm4065923e0c.13.2026.03.07.12.51.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Mar 2026 12:51:12 -0800 (PST) From: =?utf-8?q?Ricardo_B=2E_Marli=C3=A8re?= Date: Sat, 07 Mar 2026 17:50:55 -0300 Subject: [PATCH net v4 3/4] bpf: bpf_out_neigh_v4: Fix nd_tbl NULL dereference when IPv6 is disabled Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260307-net-nd_tbl_fixes-v4-3-e2677e85628c@suse.com> References: <20260307-net-nd_tbl_fixes-v4-0-e2677e85628c@suse.com> In-Reply-To: <20260307-net-nd_tbl_fixes-v4-0-e2677e85628c@suse.com> To: Martin KaFai Lau , Daniel Borkmann , John Fastabend , Stanislav Fomichev , Alexei Starovoitov , Andrii Nakryiko , Eduard Zingerman , Song Liu , Yonghong Song , KP Singh , Hao Luo , Jiri Olsa , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= , David Ahern , Jay Vosburgh , Andrew Lunn , Hangbin Liu Cc: Fernando Fernandez Mancera , bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Ricardo_B=2E_Marli=C3=A8re?= X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openssh-sha256; t=1772916658; l=2183; i=rbm@suse.com; h=from:subject:message-id; bh=6ZQFRvZdst5dX9ooPrNy2xeyWgmUkbigP/SKL7rpSfM=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgguRCc5X8/UX9M40lkMnr//aFGOhce x5ezt8MFNUFlqYAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QFAMmuB9+HutmVwUmvb/O9FdutNnLHcZjnU2Jh0edZO9SUOTlxUABv8/vgtIANoEqc5Nwx84eFZ jg0AOfjJVqwg= X-Developer-Key: i=rbm@suse.com; a=openssh; fpr=SHA256:pzhe0fJpYLz+3cZ33FFPhIfaUElk9CXPFFXmalIH+1g When booting with the 'ipv6.disable=3D1' parameter, the nd_tbl is never initialized because inet6_init() exits before ndisc_init() is called which initializes it. If bpf_redirect_neigh() is called from tc with an explicit nexthop of nh_family =3D=3D AF_INET6, bpf_out_neigh_v4() takes the AF_INET6 branch and calls ip_neigh_gw6(), which relies on ipv6_stub->nd_tbl. BUG: kernel NULL pointer dereference, address: 0000000000000248 Oops: Oops: 0000 [#1] SMP NOPTI RIP: 0010:skb_do_redirect+0xb93/0xf00 Call Trace: ? srso_alias_return_thunk+0x5/0xfbef5 ? __tcf_classify.constprop.0+0x83/0x160 ? srso_alias_return_thunk+0x5/0xfbef5 ? tcf_classify+0x2b/0x50 ? srso_alias_return_thunk+0x5/0xfbef5 ? tc_run+0xb8/0x120 ? srso_alias_return_thunk+0x5/0xfbef5 __dev_queue_xmit+0x6fa/0x1000 ? srso_alias_return_thunk+0x5/0xfbef5 ? srso_alias_return_thunk+0x5/0xfbef5 ? alloc_skb_with_frags+0x58/0x200 packet_sendmsg+0x10da/0x1700 ? srso_alias_return_thunk+0x5/0xfbef5 __sys_sendto+0x1f3/0x220 __x64_sys_sendto+0x24/0x30 do_syscall_64+0x101/0xf80 ? exc_page_fault+0x6e/0x170 ? srso_alias_return_thunk+0x5/0xfbef5 entry_SYSCALL_64_after_hwframe+0x77/0x7f Fix this by adding an early check in the AF_INET6 branch of bpf_out_neigh_v4(). If IPv6 is disabled, unlock RCU and drop the packet. Suggested-by: Fernando Fernandez Mancera Fixes: ba452c9e996d ("bpf: Fix bpf_redirect_neigh helper api to support sup= plying nexthop") Signed-off-by: Ricardo B. Marli=C3=A8re Acked-by: Daniel Borkmann --- net/core/filter.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/core/filter.c b/net/core/filter.c index 0d5d5a17acb2..ff02dbe4c94f 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -2335,6 +2335,10 @@ static int bpf_out_neigh_v4(struct net *net, struct = sk_buff *skb, =20 neigh =3D ip_neigh_for_gw(rt, skb, &is_v6gw); } else if (nh->nh_family =3D=3D AF_INET6) { + if (unlikely(!ipv6_mod_enabled())) { + rcu_read_unlock(); + goto out_drop; + } neigh =3D ip_neigh_gw6(dev, &nh->ipv6_nh); is_v6gw =3D true; } else if (nh->nh_family =3D=3D AF_INET) { --=20 2.53.0