From nobody Thu Apr 9 21:52:49 2026 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (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 0E0AF2F691D for ; Fri, 6 Mar 2026 00:51:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772758281; cv=none; b=ZPKXh80t0x9IAG3vj3dpZTQxOFnS2LNhEayW3cGymhVdVq+hLMr+i5hUyA6woDpp9+lBiHvAqeiHmE1+zAeXmSxExwDpVWJcss9VaEWuaJVsrS4HrvoTqtI5Jl9l6PubQ7YiF6NH54qJ6v0TPwwL01uY68iKIGEmGNL+FvhwHqY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772758281; c=relaxed/simple; bh=rEUuZZA4ANDMcvCg6pyW/UJTRU9oRAre4nZ6TiKNFLg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BpzXu3LX7nNPe2Dhvwpmn8SH0lW/ElB8VBW2ZamZDEHg86uzqbDRyjMU81GeOFm+GJdH3G72KKIGzmDX754arG2d9vjfVwV4H1Nhf4wCudwKoq94P5WyIiKHct4HGbY2BUSC4y57eutFRL/Oi+y9ScRSft1A5TTgLiYNOjMFjFk= 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=ZcvEYh3g; arc=none smtp.client-ip=209.85.221.51 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="ZcvEYh3g" Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-439afc58ac7so5664245f8f.0 for ; Thu, 05 Mar 2026 16:51:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1772758278; x=1773363078; 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=8d5hpiYB7XUuEuXpz7M550s7MAxfMslNPphPrHEEiTQ=; b=ZcvEYh3gLKjlx654lRrOER6D8AZGEZ+xNWN4PakhPqieRawNzRQg8FOHhKmmMwosQq dSXHQWv2yc/banmAyts3YxUSTXf5uqiVG/LXhT/kBFwv0SJxYEDwrAy3SI8gHco0eGgU 0tr0KeJwG1odZHj6MYl6EfpuWsv6C3yuabiA7mJs08jlkR8gjpYJpxgRidZXPlvumyeq i5QeFAal8l2mdopOCzU0sbHMsf7NfSxzXVtO7JDIxtmSlcJvVhAblch+hnXshQfJzNCy CN99e5x/54TYxs/6Lh+nSEzVry+3mEPkUYu5yLSI1R3oNLYQP4mUcA1NzP7TZPNSWZXB tYfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772758278; x=1773363078; 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=8d5hpiYB7XUuEuXpz7M550s7MAxfMslNPphPrHEEiTQ=; b=ddeo6QzuPJkibK+Y6W3mun0NCtzQXD6dE/Hr+NcceEwjg+Nk6PCgt1BpEogZAnSlHp Qn/a6hDSZPTJZPO4hRsEmm5duxJzoqRrZlmYrPC+6TctWnW8fklwq63/3vz/6pOtygBV mu5P6n1bLxDHE245O//8hifH0NwueGEGk6pjO5SDyTl/bpHV72tP9gObRqTeMm/5yyKH IibP9hc3+Yic11bOtPG6M+gJ5OBfFQNbA3U8slEoO1VbKIdT9pADgsTwp4WcHXINx33c m7LjhGW0PmD2CrAL3QFXjui7ujC9DrBAX+0Rj/d4tcPyFsc6qs/4mTAdrUVrm6DjD1mS EcFQ== X-Forwarded-Encrypted: i=1; AJvYcCUTkDSV0NdMvYKM1FUMus+mnNJqm5Z7Y+kg8/DO02l76+oGS9R4e+cDOszwSy6UBIkUJ1BEPubbUJjAXKQ=@vger.kernel.org X-Gm-Message-State: AOJu0YwmXtf7vfGubeiLS9CKZTxnZP7vlCc49neSYIFac2Is2Z0XG7fx XWwQ+wSJ5ZijQchrWs56VpWe3Uml5W7x9HULaoCQyPH15HAaPhtNNWmDZRy5cHXOxrU= X-Gm-Gg: ATEYQzw6Xk5fmgpRmtf1rPp1DOWzNfE56X9jEWGsNkdy7vEcutDF80J+gnP9pwsTMGh IC/D6AOUnWmt5C4VupPT6AcGMYZwrHQNhF3CNX0NDBWZC4GF4sxr0SShmdpgPpLZHVu+79plI2x 5NelXkauHPZ8PKUh4HeBo/Y0sJrtAoTAq+5C5Y5F6YSL6I8WbmTfJuC9Ld6WGqf9NiGTOsdzQSJ Z7X/00XYM8fGL2DMBv+ihnCaxtPQ5pP1/Pvh4ei/ZQw2urSHRbq7bRU/V8qVKALU3f/dsqWh0KN a4cY1EUubLaVrfoF2vida5HBmZPLa+TpXTJwGPsZ/t18bD8c81dhfO2EK1CF9d0seHC8AP+ks0w oz1Yp6XjbEniw5XI4OfpOsSOBYkCI0doC4o55EirZnug75F11QntctWYCgANfSVYzv6HwdESCuW GQLLQj2VWTTkEAH02k/f0p X-Received: by 2002:a05:600c:19d4:b0:477:9eb8:97d2 with SMTP id 5b1f17b1804b1-48526923b15mr3594985e9.8.1772758278421; Thu, 05 Mar 2026 16:51:18 -0800 (PST) Received: from localhost ([189.99.238.164]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-56b087d9e69sm24485e0c.15.2026.03.05.16.51.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Mar 2026 16:51:17 -0800 (PST) From: =?utf-8?q?Ricardo_B=2E_Marli=C3=A8re?= Date: Thu, 05 Mar 2026 18:29:55 -0300 Subject: [PATCH net v3 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-v3-1-fde28b30a744@suse.com> References: <20260305-net-nd_tbl_fixes-v3-0-fde28b30a744@suse.com> In-Reply-To: <20260305-net-nd_tbl_fixes-v3-0-fde28b30a744@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=1772758271; l=2192; i=rbm@suse.com; h=from:subject:message-id; bh=rEUuZZA4ANDMcvCg6pyW/UJTRU9oRAre4nZ6TiKNFLg=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgguRCc5X8/UX9M40lkMnr//aFGOhce x5ezt8MFNUFlqYAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QAqX5xIX1fDdNVLySfgqcNpq8zzpqBUX1kZwOhKrciL3jWWx4RUwsRhbdPvWDdjqg/5lFkWHs9/ RWswQa5VhTQg= 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..4f8ff05c4ec4 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_stub->nd_tbl)) { + 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