]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
netfilter: nfnetlink_osf: fix mss parsing on big-endian architectures
authorFernando Fernandez Mancera <fmancera@suse.de>
Mon, 25 May 2026 15:35:54 +0000 (17:35 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 5 Jun 2026 11:11:54 +0000 (13:11 +0200)
The MSS calculation in nf_osf_match_one() manually shifts bytes to
construct a 16-bit value before passing it to ntohs().

This works on little-endian hosts but it does not work on big-endian as
the bytes are being always shifted and set in the same way for all
architectures.

Use get_unaligned_be16() to fix this on big-endian systems. It also
simplifies the code.

Fixes: 11eeef41d5f6 ("netfilter: passive OS fingerprint xtables match")
Signed-off-by: Fernando Fernandez Mancera <fmancera@suse.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nfnetlink_osf.c

index acb753ec5697a5bd989ab5ac0265efe04a0bf01c..92002079f8eab60b07a8e2c2e9737809aaa96168 100644 (file)
@@ -95,11 +95,7 @@ static bool nf_osf_match_one(const struct sk_buff *skb,
 
                        switch (*optp) {
                        case OSFOPT_MSS:
-                               mss = optp[3];
-                               mss <<= 8;
-                               mss |= optp[2];
-
-                               mss = ntohs((__force __be16)mss);
+                               mss = get_unaligned_be16(&optp[2]);
                                break;
                        case OSFOPT_TS:
                                break;