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>] [day] [month] [year] [list]
Date:   Thu, 6 Oct 2022 16:20:31 +0300
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     "Jason A. Donenfeld" <Jason@...c4.com>
Cc:     Jason Gunthorpe <jgg@...pe.ca>, linux-kernel@...r.kernel.org,
        brcm80211-dev-list.pdl@...adcom.com, cake@...ts.bufferbloat.net,
        ceph-devel@...r.kernel.org, coreteam@...filter.org,
        dccp@...r.kernel.org, dev@...nvswitch.org,
        dmaengine@...r.kernel.org, drbd-dev@...ts.linbit.com,
        dri-devel@...ts.freedesktop.org, kasan-dev@...glegroups.com,
        linux-actions@...ts.infradead.org,
        linux-arm-kernel@...ts.infradead.org, linux-block@...r.kernel.org,
        linux-crypto@...r.kernel.org, linux-doc@...r.kernel.org,
        linux-ext4@...r.kernel.org, linux-f2fs-devel@...ts.sourceforge.net,
        linux-fbdev@...r.kernel.org, linux-fsdevel@...r.kernel.org,
        linux-hams@...r.kernel.org, linux-media@...r.kernel.org,
        linux-mm@...ck.org, linux-mmc@...r.kernel.org,
        linux-mtd@...ts.infradead.org, linux-nfs@...r.kernel.org,
        linux-nvme@...ts.infradead.org, linux-raid@...r.kernel.org,
        linux-rdma@...r.kernel.org, linux-scsi@...r.kernel.org,
        linux-sctp@...r.kernel.org,
        linux-stm32@...md-mailman.stormreply.com,
        linux-usb@...r.kernel.org, linux-wireless@...r.kernel.org,
        linux-xfs@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org,
        lvs-devel@...r.kernel.org, netdev@...r.kernel.org,
        netfilter-devel@...r.kernel.org, rds-devel@....oracle.com,
        SHA-cyfmac-dev-list@...ineon.com, target-devel@...r.kernel.org,
        tipc-discussion@...ts.sourceforge.net
Subject: Re: [PATCH v1 3/5] treewide: use get_random_u32() when possible

On Thu, Oct 06, 2022 at 07:05:48AM -0600, Jason A. Donenfeld wrote:
> On Thu, Oct 6, 2022 at 6:47 AM Jason Gunthorpe <jgg@...pe.ca> wrote:
> > On Wed, Oct 05, 2022 at 11:48:42PM +0200, Jason A. Donenfeld wrote:

...

> > > -     u32 isn = (prandom_u32() & ~7UL) - 1;
> > > +     u32 isn = (get_random_u32() & ~7UL) - 1;
> >
> > Maybe this wants to be written as
> >
> > (prandom_max(U32_MAX >> 7) << 7) | 7

> > ?
> 
> Holy smokes. Yea I guess maybe? It doesn't exactly gain anything or
> make the code clearer though, and is a little bit more magical than
> I'd like on a first pass.

Shouldn't the two first 7s to be 3s?

...

> > > -     psn = prandom_u32() & 0xffffff;
> > > +     psn = get_random_u32() & 0xffffff;
> >
> >  prandom_max(0xffffff + 1)
> 
> That'd work, but again it's not more clear. Authors here are going for
> a 24-bit number, and masking seems like a clear way to express that.

We have some 24-bit APIs (and 48-bit) already in kernel, why not to have
get_random_u24() ?


-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ