lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMuHMdUpQ1h5gapkzoX191hgxSQ814TfwcuPAmm8hOKSwk0RHA@mail.gmail.com>
Date:   Fri, 24 Apr 2020 19:54:47 +0200
From:   Geert Uytterhoeven <geert@...ux-m68k.org>
To:     Toke Høiland-Jørgensen <toke@...hat.com>
Cc:     Eric Dumazet <eric.dumazet@...il.com>,
        Pravin B Shelar <pshelar@....org>,
        "David S . Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        Tonghao Zhang <xiangxia.m.yue@...il.com>,
        netdev <netdev@...r.kernel.org>, dev@...nvswitch.org,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] net: openvswitch: use do_div() for 64-by-32 divisions:

Hi Toke,

On Fri, Apr 24, 2020 at 6:45 PM Toke Høiland-Jørgensen <toke@...hat.com> wrote:
> Geert Uytterhoeven <geert@...ux-m68k.org> writes:
> > On Fri, Apr 24, 2020 at 5:05 PM Eric Dumazet <eric.dumazet@...il.com> wrote:
> >> On 4/24/20 5:10 AM, Geert Uytterhoeven wrote:
> >> > On 32-bit architectures (e.g. m68k):
> >> >
> >> >     ERROR: modpost: "__udivdi3" [net/openvswitch/openvswitch.ko] undefined!
> >> >     ERROR: modpost: "__divdi3" [net/openvswitch/openvswitch.ko] undefined!
> >> >
> >> > Fixes: e57358873bb5d6ca ("net: openvswitch: use u64 for meter bucket")
> >> > Reported-by: noreply@...erman.id.au
> >> > Signed-off-by: Geert Uytterhoeven <geert@...ux-m68k.org>
> >> > ---
> >> >  net/openvswitch/meter.c | 2 +-
> >> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >> >
> >> > diff --git a/net/openvswitch/meter.c b/net/openvswitch/meter.c
> >> > index 915f31123f235c03..3498a5ab092ab2b8 100644
> >> > --- a/net/openvswitch/meter.c
> >> > +++ b/net/openvswitch/meter.c
> >> > @@ -393,7 +393,7 @@ static struct dp_meter *dp_meter_create(struct nlattr **a)
> >> >                * Start with a full bucket.
> >> >                */
> >> >               band->bucket = (band->burst_size + band->rate) * 1000ULL;
> >> > -             band_max_delta_t = band->bucket / band->rate;
> >> > +             band_max_delta_t = do_div(band->bucket, band->rate);
> >> >               if (band_max_delta_t > meter->max_delta_t)
> >> >                       meter->max_delta_t = band_max_delta_t;
> >> >               band++;
> >> >
> >>
> >> This is fascinating... Have you tested this patch ?
> >
> > Sorry, I should have said this is compile-tested only.
> >
> >> Please double check what do_div() return value is supposed to be !
> >
> > I do not have any openvswitch setups, let alone on the poor m68k box.
>
> I think what Eric is referring to is this, from the documentation of
> do_div:
>
>  * do_div - returns 2 values: calculate remainder and update new dividend
>  * @n: uint64_t dividend (will be updated)
>  * @base: uint32_t divisor
>  *
>  * Summary:
>  * ``uint32_t remainder = n % base;``
>  * ``n = n / base;``
>  *
>  * Return: (uint32_t)remainder

Oops, that was a serious brain fart. Sorry for that!

That should have been div_u64() instead of do_div().
Feel free to update my patch while applying, else I'll send a v2 later.

/me hides in a brown paper bag for the whole weekend...

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ