Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 656AE471253; Tue, 21 Jul 2026 18:28:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784658517; cv=none; b=F074LO6sv8MnAjqs05A6oVPCcVCKO864sglydRutuZOcPKCvvL5/pqGdn5rT4SX/ObA9v8WEEGUE9/BTrlY3WO8QzTQfjrxB68+s5T76ZgspxvPGH1qxcxCHmnnD6aJ3TkzfIkm7HwY9aA2WBJgFwAi4sm6CWJKgBsOi4NWYgt8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784658517; c=relaxed/simple; bh=uIWp/5jTjiD3EcsxMYmJF/rE/uDSUbjIIqWo/j4E1u0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ADjGAN8hzZhQDl9wWvHRhvxKQeTN+02XLGzM7xQc87SE5kCv9h1UvFAx87dBzQ/eOO269FbeeKt33uL8KLBCAMzx6jX3c+v4i2k5mtgC2Jl53EI+18AF6rcC2bu+JeBzKA+z9nYeKDClgNi1e/HLKzLVFlXAod/sFmKg7C0heYg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=LTIwshcd; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="LTIwshcd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D3BC1F000E9; Tue, 21 Jul 2026 18:28:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784658516; bh=DQ3BDbsxuuNkZc7WfU6gZelJ1f3Rz2I2eG/Spy0WH6I=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=LTIwshcdH5q6QrAJisHGf3zMtWC7DjxxBO48nrPiAor21oWS8hOjBrgOf5+9lBnym zBw0pivFDr/uTZHlH/9pEQuqND7S9ppNd4ZOxd+oODJXo7Cfnfkdep9X1NFheCm8Ag z3iTO/n45mb9zYG5g5dc/zWE9nODUis8GqiPKNyg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yuan Tan , Yifan Wu , Juefei Pu , Zhengchuan Liang , Xin Liu , Wyatt Feng , Ren Wei , Florian Westphal Subject: [PATCH 6.18 1174/1611] netfilter: xt_nat: reject unsupported target families Date: Tue, 21 Jul 2026 17:21:30 +0200 Message-ID: <20260721152541.837402756@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152514.750365251@linuxfoundation.org> References: <20260721152514.750365251@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Wyatt Feng commit 5d1a2240935ea47e2673d0ea17fdb058e4dc91dd upstream. xt_nat SNAT and DNAT target handlers assume IP-family conntrack state is present and can dereference a NULL pointer when instantiated from an unsupported family through nft_compat. A bridge-family compat rule can therefore trigger a NULL-dereference in nf_nat_setup_info(). Reject non-IP families in xt_nat_checkentry() so unsupported targets cannot be installed. Keep NFPROTO_INET allowed for valid inet NAT compat users and leave the runtime fast path unchanged. [ The crash was fixed via 9dbba7e694ec ("netfilter: nft_compat: ebtables emulation must reject non-bridge targets"), so this patch is no longer critical. Nevertheless, NAT is only relevant for ipv4/ipv6, so this extra family check is a good idea in any case. ] Fixes: c7232c9979cb ("netfilter: add protocol independent NAT core") Cc: stable@vger.kernel.org Reported-by: Yuan Tan Reported-by: Yifan Wu Reported-by: Juefei Pu Reported-by: Zhengchuan Liang Reported-by: Xin Liu Assisted-by: Codex:GPT-5.4 Signed-off-by: Wyatt Feng Signed-off-by: Ren Wei Signed-off-by: Florian Westphal Signed-off-by: Greg Kroah-Hartman --- net/netfilter/xt_nat.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/net/netfilter/xt_nat.c +++ b/net/netfilter/xt_nat.c @@ -26,6 +26,15 @@ static int xt_nat_checkentry_v0(const st static int xt_nat_checkentry(const struct xt_tgchk_param *par) { + switch (par->family) { + case NFPROTO_IPV4: + case NFPROTO_IPV6: + case NFPROTO_INET: + break; + default: + return -EINVAL; + } + return nf_ct_netns_get(par->net, par->family); }