Skip to contentSkip to conversation

netfilter: nat: fix icmp id endianness when protocol mapping was given

PATCH In review Florian Westphal 2 participants 2 messages Apr 13, 2019

Subsystems (2)
lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 netfilter: nat: fix icmp id endianness when protocol mapping was given

net/netfilter/nf_nat_core.c:422:29: sparse: incorrect type in assignment (different base types)
net/netfilter/nf_nat_core.c:422:29: expected unsigned int [unsigned] [assigned] min
net/netfilter/nf_nat_core.c:422:29: got restricted __be16 const [usertype] id

The warning is correct, this needs ntohs treatment.

Fixes 203f2e78200c27e ("netfilter: nat: remove l4proto->unique_tuple")

---
Pablo, feel free to squash this with commit 57be8a51f2a8ba390f7c5a03d2ae812a1b39c9bb ("netfilter: nat: fix icmp id randomization"), it touched this area already (and moved the faulty line to its current place).

 net/netfilter/nf_nat_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nf_nat_core.c +1 -1
index f79f77d6850b..000952719adf 100644
@@ -419,7 +419,7 @@ static void nf_nat_l4proto_unique_tuple(struct nf_conntrack_tuple *tuple,
 			min = 0;
 			range_size = 65536;
 		} else {
-			min = range->min_proto.icmp.id;
+			min = ntohs(range->min_proto.icmp.id);
 			range_size = ntohs(range->max_proto.icmp.id) -
 				     ntohs(range->min_proto.icmp.id) + 1;
 		}
Signature · 1 line
2.21.0
#1 lore raw
Quoted 6 lines · Florian Westphal

net/netfilter/nf_nat_core.c:422:29: sparse: incorrect type in assignment (different base types)
net/netfilter/nf_nat_core.c:422:29: expected unsigned int [unsigned] [assigned] min
net/netfilter/nf_nat_core.c:422:29: got restricted __be16 const [usertype] id

The warning is correct, this needs ntohs treatment.

Quoted 7 lines
Fixes 203f2e78200c27e ("netfilter: nat: remove l4proto->unique_tuple")

---
Pablo, feel free to squash this with commit 57be8a51f2a8ba390f7c5a03d2ae812a1b39c9bb ("netfilter: nat: fix icmp id randomization"), it touched this area already (and moved the faulty line to its current place).

I have collapsed it as suggested. Thanks.