Skip to content

Commit c9b3b82

Browse files
arndbummakynes
authored andcommitted
netfilter: nf_flow_table: fix big-endian integer overflow
In some configurations, gcc reports an integer overflow: net/netfilter/nf_flow_table_offload.c: In function 'nf_flow_rule_match': net/netfilter/nf_flow_table_offload.c:80:21: error: unsigned conversion from 'int' to '__be16' {aka 'short unsigned int'} changes value from '327680' to '0' [-Werror=overflow] mask->tcp.flags = TCP_FLAG_RST | TCP_FLAG_FIN; ^~~~~~~~~~~~ From what I can tell, we want the upper 16 bits of these constants, so they need to be shifted in cpu-endian mode. Fixes: c29f74e ("netfilter: nf_flow_table: hardware offload support") Signed-off-by: Arnd Bergmann <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 0fd2600 commit c9b3b82

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/netfilter/nf_flow_table_offload.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ static int nf_flow_rule_match(struct nf_flow_match *match,
8888
switch (tuple->l4proto) {
8989
case IPPROTO_TCP:
9090
key->tcp.flags = 0;
91-
mask->tcp.flags = TCP_FLAG_RST | TCP_FLAG_FIN;
91+
mask->tcp.flags = cpu_to_be16(be32_to_cpu(TCP_FLAG_RST | TCP_FLAG_FIN) >> 16);
9292
match->dissector.used_keys |= BIT(FLOW_DISSECTOR_KEY_TCP);
9393
break;
9494
case IPPROTO_UDP:

0 commit comments

Comments
 (0)