Re: [PATCH] netfilter: nf_conntrack: use get_unaligned_be32() in tcp_sack()

From: Fernando Fernandez Mancera

Date: Mon May 25 2026 - 18:35:42 EST


On 5/25/26 11:58 PM, Rosen Penev wrote:
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 <rosenp@xxxxxxxxx>
I already spotted this corner case when working on a SYNPROXY patch [1] but didn't send a patch yet. I think this is for correctness too.

Anyway, it is likely that there are more places where this tweak is needed.. I will look around.. meanwhile:

Reviewed-by: Fernando Fernandez Mancera <fmancera@xxxxxxx>

[1] lore.kernel.org/netfilter-devel/20260525124450.6043-4-fmancera@xxxxxxx/