Skip to contentSkip to conversation

netfilter: nft_tproxy: Fix port selector on Big Endian

PATCH Applied Phil Sutter 4 participants 7 messages Dec 17, 2019 – Dec 20, 2019

Subsystems (2)
lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

PATCH 1/1 netfilter: nft_tproxy: Fix port selector on Big Endian

On Big Endian architectures, u16 port value was extracted from the wrong parts of u32 sreg_port, just like commit 10596608c4d62 ("netfilter:
nf_tables: fix mismatch in big-endian system") describes.

Fixes 4ed8eb6570a49 ("netfilter: nf_tables: Add native tproxy support")
Cc Máté Eckl <[email protected]>
---
 net/netfilter/nft_tproxy.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nft_tproxy.c +2 -2
index f92a82c738808..95980154ef02c 100644
@@ -50,7 +50,7 @@ static void nft_tproxy_eval_v4(const struct nft_expr *expr,
 	taddr = nf_tproxy_laddr4(skb, taddr, iph->daddr);
 
 	if (priv->sreg_port)
-		tport = regs->data[priv->sreg_port];
+		tport = nft_reg_load16(&regs->data[priv->sreg_port]);
 	if (!tport)
 		tport = hp->dest;
 
@@ -117,7 +117,7 @@ static void nft_tproxy_eval_v6(const struct nft_expr *expr,
 	taddr = *nf_tproxy_laddr6(skb, &taddr, &iph->daddr);
 
 	if (priv->sreg_port)
-		tport = regs->data[priv->sreg_port];
+		tport = nft_reg_load16(&regs->data[priv->sreg_port]);
 	if (!tport)
 		tport = hp->dest;
 
Signature · 1 line
2.24.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 3 lines · Phil Sutter

On Big Endian architectures, u16 port value was extracted from the wrong parts of u32 sreg_port, just like commit 10596608c4d62 ("netfilter:
nf_tables: fix mismatch in big-endian system") describes.

I was about to debug this today, thanks for debugging/fixing this.

author reviewer
#2 lore raw

Hi,

Quoted 6 lines · Florian Westphal
Quoted 3 lines · Phil Sutter

On Big Endian architectures, u16 port value was extracted from the wrong parts of u32 sreg_port, just like commit 10596608c4d62 ("netfilter:
nf_tables: fix mismatch in big-endian system") describes.

I was about to debug this today, thanks for debugging/fixing this.

With that BE machine at hand, I quickly gave nftables testsuite a try - results are a bit concerning: The mere fact that netlink debug output for these immediates differs between BE and LE indicates we don't seriously test on BE.

Cheers, Phil

maintainer
#3 lore raw
Quoted 6 lines · Phil Sutter
Quoted 5 lines · Florian Westphal
Quoted 3 lines · Phil Sutter

On Big Endian architectures, u16 port value was extracted from the wrong parts of u32 sreg_port, just like commit 10596608c4d62 ("netfilter:
nf_tables: fix mismatch in big-endian system") describes.

Quoted 6 lines
Quoted 1 line

I was about to debug this today, thanks for debugging/fixing this.

With that BE machine at hand, I quickly gave nftables testsuite a try - results are a bit concerning: The mere fact that netlink debug output for these immediates differs between BE and LE indicates we don't seriously test on BE.

Yes, I fear we will need to add extra .be test files with big-endian output.

Alternative is to unify debug output in libnftnl to always print in host byte order, but thats not going to be easy because we don't know if the immediate value is in network or host byte order.

#4 lore raw
Quoted 14 lines · Florian Westphal
Quoted 6 lines · Phil Sutter
Quoted 5 lines · Florian Westphal
Quoted 3 lines · Phil Sutter

On Big Endian architectures, u16 port value was extracted from the wrong parts of u32 sreg_port, just like commit 10596608c4d62 ("netfilter:
nf_tables: fix mismatch in big-endian system") describes.

Quoted 6 lines
Quoted 1 line

I was about to debug this today, thanks for debugging/fixing this.

With that BE machine at hand, I quickly gave nftables testsuite a try - results are a bit concerning: The mere fact that netlink debug output for these immediates differs between BE and LE indicates we don't seriously test on BE.

Quoted 6 lines

Yes, I fear we will need to add extra .be test files with big-endian output.

Alternative is to unify debug output in libnftnl to always print in host byte order, but thats not going to be easy because we don't know if the immediate value is in network or host byte order.

The byteorder information is available in libnftables, so we can probably move the print function there.

Acked-by on v1 1/1
#5 lore raw
In reply to Phil Sutter
Quoted 8 lines · Phil Sutter

On Big Endian architectures, u16 port value was extracted from the wrong parts of u32 sreg_port, just like commit 10596608c4d62 ("netfilter:
nf_tables: fix mismatch in big-endian system") describes.

Fixes 4ed8eb6570a49 ("netfilter: nf_tables: Add native tproxy support")
Cc Máté Eckl <[email protected]>

---

Thanks for the fix! This was out of my sight.

maintainer Applied
#6 lore raw
In reply to Phil Sutter
Quoted 3 lines · Phil Sutter

On Big Endian architectures, u16 port value was extracted from the wrong parts of u32 sreg_port, just like commit 10596608c4d62 ("netfilter:
nf_tables: fix mismatch in big-endian system") describes.

Applied, thanks.