Skip to content

Commit cc5d7da

Browse files
ffmanceragregkh
authored andcommitted
netfilter: nfnetlink_osf: fix mss parsing on big-endian architectures
[ Upstream commit a625c94 ] 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: 11eeef4 ("netfilter: passive OS fingerprint xtables match") Signed-off-by: Fernando Fernandez Mancera <fmancera@suse.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent f38fb17 commit cc5d7da

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

net/netfilter/nfnetlink_osf.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,7 @@ static bool nf_osf_match_one(const struct sk_buff *skb,
9595

9696
switch (*optp) {
9797
case OSFOPT_MSS:
98-
mss = optp[3];
99-
mss <<= 8;
100-
mss |= optp[2];
101-
102-
mss = ntohs((__force __be16)mss);
98+
mss = get_unaligned_be16(&optp[2]);
10399
break;
104100
case OSFOPT_TS:
105101
break;

0 commit comments

Comments
 (0)