From mboxrd@z Thu Jan 1 00:00:00 1970 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 7A8553B52E2; Tue, 21 Jul 2026 20:32:22 +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=1784665944; cv=none; b=BRVYqEXZOVTRCUB8fg8fAWY788fowhEMEnz3fdyurNLXrNXv04oRg44VgqE89URIE/UmIKLwXEV0duoMey6E5C3WJpcXEOY3NUfb9eA0qx4tbsughcZixlye+ONQZK5lRpf44QTpx5Kfw/1qmcCK2VfH8moC6ISkX4IhxQd1Cqc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784665944; c=relaxed/simple; bh=MWW96IqA2H7bmE9Axj8bxjlooF5vk73HUPspEbg8bcI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EvFECCKUA4iCPfXC7iajV21+YqzzmNehLgVt5sMXV0EUTntxGFf3gjZ5VsSWmK3lnvitc/jZbPKHD1zJew1G8MRm9/IKC6Nri4jDDwWZ6pcrSyC5LcgKfMIFUeI1iRAuuJ5LN+ET04dDlqd3Eg5b91Rkjvu8XpnvjBsCdVL+Pxg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=P4YdQojF; 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="P4YdQojF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD8DF1F000E9; Tue, 21 Jul 2026 20:32:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784665942; bh=pwaC9f0xx3Aeg7BaqnGVUn7MW4sf3VXxIJsrV4X2CPw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=P4YdQojFD86b9WBwDQ6jFA8LFzn+Yxjuyhlc/FNWI8Oyawep+IzIFXPmENoKOTK1A eXZ/hRTGGtJAlnAr+ruVwaHXtnwbrveUfmQDS4FzRnKVrj59DW1/2fKmKMt005uTul Suu4Qb6y2OTLHDAbpPq6XIzW5WYtjRXy9Rm9kUWk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Fernando Fernandez Mancera , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 6.6 0494/1266] netfilter: synproxy: protect nf_ct_seqadj_init() with conntrack lock Date: Tue, 21 Jul 2026 17:15:31 +0200 Message-ID: <20260721152452.896722284@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152441.786066624@linuxfoundation.org> References: <20260721152441.786066624@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.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Fernando Fernandez Mancera [ Upstream commit 9e37388b8070afe73d4ab2d973b28593ed65f3ad ] nf_ct_seqadj_init() is called without holding the ct lock. This can race with nf_ct_seq_adjust() when a connection is in CLOSE state due to an RST or connection reopening. In addition for SYN_RECV state, concurrent processing of packets can trigger nf_ct_seq_adjust() too. These situations create a read/write data race. As synproxy is the only user of nf_ct_seqadj_init() at the moment, fix this by holding ct->lock inside nf_ct_seqadj_init() until all is done. Fixes: 48b1de4c110a ("netfilter: add SYNPROXY core/target") Signed-off-by: Fernando Fernandez Mancera Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nf_conntrack_seqadj.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/netfilter/nf_conntrack_seqadj.c b/net/netfilter/nf_conntrack_seqadj.c index 7ab2b25b57bcc0..b7e99f34dfce86 100644 --- a/net/netfilter/nf_conntrack_seqadj.c +++ b/net/netfilter/nf_conntrack_seqadj.c @@ -17,12 +17,14 @@ int nf_ct_seqadj_init(struct nf_conn *ct, enum ip_conntrack_info ctinfo, if (off == 0) return 0; + spin_lock_bh(&ct->lock); set_bit(IPS_SEQ_ADJUST_BIT, &ct->status); seqadj = nfct_seqadj(ct); this_way = &seqadj->seq[dir]; this_way->offset_before = off; this_way->offset_after = off; + spin_unlock_bh(&ct->lock); return 0; } EXPORT_SYMBOL_GPL(nf_ct_seqadj_init); -- 2.53.0