linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Ingo Molnar <mingo@kernel.org>,
	Igor Lubashev <ilubashe@akamai.com>,
	Josh Hunt <johunt@akamai.com>, Vishwanath Pai <vpai@akamai.com>,
	Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Borislav Petkov <bp@alien8.de>, Andy Lutomirski <luto@kernel.org>,
	"the arch/x86 maintainers" <x86@kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Brian Gerst <brgerst@gmail.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Juergen Gross <jgross@suse.com>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	Kees Cook <keescook@chromium.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	"David S. Miller" <davem@davemloft.net>
Subject: xt_hashlimig build error (was Re: [RFC 01/17] x86/asm/64: Remove the restore_c_regs_and_iret label)
Date: Thu, 7 Sep 2017 10:51:21 -0700	[thread overview]
Message-ID: <CA+55aFznorYJd8OyV09eHt4zrRrrv2aEq_D=Q8k2w+CmgJ=+cw@mail.gmail.com> (raw)

On Thu, Sep 7, 2017 at 3:29 AM, Ingo Molnar <mingo@kernel.org> wrote:
>
> not the best of kernels, 32-bit allyesconfig doesn't even appear to build:
>
>   net/netfilter/xt_hashlimit.o: In function `hashlimit_mt_common.isra.6':
>   xt_hashlimit.c:(.text+0x1146): undefined reference to `__udivdi3'

I think this is due to commit bea74641e378 ("netfilter: xt_hashlimit:
add rate match mode").

It adds a 64-bit divide in user2rate_bytes() afaik, and to make things
worse it seems to be a really stupid one too.

Although I guess "worse" is not bad when the stupidity of it should
mean that it's easy to avoid the 64-bit issue.

Oddly, user2rate() that actually *does* need a 64-bit divide, seems to
do it right and use "div64_u64()" to do so.

But user2rate_bytes() could easily avoid any 64-bit issues, since it
divides the max 32-bit (unsigned) number with a 64-bit unsigned
number.

It would be easy to just say

 - "if high 32 bits are set, result is 0"

 - else do a 32-bit divide

or just use "div64_u64()" in that code too.

But honestly, that math is odd in other ways too (is that "r-1"
_supposed_ to underflow to -1 for large 'user' counts?), so somebody
needs to look at that logic.

And there might be some other 64-bit divide I missed, so please,
netfilter people, check the 32-bit build.

                  Linus

             reply	other threads:[~2017-09-07 17:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-07 17:51 Linus Torvalds [this message]
2017-09-07 18:25 ` xt_hashlimig build error (was Re: [RFC 01/17] x86/asm/64: Remove the restore_c_regs_and_iret label) Vishwanath Pai
2017-09-07 18:43   ` Linus Torvalds
2017-09-07 20:16     ` Vishwanath Pai
2017-09-07 20:41       ` Lubashev, Igor
2017-09-07 20:45       ` Linus Torvalds
2017-09-07 21:21         ` Vishwanath Pai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA+55aFznorYJd8OyV09eHt4zrRrrv2aEq_D=Q8k2w+CmgJ=+cw@mail.gmail.com' \
    --to=torvalds@linux-foundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=andrew.cooper3@citrix.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=bp@alien8.de \
    --cc=brgerst@gmail.com \
    --cc=davem@davemloft.net \
    --cc=ilubashe@akamai.com \
    --cc=jgross@suse.com \
    --cc=johunt@akamai.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@kernel.org \
    --cc=pablo@netfilter.org \
    --cc=vpai@akamai.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).