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 B115243D4E8; Tue, 16 Jun 2026 18:41:18 +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=1781635279; cv=none; b=Fubs/H7UepLAfMHhG00ChTAWxV+3/fCudtaqEnd4NBt/UdVMnOGMtWAREr2DZDd2r7JSC6wZI3r6/SIwBSfDVj1nP1f7MfMnG2EllZj1ftIv2AdE8Gt/lXZi1V2aFSUnmtSJIGd33WWBSSRLEtTj8gBFw7pFH9JLAC/sELQZHQQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781635279; c=relaxed/simple; bh=bqFqZm5fJlGjrRneRDWC7pz5UUUXcpJiC00DeMVLeLc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iR6NBDAOBt1QH+ufoUi1d9SwT8kK0UMhgpt53zqpKbc817eO8Xd8aCLpKJmwBGgVqi2aKuGR+08vDxwIrDzvAXH9aQydq+sSxFZy2Jw7ZXOh+l6oc/JxiuoACZx5HlOgSMqy3Cgsqycbg7+QLeVotnOrhwgZbAjgCI/fHqMZTwk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ASL5mS/G; 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="ASL5mS/G" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70C561F000E9; Tue, 16 Jun 2026 18:41:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781635278; bh=iwhPl6ItE0GytUbc8ConOvq+GK7wlhvmhs38hhN+Vzc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ASL5mS/G0WckNP/iGnmuQVAaxCSox4xJzcVh+GsU7eSFYmhiKVhnfq4s6gnxiIFvQ BxwdaxKYw8ATGLdF3JyGU1ppbqDAP2rpasNCbRNoQceHN352JzdaiRTJxfezlu4RB2 +g11hF11zIRh7U1sIbinv6KRHQJRkfGrLr6H854Q= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Chris Mason , Fernando Fernandez Mancera , Florian Westphal , Sasha Levin Subject: [PATCH 5.10 011/342] netfilter: synproxy: refresh tcphdr after skb_ensure_writable Date: Tue, 16 Jun 2026 20:25:07 +0530 Message-ID: <20260616145048.836075104@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145048.348037099@linuxfoundation.org> References: <20260616145048.348037099@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: Chris Mason [ Upstream commit 92170e6afe927ab2792a3f71902845789c8e31b1 ] synproxy_tstamp_adjust() rewrites the TCP timestamp option in place and then patches the TCP checksum via inet_proto_csum_replace4() on the caller-supplied tcphdr pointer. Both ipv4_synproxy_hook() and ipv6_synproxy_hook() obtain that pointer with skb_header_pointer() before calling in, so it may either alias skb->head directly or point at the caller's on-stack _tcph buffer. Between obtaining the pointer and using it, the function calls skb_ensure_writable(skb, optend), which on a cloned or non-linear skb invokes pskb_expand_head() and frees the old skb->head. After that point the cached th is stale: caller (ipv[46]_synproxy_hook) th = skb_header_pointer(skb, ..., &_tcph) synproxy_tstamp_adjust(skb, protoff, th, ...) skb_ensure_writable(skb, optend) pskb_expand_head() /* kfree(old skb->head) */ ... inet_proto_csum_replace4(&th->check, ...) /* writes into freed head, or into the caller's stack copy leaving the on-wire checksum stale */ The option bytes are written through skb->data and are fine; only the checksum update goes through th and so lands in the wrong place. The result is either a write into freed slab memory or a packet leaving with a checksum that does not match its payload. Fix by re-deriving th from skb->data + protoff immediately after skb_ensure_writable() succeeds, so the subsequent checksum update targets the linear, writable header. Fixes: 48b1de4c110a ("netfilter: add SYNPROXY core/target") Assisted-by: kres (claude-opus-4-7) Signed-off-by: Chris Mason Reviewed-by: Fernando Fernandez Mancera Signed-off-by: Florian Westphal Signed-off-by: Sasha Levin --- net/netfilter/nf_synproxy_core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/netfilter/nf_synproxy_core.c b/net/netfilter/nf_synproxy_core.c index 2dfc5dae065638..0a97b1a0f53e45 100644 --- a/net/netfilter/nf_synproxy_core.c +++ b/net/netfilter/nf_synproxy_core.c @@ -199,6 +199,8 @@ synproxy_tstamp_adjust(struct sk_buff *skb, unsigned int protoff, if (skb_ensure_writable(skb, optend)) return 0; + th = (struct tcphdr *)(skb->data + protoff); + while (optoff < optend) { unsigned char *op = skb->data + optoff; -- 2.53.0