Skip to contentSkip to conversation

netfilter: nfnetlink_osf: fix mss parsing on big-endian architectures

PATCH New Fernando Fernandez Mancera 1 participant 1 message May 25

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netfilter: nfnetlink_osf: fix mss parsing on big-endian architectures

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")

---
Note: the nf queue is already busy.. it does not make sense to queue this there IMHO, let's aim this to nf-next.

---
 net/netfilter/nfnetlink_osf.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
net/netfilter/nfnetlink_osf.c +1 -5
index acb753ec5697..92002079f8ea 100644
@@ -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;
Signature · 1 line
2.53.0