From nobody Thu Apr 9 21:52:43 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 99AF33446B2 for ; Thu, 5 Mar 2026 20:37:50 +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=1772743072; cv=none; b=Nyx9r9XtzKz+HhkILxSX9f75oApSYWFGmvcc2l/wYbCeTA/j2hXbUzZyzzkaqIrtVjGy6cRs35TOlpksrluXk0VfsRUSYlc7aMzzRCFApkoRLcKslqzU2Nm0MngPmQt9Uj13f4X/4ar3oHWKXoPelBenNSmFH++UgKuquuPvRPw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772743072; c=relaxed/simple; bh=Yfucwf5JHvyU/znf9S6sDQrRZ/qy3di3N5iSoXWL4aM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=L+aFixu7YwqSRWyFd940slT8W0skNw1I/hla6oZa65cmd/Wz9ixbx4A0veeYQo9jS3qJ6vdOJnNxCAH+84p4Ayni6+Kk6aggpyq08Fhw1uF3toHjpYhufBC99expIGT29ws0ADQfbA99dHlVb3zm2Oaxm1hfKwZy0ISBKQ+XHM4= 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=OwYnViCU; 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="OwYnViCU" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-48371119eacso100302625e9.2 for ; Thu, 05 Mar 2026 12:37:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1772743069; x=1773347869; 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=6qqlYUk2uLknCELv6zwONHG5x3atJmpFah5PNZJ3m1g=; b=OwYnViCUQd7q/FhqXzjz9Q8r4KoWEKZa/1pt39UHCDDILvlIgm+PK7qqo4Vlen4XXy 2Z4rIFVx1DOj9kRtPCN5wbKFjxEjqzoEUuJ02KGLheB21r9V2LomJqBSr4mn0Qs3IIJx F3MTZCV6eeSc/fCcHPeWyoRYGbcTd3LUNPkTwOk/FhKGWMD2xwyJQUysJhI86E+ts30Z QbJ/dlzu4aSatL9iHEdQwfCLLuSFPLLC+25n5Ll6PItYogwGRsFzBPTz/8Rr6A/IVVd0 oX3WdG94wBeovCVbLngT+x2pFaAU2/mrlK4mXyDzkEx5O685ylrzRTzqFMOJ3oMficqx Gotw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772743069; x=1773347869; 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=6qqlYUk2uLknCELv6zwONHG5x3atJmpFah5PNZJ3m1g=; b=wXosQwRuB/4RcJ38/xLkbXr0jkMZaoVek8D/tANCdZX34IAqV02Cn08bOYYFp+XhSj 00g5nfLG8znPmnSblrTMX7cY2mdu/yMHJNln06xZaxsN/jW5iL6ViibU1fHjBDyMBr+R RSf18JYaN6FfbFCr7xp06I9IFIF2ALV+HTQypvBw0o/OWphX/RzS4RCcBoAZmSix4FEM 1TRvtfQoXThd+FaRY/Kx94us+26euKbdu8/I+/bXNdQl5wH5kpj9LxpCnhTLHun7vs5d wLpxalMZenpVbzcIIe79j4M9TOc/rQ5FjKd/gJ+X2Tog6J9nXemi7cOY7Qtjlk6p7aNz qBiA== X-Forwarded-Encrypted: i=1; AJvYcCXtGBPoBmGPUCcUVcf+TNkz+eL3vlKCIEzaCWMI5iT/x/ZSmRqz6yJ1wt/ioUCS4q9YGygRxTgxzDjTHI8=@vger.kernel.org X-Gm-Message-State: AOJu0YwRsOMwwNXhz0dy3J9P+8d02eQQLH63c7y1U+zwC3CvHHFvMVIG Wwv6cJFTKYxmB2UcH2QgOyX3uGlrr7O2IoRQngxgDi93y2/EU5wZMQ2oSwVsyRd07AE= X-Gm-Gg: ATEYQzyO9Em0GgkqUNjskgh86lw1L2mDghI8UqiEScJWsE1HnSQeMoSJZ+qpodPd/MY bIzW+VyvRqNhEWyowHsCKQhzJqAW/997K4Q3SoLEF5WhMdCs3dYkpH0b6VRDK0gPBofEUgwJ1J9 8fZpf7z2R4DrVijmYrNKNqREEBPN6TVp9GgEIwAMljIKjjsPPAD50EtLCmPiQrVmUQ4Ygbykfdd mguFndLX33U6VJfsqB7prLnwI7IMZD7mchCEiEGcy63pzl97ywDZWKh6APxvesRkWmoclbhnjYc Fm2dxlPOt8iGh68IZNiCX0+u+gU9zw66xiI8dW4045GoYNkG2nI1qh2t07PtczQLE+5nm+o11P9 ejh2SoCkxKyl+ZAgt25ARbRS11Ryq2DeNeUDcNu3IF+TZtVgslctMhlPrXS8WyG8i9n1MDN+eig PX3isTrPnStw== X-Received: by 2002:a05:600c:3f10:b0:483:b01c:9508 with SMTP id 5b1f17b1804b1-485235a78d8mr14649615e9.2.1772743068926; Thu, 05 Mar 2026 12:37:48 -0800 (PST) Received: from localhost ([189.99.238.164]) by smtp.gmail.com with ESMTPSA id ada2fe7eead31-5ffce11d29dsm2610413137.7.2026.03.05.12.37.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Mar 2026 12:37:48 -0800 (PST) From: =?utf-8?q?Ricardo_B=2E_Marli=C3=A8re?= Date: Thu, 05 Mar 2026 17:37:39 -0300 Subject: [PATCH net v2 1/3] 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: <20260305-net-nd_tbl_fixes-v2-1-b7177db1a9f3@suse.com> References: <20260305-net-nd_tbl_fixes-v2-0-b7177db1a9f3@suse.com> In-Reply-To: <20260305-net-nd_tbl_fixes-v2-0-b7177db1a9f3@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=1772743062; l=2193; i=rbm@suse.com; h=from:subject:message-id; bh=Yfucwf5JHvyU/znf9S6sDQrRZ/qy3di3N5iSoXWL4aM=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgguRCc5X8/UX9M40lkMnr//aFGOhce x5ezt8MFNUFlqYAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QELA4fZ8Uu1G8uhu9+u3KMAefcDUWGgV/dwgvshG/ifXp0EaQKOUYgVehq7+ApJEY+ASGkfwf7P bFe0OGSXMmgI= 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_stub->nd_tbl is NULL, 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 --- 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