From: Jozsef Kadlecsik Date: Wed, 28 Jul 2021 14:06:46 +0000 (+0200) Subject: 64bit division isn't allowed on 32bit, replace it with shift X-Git-Tag: v7.14~1 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=73e5366e2295f009da5ac3fd608dfe8464c795d3;p=thirdparty%2Fipset.git 64bit division isn't allowed on 32bit, replace it with shift The number of hosts in a netblock must be a power of two, so use shift instead of division. Signed-off-by: Jozsef Kadlecsik --- diff --git a/kernel/net/netfilter/ipset/ip_set_hash_ip.c b/kernel/net/netfilter/ipset/ip_set_hash_ip.c index 789b28a4..baa5e14c 100644 --- a/kernel/net/netfilter/ipset/ip_set_hash_ip.c +++ b/kernel/net/netfilter/ipset/ip_set_hash_ip.c @@ -148,7 +148,8 @@ hash_ip4_uadt(struct ip_set *set, struct nlattr *tb[], hosts = h->netmask == 32 ? 1 : 2 << (32 - h->netmask - 1); - if (((u64)ip_to - ip + 1)/hosts > IPSET_MAX_RANGE) + /* 64bit division is not allowed on 32bit */ + if (((u64)ip_to - ip + 1) >> (32 - h->netmask) > IPSET_MAX_RANGE) return -ERANGE; if (retried) {