Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752519AbdIFUYQ (ORCPT ); Wed, 6 Sep 2017 16:24:16 -0400 Received: from mx0b-00190b01.pphosted.com ([67.231.157.127]:34894 "EHLO mx0b-00190b01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752058AbdIFUYO (ORCPT ); Wed, 6 Sep 2017 16:24:14 -0400 Subject: Re: [PATCH] netfilter: xt_hashlimit: avoid 64-bit division To: Arnd Bergmann , Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , "David S. Miller" Cc: Josh Hunt , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <20170906195825.3715290-1-arnd@arndb.de> From: Vishwanath Pai Message-ID: <7791dee1-64a9-dcaa-c5d9-0b04a44bc526@akamai.com> Date: Wed, 6 Sep 2017 16:22:30 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <20170906195825.3715290-1-arnd@arndb.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-09-06_06:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1709060291 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-09-06_06:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1709060292 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1494 Lines: 44 On 09/06/2017 03:57 PM, Arnd Bergmann wrote: > 64-bit division is expensive on 32-bit architectures, and > requires a special function call to avoid a link error like: > > net/netfilter/xt_hashlimit.o: In function `hashlimit_mt_common': > xt_hashlimit.c:(.text+0x1328): undefined reference to `__aeabi_uldivmod' > > In the case of hashlimit_mt_common, we don't actually need a > 64-bit operation, we can simply rewrite the function slightly > to make that clear to the compiler. > > Fixes: bea74641e378 ("netfilter: xt_hashlimit: add rate match mode") > Signed-off-by: Arnd Bergmann > --- > net/netfilter/xt_hashlimit.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c > index 10d48234f5f4..50b53d86eef5 100644 > --- a/net/netfilter/xt_hashlimit.c > +++ b/net/netfilter/xt_hashlimit.c > @@ -531,7 +531,10 @@ static u64 user2rate_bytes(u64 user) > { > u64 r; > > - r = user ? 0xFFFFFFFFULL / user : 0xFFFFFFFFULL; > + if (user > 0xFFFFFFFFULL) > + return 0; > + > + r = user ? 0xFFFFFFFFULL / (u32)user : 0xFFFFFFFFULL; > r = (r - 1) << 4; > return r; > } > I have submitted another patch to fix this: https://patchwork.ozlabs.org/patch/809881/ We have seen this problem before, I was careful not to introduce this again in the new patch but clearly I overlooked this particular line :( In the other cases we fixed it by replacing division with div64_u64(). -Vishwanath