From nobody Sat Jul 25 20:47:09 2026 Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) (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 F17D4335BB4 for ; Mon, 13 Jul 2026 18:36:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783967779; cv=none; b=QF6s8CQcVtMzdoEm+hY0jrn/eaI+8fU5fI/nGrrPMxStO5HWOgh4hdToorFYiVx7uR79Sx2Dj5Xc0QmRXXYN3dpS/1RaRM14Q7+YehYTJ6taAxkVMFCOcK//HBERSdw/OK3da7KqW09ooVYlq9ssqru0bS6psHSBHGO+cYqU9Rs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783967779; c=relaxed/simple; bh=d/eeuVxUleGy31a88wNlioaq+/dr9+CAscc3aVXlqtU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=coXQ3/8wnE0krSM4vWsH4f8h5JTRT88MQMeLPv01pYbEBWE4byT4BBhvy7i9XJ12RoB+l9LsW30DfM+SdBVDO60AAuBpkqwZjtphOCD+sFGAnifstx3E2C569zaceECoJYxDS8Rss7Wm+0K1Oy3HAgNvzxowVkqcaZVzj16VKNQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=asu.edu; spf=pass smtp.mailfrom=asu.edu; dkim=pass (2048-bit key) header.d=asu.edu header.i=@asu.edu header.b=RQO22JJc; arc=none smtp.client-ip=209.85.215.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=asu.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=asu.edu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=asu.edu header.i=@asu.edu header.b="RQO22JJc" Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-c9d1fc053e0so112318a12.1 for ; Mon, 13 Jul 2026 11:36:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=asu.edu; s=google; t=1783967776; x=1784572576; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=83OFQaO++E4joRubEA/Dmu6J46o8fWIq9Xk8WKWgSek=; b=RQO22JJcAOciRBggMdebttFd6CWL9ajvG3P2sX2yJ4HWTzVDEXm4PRsQJ/PhrTgDra I6Bx/cJbSQLTS+Sj+77bAlq+XkoCl68ja+wJDzIXRPgriFgG4Hw4iczGt1hINt5NRQbp Hec7Z0cMCR1nkapiXP/DnpuqHxdJlJAdkG4lg2Pz4yP/hNs46ntEQEpaHog088ZvpCjr EAAKcPXNVKqwIJd5yqLGHG7CuyANC1s9GZ4OJpTIAHjSlbZ6/n6MrQT9xdmvLIkm5umP SPYqCO/oSSmpTEPkLX+Tq+rYa1vubcVPw1ZuwUIqARqEeEROLtuRoI1LpgrKwBRK9GML ASXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783967776; x=1784572576; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=83OFQaO++E4joRubEA/Dmu6J46o8fWIq9Xk8WKWgSek=; b=dFd/1CeVVkICBjRwrydVN+UejW4dxo69/AX6JtiEXm1Ie22sXgPP0np57C7CjA0NIU 4prgyAg/iW445KaWJ5qiWvXd73ry8uQebMQ2Wp9xVdRsSHCRmNyZ4Q+NT/yLlVdO/YYf SGeY2JuzZpLVy8JHE59kB+ZTbfW8E29OsjE5ZGcDGmZQ1aAje9jrfO+mO8q6mZtO2uO1 HscVCzO2GZMTTsTSZcdqKtJEGSnMFCkRGAdWHkjnnbGzsWb2MXdEtIi2JBprmFBjE7yr B5jN1T77q1YfHlYos+f8Jit5oYFjSEcd4uUJMtry6knuKegOtY963I/0h6vBaNYLZ2fw i4YA== X-Forwarded-Encrypted: i=1; AHgh+RqbmkZ4PY0bHsWhNwG3YL2DeEtWUT6kHHI0na/E3RoPKB4prHGRkX7GIQWjia01pqsbdia/JDg/wGQK76s=@vger.kernel.org X-Gm-Message-State: AOJu0Yz0b9Oadfr6lB2SKTDFqOi3Ovfgpcx9XXsr+IWw9kaI9VmvyzGH G9i2VUDpFghZ0ki/evDW1g9Xxw+pqPDLg2LgNH4thvEEL1Ibo54VuTLe2FdQ18jFmQ== X-Gm-Gg: AfdE7ckktwXaKeWZ9aTZ466WdV3xDKPn4sJvNJFaQzv9aJMAXOVN0n5f9uVbmMQJ6+j 7A+BnJy6LwmcxKVzVIfYhTEKn5eXfzjuLcf3TvYmZ0rsieTe0Gy9GpO0Y334HZuJ9Mxu9ROEUvk VDom4reueEwYHb02IM1tZcjPBiE3RX2TNsUiAhGUu2/0BFd+nAkPQ5NKXYqP7Cgyq7+77NVXR4z bNxhDWGAjcb7DqQyua97imOZHMWDANV0DNz5H3j+js+gOdteZ8/lvyUjXXTwM2O+jEH9ViDvOYt NH3U1OspCERsPuYwCaiFCeQToFIRKiNnO28nSk4RPo2BOw+Qa/flc7t84vcV+wdX0CTMelef6NL 5D+VJcqsOPaYHPFWP1CT5uqUSE0HwGxDUx3UJ68ZZlqlVACR+A7460yj9909d4sTxA/5ZVa+jxd PqKV0LN61mpi9dUNxrfw== X-Received: by 2002:a05:6a21:1798:b0:3bf:6237:b1b3 with SMTP id adf61e73a8af0-3c110775a71mr10882651637.42.1783967776314; Mon, 13 Jul 2026 11:36:16 -0700 (PDT) Received: from xiang.tailc0aff1.ts.net ([20.171.14.70]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3118389d9bcsm61616034eec.20.2026.07.13.11.36.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2026 11:36:15 -0700 (PDT) From: "Xiang Mei (Microsoft)" To: Florian Westphal , Pablo Neira Ayuso , Phil Sutter , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, AutonomousCodeSecurity@microsoft.com, tgopinath@linux.microsoft.com, kys@microsoft.com, "Xiang Mei (Microsoft)" Subject: [PATCH nf] netfilter: nft_fib: bail out if input device is missing Date: Mon, 13 Jul 2026 18:36:14 +0000 Message-ID: <20260713183614.2975972-1-xmei5@asu.edu> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" nft_fib_can_skip() dereferences the input device (indev->ifindex, and in->flags via nft_fib_is_loopback()) without a NULL check, assuming the hook switch only admits PRE_ROUTING/INGRESS/LOCAL_IN. But NF_NETDEV_EGRESS =3D=3D NF_INET_LOCAL_IN =3D=3D 1, so a netdev-family base chain on the egre= ss hook passes both the switch and nft_fib_validate() (which also keys only on the hook number). Egress packets have no input device, so nft_fib_can_skip() dereferences NULL. KASAN: null-ptr-deref in range [0x00000000000000b0-0x00000000000000b7] RIP: 0010:nft_fib4_eval (net/netfilter/nft_fib.h:19) nft_do_chain (net/netfilter/nf_tables_core.c:285) nft_do_chain_netdev (net/netfilter/nft_chain_filter.c:307) nf_hook_slow (net/netfilter/core.c:619) __dev_queue_xmit (net/core/dev.c:4799) ... Kernel panic - not syncing: Fatal exception in interrupt The eval path touched the device only via l3mdev_master_ifindex_rcu(), which tolerates NULL, until commit eaaff9b6702e ("netfilter: fib: avoid lookup if socket is available") added the sk/indev dereference. Restore the old behaviour by returning early when indev is NULL, so the packet takes the regular FIB lookup. Receive-side hooks always have an input device and are unaffected. Fixes: eaaff9b6702e ("netfilter: fib: avoid lookup if socket is available") Reported-by: AutonomousCodeSecurity@microsoft.com Signed-off-by: Xiang Mei (Microsoft) --- include/net/netfilter/nft_fib.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/net/netfilter/nft_fib.h b/include/net/netfilter/nft_fi= b.h index e0422456f27b..d53e5a5214fe 100644 --- a/include/net/netfilter/nft_fib.h +++ b/include/net/netfilter/nft_fib.h @@ -33,6 +33,9 @@ static inline bool nft_fib_can_skip(const struct nft_pkti= nfo *pkt) return false; } =20 + if (!indev) + return false; + sk =3D pkt->skb->sk; if (sk && sk_fullsock(sk)) return sk->sk_rx_dst_ifindex =3D=3D indev->ifindex; --=20 2.43.0