linux-stable/drivers/char
Jason A. Donenfeld 7f576b2593 random: add helpers for random numbers with given floor or range
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_inclusive(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.

Cc: stable@vger.kernel.org # to ease future backports that use this api
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2022-11-18 02:15:12 +01:00
..
agp IOMMU Updates for Linux v5.20/v6.0: 2022-08-06 10:42:38 -07:00
hw_random hwrng: bcm2835 - use hwrng_msleep() instead of cpu_relax() 2022-10-14 19:03:09 +08:00
ipmi Fix a bunch of little problems in IPMI 2022-10-11 10:42:25 -07:00
mwave char/mwave: Adjust io port register size 2021-12-03 14:27:06 +01:00
pcmcia tty: Make ->set_termios() old ktermios const 2022-08-30 14:22:35 +02:00
tpm tpmdd updates for Linux v6.1-rc1 2022-10-10 13:09:33 -07:00
xilinx_hwicap xilinx_hwicap: cleanup comments 2022-02-25 12:08:57 +01:00
xillybus char: xillybus: fix a refcount leak in cleanup_dev() 2022-04-24 17:30:45 +02:00
Kconfig Char / Misc driver changes for 6.0-rc1 2022-08-04 11:05:48 -07:00
Makefile char: remove VR41XX related char driver 2022-07-28 16:12:33 +02:00
adi.c
apm-emulation.c apm-emulation: drop unexpected word "the" in the comments 2022-06-27 16:15:27 +02:00
applicom.c applicom: unneed to initialise statics to 0 2021-12-21 10:14:08 +01:00
applicom.h
bsr.c powerpc/BSR: Make use of the helper macro LIST_HEAD() 2022-02-25 12:10:15 +01:00
ds1620.c
dsp56k.c
dtlk.c
hangcheck-timer.c
hpet.c hpet: remove unused writeq/readq function definitions 2022-02-04 16:45:39 +01:00
lp.c char: lp: remove redundant initialization of err 2022-06-10 15:29:50 +02:00
mem.c random: restore O_NONBLOCK support 2022-09-23 12:27:57 +02:00
misc.c char: misc: remove usage of list iterator past the loop body 2022-04-24 17:15:12 +02:00
mspec.c
nsc_gpio.c
nvram.c
nwbutton.c
nwbutton.h
nwflash.c
pc8736x_gpio.c
powernv-op-panel.c powerpc/powernv: Fix fall-through warning for Clang 2021-07-13 19:21:41 -05:00
ppdev.c
ps3flash.c
random.c random: add helpers for random numbers with given floor or range 2022-11-18 02:15:12 +01:00
scx200_gpio.c
sonypi.c
tlclk.c
toshiba.c
ttyprintk.c char: ttyprintk: register console 2022-04-22 16:24:47 +02:00
uv_mmtimer.c
virtio_console.c Char/Misc and other driver updates for 5.18-rc1 2022-03-28 12:27:35 -07:00