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] [day] [month] [year] [list]
Message-ID: <202211171347.92FDE65A6D@keescook>
Date:   Thu, 17 Nov 2022 13:48:14 -0800
From:   Kees Cook <keescook@...omium.org>
To:     "Jason A. Donenfeld" <Jason@...c4.com>
Cc:     linux-kernel@...r.kernel.org, tytso@....edu, kees@...nel.org,
        linux@...linux.org.uk, ydroneaud@...eya.com,
        gregkh@...uxfoundation.org, rdunlap@...radead.org
Subject: Re: [PATCH v3] random: add helpers for random numbers with given
 floor or range

On Thu, Nov 17, 2022 at 08:26:20PM +0100, Jason A. Donenfeld wrote:
> Now that we have get_random_u32_below(), it's nearly trivial to make
> inline helpers to compute get_random_u32_above() and
> get_random_u32_inclusive(), which will help clean up open coded loops
> and manual computations throughout the tree.
> 
> One snag is that in order to make get_random_u32_inclusive() operate on
> closed intervals, we have to do some (unlikely) special case handling if
> get_random_u32_interval(0, U32_MAX) is called. The least expensive way
> of doing this is actually to adjust the slowpath of
> get_random_u32_below() to have its undefined 0 result just return the
> output of get_random_u32(). We can make this basically free by calling
> get_random_u32() before the branch, so that the branch latency gets
> interleaved.
> 
> Signed-off-by: Jason A. Donenfeld <Jason@...c4.com>

I really like these -- unambiguous! :) Thanks for adjusting this API.

Reviewed-by: Kees Cook <keescook@...omium.org>

-Kees

-- 
Kees Cook

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ