* Re: [PATCH v1 0/5] treewide cleanup of random integer usage
[not found] <20221005214844.2699-1-Jason@zx2c4.com>
@ 2022-10-06 6:15 ` Kees Cook
2022-10-06 12:58 ` Jason A. Donenfeld
2022-10-06 8:17 ` Yann Droneaud
1 sibling, 1 reply; 3+ messages in thread
From: Kees Cook @ 2022-10-06 6:15 UTC (permalink / raw)
To: Jason A. Donenfeld; +Cc: linux-kernel, netdev, linux-api
On Wed, Oct 05, 2022 at 11:48:39PM +0200, Jason A. Donenfeld wrote:
> I've CC'd get_maintainers.pl, which is a pretty big list. Probably some
> portion of those are going to bounce, too, and everytime you reply to
The real problem is that replies may not reach the vger lists:
Subject: BOUNCE linux-kernel@vger.kernel.org: Header field too long (>8192)
But the originals somehow ended up on lore?
https://lore.kernel.org/lkml/20221005214844.2699-1-Jason@zx2c4.com/
--
Kees Cook
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1 0/5] treewide cleanup of random integer usage
[not found] <20221005214844.2699-1-Jason@zx2c4.com>
2022-10-06 6:15 ` [PATCH v1 0/5] treewide cleanup of random integer usage Kees Cook
@ 2022-10-06 8:17 ` Yann Droneaud
1 sibling, 0 replies; 3+ messages in thread
From: Yann Droneaud @ 2022-10-06 8:17 UTC (permalink / raw)
To: Jason A. Donenfeld
Cc: Jason A. Donenfeld, linux-crypto, linux-doc, kernel-janitors,
Julia Lawall, Nicolas Palix, linux-api, linux-kernel
Hi,
6 octobre 2022 à 04:51 "Jason A. Donenfeld" a écrit:
>
> This is a five part treewide cleanup of random integer handling. The
> rules for random integers are:
>
> - If you want a secure or an insecure random u64, use get_random_u64().
> - If you want a secure or an insecure random u32, use get_random_u32().
> * The old function prandom_u32() has been deprecated for a while now
> and is just a wrapper around get_random_u32().
> - If you want a secure or an insecure random u16, use get_random_u16().
> - If you want a secure or an insecure random u8, use get_random_u8().
> - If you want secure or insecure random bytes, use get_random_bytes().
> * The old function prandom_bytes() has been deprecated for a while now
> and has long been a wrapper around get_random_bytes().
> - If you want a non-uniform random u32, u16, or u8 bounded by a certain
> open interval maximum, use prandom_u32_max().
> * I say "non-uniform", because it doesn't do any rejection sampling or
> divisions. Hence, it stays within the prandom_* namespace.
>
> These rules ought to be applied uniformly, so that we can clean up the
> deprecated functions, and earn the benefits of using the modern
> functions. In particular, in addition to the boring substitutions, this
> patchset accomplishes a few nice effects:
>
> - By using prandom_u32_max() with an upper-bound that the compiler can
> prove at compile-time is ≤65536 or ≤256, internally get_random_u16()
> or get_random_u8() is used, which wastes fewer batched random bytes,
> and hence has higher throughput.
>
> - By using prandom_u32_max() instead of %, when the upper-bound is not a
> constant, division is still avoided, because prandom_u32_max() uses
> a faster multiplication-based trick instead.
>
> - By using get_random_u16() or get_random_u8() in cases where the return
> value is intended to indeed be a u16 or a u8, we waste fewer batched
> random bytes, and hence have higher throughput.
>
> So, based on those rules and benefits from following them, this patchset
> breaks down into the following five steps:
>
> 1) Replace `prandom_u32() % max` and variants thereof with
> prandom_u32_max(max).
>
> 2) Replace `(type)get_random_u32()` and variants thereof with
> get_random_u16() or get_random_u8(). I took the pains to actually
> look and see what every lvalue type was across the entire tree.
>
> 3) Replace remaining deprecated uses of prandom_u32() with
> get_random_u32().
>
> 4) Replace remaining deprecated uses of prandom_bytes() with
> get_random_bytes().
>
> 5) Remove the deprecated and now-unused prandom_u32() and
> prandom_bytes() inline wrapper functions.
>
Did you use some coccinelle patches ? Or other semantic patch tool ?
Maybe we could introduce some coccinelle patch to ensure future get_random_u{16,32,64} usages be checked and patched to use the best fit.
Regards.
--
Yann Droneaud
OPTEYA
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1 0/5] treewide cleanup of random integer usage
2022-10-06 6:15 ` [PATCH v1 0/5] treewide cleanup of random integer usage Kees Cook
@ 2022-10-06 12:58 ` Jason A. Donenfeld
0 siblings, 0 replies; 3+ messages in thread
From: Jason A. Donenfeld @ 2022-10-06 12:58 UTC (permalink / raw)
To: Kees Cook; +Cc: linux-kernel, netdev, linux-api
On Thu, Oct 6, 2022 at 12:15 AM Kees Cook <keescook@chromium.org> wrote:
>
> On Wed, Oct 05, 2022 at 11:48:39PM +0200, Jason A. Donenfeld wrote:
> > I've CC'd get_maintainers.pl, which is a pretty big list. Probably some
> > portion of those are going to bounce, too, and everytime you reply to
>
> The real problem is that replies may not reach the vger lists:
>
> Subject: BOUNCE linux-kernel@vger.kernel.org: Header field too long (>8192)
>
> But the originals somehow ended up on lore?
>
> https://lore.kernel.org/lkml/20221005214844.2699-1-Jason@zx2c4.com/
Heh, those aren't quite the originals. Same message IDs, but I did
evil things to get them on there.
v2 coming shortly to rectify this mess.
Jason
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-10-06 12:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20221005214844.2699-1-Jason@zx2c4.com>
2022-10-06 6:15 ` [PATCH v1 0/5] treewide cleanup of random integer usage Kees Cook
2022-10-06 12:58 ` Jason A. Donenfeld
2022-10-06 8:17 ` Yann Droneaud
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).