]> git.baikalelectronics.ru Git - kernel.git/commit
netfilter: xt_hashlimit: fix build error caused by 64bit division
authorVishwanath Pai <vpai@akamai.com>
Fri, 8 Sep 2017 05:38:58 +0000 (01:38 -0400)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 8 Sep 2017 16:55:53 +0000 (18:55 +0200)
commit0a1163d56a6d70d66898f5c336b0dc673ae89a70
tree3d78647f4cf96a1ef30a8169d461cf0a46a86899
parent2289992a208caed9f947a690f4ac6adc2e1c12c1
netfilter: xt_hashlimit: fix build error caused by 64bit division

64bit division causes build/link errors on 32bit architectures. It
prints out error messages like:

ERROR: "__aeabi_uldivmod" [net/netfilter/xt_hashlimit.ko] undefined!

The value of avg passed through by userspace in BYTE mode cannot exceed
U32_MAX. Which means 64bit division in user2rate_bytes is unnecessary.
To fix this I have changed the type of param 'user' to u32.

Since anything greater than U32_MAX is an invalid input we error out in
hashlimit_mt_check_common() when this is the case.

Changes in v2:
Making return type as u32 would cause an overflow for small
values of 'user' (for example 2, 3 etc). To avoid this I bumped up
'r' to u64 again as well as the return type. This is OK since the
variable that stores the result is u64. We still avoid 64bit
division here since 'user' is u32.

Fixes: c2dc8af7fd19 ("netfilter: xt_hashlimit: add rate match mode")
Signed-off-by: Vishwanath Pai <vpai@akamai.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/xt_hashlimit.c