Re: [PATCH v6 3/7] treewide: use get_random_{u8,u16}() when possible, part 1

2022-10-10 Thread Jason A. Donenfeld
On Tue, Oct 11, 2022 at 01:18:40AM +, Elliott, Robert (Servers) wrote: > > > diff --git a/crypto/testmgr.c b/crypto/testmgr.c > ... > > @@ -944,7 +944,7 @@ static void generate_random_bytes(u8 *buf, size_t count) > > default: > > /* Fully random bytes */ > > for (i

RE: [PATCH v6 3/7] treewide: use get_random_{u8,u16}() when possible, part 1

2022-10-10 Thread Elliott, Robert (Servers)
> diff --git a/crypto/testmgr.c b/crypto/testmgr.c ... > @@ -944,7 +944,7 @@ static void generate_random_bytes(u8 *buf, size_t count) > default: > /* Fully random bytes */ > for (i = 0; i < count; i++) > - buf[i] = (u8)prandom_u32(); > +

[PATCH v6 7/7] prandom: remove unused functions

2022-10-10 Thread Jason A. Donenfeld
With no callers left of prandom_u32() and prandom_bytes(), as well as get_random_int(), remove these deprecated wrappers, in favor of get_random_u32() and get_random_bytes(). Reviewed-by: Greg Kroah-Hartman Reviewed-by: Kees Cook Reviewed-by: Yury Norov Signed-off-by: Jason A. Donenfeld --- d

[PATCH v6 6/7] treewide: use get_random_bytes() when possible

2022-10-10 Thread Jason A. Donenfeld
The prandom_bytes() function has been a deprecated inline wrapper around get_random_bytes() for several releases now, and compiles down to the exact same code. Replace the deprecated wrapper with a direct call to the real function. This was done as a basic find and replace. Reviewed-by: Greg Kroah

[PATCH v6 5/7] treewide: use get_random_u32() when possible

2022-10-10 Thread Jason A. Donenfeld
The prandom_u32() function has been a deprecated inline wrapper around get_random_u32() for several releases now, and compiles down to the exact same code. Replace the deprecated wrapper with a direct call to the real function. The same also applies to get_random_int(), which is just a wrapper arou

[PATCH v6 4/7] treewide: use get_random_{u8,u16}() when possible, part 2

2022-10-10 Thread Jason A. Donenfeld
Rather than truncate a 32-bit value to a 16-bit value or an 8-bit value, simply use the get_random_{u8,u16}() functions, which are faster than wasting the additional bytes from a 32-bit value. This was done by hand, identifying all of the places where one of the random integer functions was used in

[PATCH v6 3/7] treewide: use get_random_{u8,u16}() when possible, part 1

2022-10-10 Thread Jason A. Donenfeld
Rather than truncate a 32-bit value to a 16-bit value or an 8-bit value, simply use the get_random_{u8,u16}() functions, which are faster than wasting the additional bytes from a 32-bit value. This was done mechanically with this coccinelle script: @@ expression E; identifier get_random_u32 =~ "ge

[PATCH v6 2/7] treewide: use prandom_u32_max() when possible, part 2

2022-10-10 Thread Jason A. Donenfeld
Rather than incurring a division or requesting too many random bytes for the given range, use the prandom_u32_max() function, which only takes the minimum required bytes from the RNG and avoids divisions. This was done by hand, covering things that coccinelle could not do on its own. Reviewed-by:

[PATCH v6 1/7] treewide: use prandom_u32_max() when possible, part 1

2022-10-10 Thread Jason A. Donenfeld
Rather than incurring a division or requesting too many random bytes for the given range, use the prandom_u32_max() function, which only takes the minimum required bytes from the RNG and avoids divisions. This was done mechanically with this coccinelle script: @basic@ expression E; type T; identif

[PATCH v6 0/7] treewide cleanup of random integer usage

2022-10-10 Thread Jason A. Donenfeld
Changes v5->v6: - Added a few missing conversions that weren't in my older tree, so now this should be ready to go, as well as a couple nits people had from v5. Barring something large and unforeseen, this is the "final version", as this is ready to ship. Thanks to everyone who reviewed thi