From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 5817E332621; Mon, 13 Apr 2026 16:57:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776099442; cv=none; b=T4O172n/0f528u4W1oAVBdpo/d4Ci4Zc1IRHR6o6M1eF9esqySZe367hHBC8jPO89iGxXiXUhCF52993kxzzZqLZ1M+Dr9FSc6vBYzRyhCnkP76wO0KyKgs7e+Ma6V3S4NcrOSbZwKcOoJzsdZlnCUMdXIcKDlm4FHT70WZvzM8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776099442; c=relaxed/simple; bh=M1m9Gq0GkKBo6XP8y2HGSOaZ5fbQ8x3SridUWdWW5aE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IO/9ONKXU8Oe+imK/gMSyX/82AHHCCzzzfMQqK+5Cwui4o8TLTaOQjwlqE4layVX+FcMvhpJYKEaDpfOLhQukGFSOmAOW3I8pSpVjsYla/FeLdxBb1JXWnlWIJD3GHbQjwKISEkttvZZ31bK+BS59h47U6O2Y5k+9GzXfdBfIkA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=XClEGc1F; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="XClEGc1F" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3143C2BCAF; Mon, 13 Apr 2026 16:57:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1776099442; bh=M1m9Gq0GkKBo6XP8y2HGSOaZ5fbQ8x3SridUWdWW5aE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XClEGc1FYF6VquA80zrC1n7jbQx0mEczU0uxhcsiYfi6GiPEWEFzI1UryqClAa5dJ +yupOwtAEfNjUzBvA4mP9dW1TLDO9WX6UGa0VndpuQ7QqdEy8VlTZXGCV/oU9cuVQF zBvNwF+T2q94QfLK4xFuEsRGm00uGB86OP8HfcQg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, kernel test robot , Qi Tang , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 5.10 341/491] netfilter: ctnetlink: zero expect NAT fields when CTA_EXPECT_NAT absent Date: Mon, 13 Apr 2026 17:59:46 +0200 Message-ID: <20260413155831.806285285@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260413155819.042779211@linuxfoundation.org> References: <20260413155819.042779211@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 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Qi Tang [ Upstream commit 35177c6877134a21315f37d57a5577846225623e ] ctnetlink_alloc_expect() allocates expectations from a non-zeroing slab cache via nf_ct_expect_alloc(). When CTA_EXPECT_NAT is not present in the netlink message, saved_addr and saved_proto are never initialized. Stale data from a previous slab occupant can then be dumped to userspace by ctnetlink_exp_dump_expect(), which checks these fields to decide whether to emit CTA_EXPECT_NAT. The safe sibling nf_ct_expect_init(), used by the packet path, explicitly zeroes these fields. Zero saved_addr, saved_proto and dir in the else branch, guarded by IS_ENABLED(CONFIG_NF_NAT) since these fields only exist when NAT is enabled. Confirmed by priming the expect slab with NAT-bearing expectations, freeing them, creating a new expectation without CTA_EXPECT_NAT, and observing that the ctnetlink dump emits a spurious CTA_EXPECT_NAT containing stale data from the prior allocation. Fixes: 076a0ca02644 ("netfilter: ctnetlink: add NAT support for expectations") Reported-by: kernel test robot Signed-off-by: Qi Tang Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nf_conntrack_netlink.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c index 8d35e17a0f7e7..befc9d2bc0b52 100644 --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c @@ -3568,6 +3568,12 @@ ctnetlink_alloc_expect(const struct nlattr * const cda[], struct nf_conn *ct, exp, nf_ct_l3num(ct)); if (err < 0) goto err_out; +#if IS_ENABLED(CONFIG_NF_NAT) + } else { + memset(&exp->saved_addr, 0, sizeof(exp->saved_addr)); + memset(&exp->saved_proto, 0, sizeof(exp->saved_proto)); + exp->dir = 0; +#endif } return exp; err_out: -- 2.53.0