[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20201022122534.5a700251@kicinski-fedora-PC1C0HJN.hsd1.ca.comcast.net>
Date: Thu, 22 Oct 2020 12:25:34 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Eric Dumazet <edumazet@...gle.com>
Cc: Ke Li <keli@...mai.com>, netdev <netdev@...r.kernel.org>,
David Miller <davem@...emloft.net>, kli@...l.edu,
Ji Li <jli@...mai.com>
Subject: Re: [PATCH net v2] net: Properly typecast int values to set
sk_max_pacing_rate
On Thu, 22 Oct 2020 09:48:48 +0200 Eric Dumazet wrote:
> On Thu, Oct 22, 2020 at 8:42 AM Ke Li <keli@...mai.com> wrote:
> >
> > In setsockopt(SO_MAX_PACING_RATE) on 64bit systems, sk_max_pacing_rate,
> > after extended from 'u32' to 'unsigned long', takes unintentionally
> > hiked value whenever assigned from an 'int' value with MSB=1, due to
> > binary sign extension in promoting s32 to u64, e.g. 0x80000000 becomes
> > 0xFFFFFFFF80000000.
> >
> > Thus inflated sk_max_pacing_rate causes subsequent getsockopt to return
> > ~0U unexpectedly. It may also result in increased pacing rate.
> >
> > Fix by explicitly casting the 'int' value to 'unsigned int' before
> > assigning it to sk_max_pacing_rate, for zero extension to happen.
> >
> > Fixes: 76a9ebe811fb ("net: extend sk_pacing_rate to unsigned long")
> > Signed-off-by: Ji Li <jli@...mai.com>
> > Signed-off-by: Ke Li <keli@...mai.com>
> > Cc: Eric Dumazet <edumazet@...gle.com>
> > ---
> > v2: wrap the line in net/core/filter.c to less than 80 chars.
>
> SGTM (the other version was also fine, the 80 chars rule has been
> relaxed/changed to 100 recently)
We went from old guidelines, to unclear guidelines, IDK which one is
worse :( Here the way the ternary expression was wrapping in a 80 char
window looked way less readable, so I thought I'd request a reformat.
> Reviewed-by: Eric Dumazet <edumazet@...gle.com>
Applied, thanks everyone!
Powered by blists - more mailing lists