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 B37733B05A4; Wed, 30 Sep 2026 18:52:50 +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=1790794371; cv=none; b=sEm8hlZ86kHAlM6yYnIkGpoH5vkb1tPN5gL8p6KKPyhij0XRi9LmszY5U61j/B2awSJtPj1ejTdn7GdIE52pN7EsbN13YIURRJ3a/dQOTtkCr57Z7NqPmvLNDxyinolmVB6Hy+KBS0aYu70PjUPQtbZf4IkPjoXR34kKzaug6Ks= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790794371; c=relaxed/simple; bh=baVaV3GMGeIrsnvPKVLX/sN5d0xP6fX3rwlc7OUGGpA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DB9vFlQ6g4K71ixVXsCY/DObVezUc5HG7UgHnOH09bKyeilL3USrWQ6gXgewYVAn2dQcv+hWjsgqO+Buyw7hvCzcwU0ZkGmoFl37Rqyo28iLGtJY/uWAUqS8lTTvCbK79B741O8aiM2S0/7/+14dOYljU6cnndam/Pbmd2nCrPE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=u+e5x8aU; 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="u+e5x8aU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1556C1F000FF; Wed, 30 Sep 2026 18:52:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790794370; bh=+SYx39045bJs8GuJvDROXodzQPtv2XBeGg7dkh9FD0A=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=u+e5x8aUEcVBl1yxvueBvXbFT1ffMSvDrNxHEkBwwTiXF5SwH+Bj/r5atHtiWND0Q nFhr7CdDV2TMl4zwNcOLpqrzm+K1RVgnBYjq8DoA3LCUU/kAPQC9GEpqxk0G9S0bwh iABNkh4IjznsoLr1f0hBcFi9JUKjkbzSFhIrvoQk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Rosen Penev , Fernando Fernandez Mancera , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 6.6 0186/1193] netfilter: nf_conntrack: use get_unaligned_be32() in tcp_sack() Date: Wed, 30 Sep 2026 17:14:30 +0200 Message-ID: <20260930152438.327256972@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152434.301151190@linuxfoundation.org> References: <20260930152434.301151190@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: Rosen Penev [ Upstream commit d3bf9eae486490832bd08fd62ab0ac601f346bd4 ] The timestamp-only fast path dereferences the option stream as *(__be32 *)ptr, which assumes 4-byte alignment that the TCP option stream does not guarantee. Use get_unaligned_be32() instead, which reads the value safely and already returns host byte order, so the htonl() on the comparison constant can be dropped. This matches the existing get_unaligned_be32() use later in the same function. Assisted-by: Claude:Opus-4.7 Signed-off-by: Rosen Penev Reviewed-by: Fernando Fernandez Mancera Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nf_conntrack_proto_tcp.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c index 2d39421dcf9d8..aaf316c665661 100644 --- a/net/netfilter/nf_conntrack_proto_tcp.c +++ b/net/netfilter/nf_conntrack_proto_tcp.c @@ -405,11 +405,11 @@ static void tcp_sack(const struct sk_buff *skb, unsigned int dataoff, return; /* Fast path for timestamp-only option */ - if (length == TCPOLEN_TSTAMP_ALIGNED - && *(__be32 *)ptr == htonl((TCPOPT_NOP << 24) - | (TCPOPT_NOP << 16) - | (TCPOPT_TIMESTAMP << 8) - | TCPOLEN_TIMESTAMP)) + if (length == TCPOLEN_TSTAMP_ALIGNED && + get_unaligned_be32(ptr) == ((TCPOPT_NOP << 24) | + (TCPOPT_NOP << 16) | + (TCPOPT_TIMESTAMP << 8) | + TCPOLEN_TIMESTAMP)) return; while (length > 0) { -- 2.53.0