<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/drivers/char/random.c, branch v6.1.2</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v6.1.2</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v6.1.2'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2022-10-28T22:24:03+00:00</updated>
<entry>
<title>random: use arch_get_random*_early() in random_init()</title>
<updated>2022-10-28T22:24:03+00:00</updated>
<author>
<name>Jean-Philippe Brucker</name>
<email>jean-philippe@linaro.org</email>
</author>
<published>2022-10-28T16:00:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=f5e4ec155d145002fd9840868453d785fab86d42'/>
<id>urn:sha1:f5e4ec155d145002fd9840868453d785fab86d42</id>
<content type='text'>
While reworking the archrandom handling, commit d349ab99eec7 ("random:
handle archrandom with multiple longs") switched to the non-early
archrandom helpers in random_init(), which broke initialization of the
entropy pool from the arm64 random generator.

Indeed at that point the arm64 CPU features, which verify that all CPUs
have compatible capabilities, are not finalized so arch_get_random_seed_longs()
is unsuccessful. Instead random_init() should use the _early functions,
which check only the boot CPU on arm64. On other architectures the
_early functions directly call the normal ones.

Fixes: d349ab99eec7 ("random: handle archrandom with multiple longs")
Cc: stable@vger.kernel.org
Signed-off-by: Jean-Philippe Brucker &lt;jean-philippe@linaro.org&gt;
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>prandom: remove unused functions</title>
<updated>2022-10-11T23:42:58+00:00</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2022-10-05T15:50:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=de492c83cae0af72de370b9404aacda93dafcad5'/>
<id>urn:sha1:de492c83cae0af72de370b9404aacda93dafcad5</id>
<content type='text'>
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 &lt;gregkh@linuxfoundation.org&gt;
Reviewed-by: Kees Cook &lt;keescook@chromium.org&gt;
Reviewed-by: Yury Norov &lt;yury.norov@gmail.com&gt;
Acked-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>random: clear new batches when bringing new CPUs online</title>
<updated>2022-10-06T15:35:55+00:00</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2022-10-05T10:54:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=a890d1c657ecba73a7b28591c92587aef1be1888'/>
<id>urn:sha1:a890d1c657ecba73a7b28591c92587aef1be1888</id>
<content type='text'>
The commit that added the new get_random_{u8,u16}() functions neglected
to update the code that clears the batches when bringing up a new CPU.
It also forgot a few comments and helper defines, so add those in too.

Fixes: 585cd5fe9f73 ("random: add 8-bit and 16-bit batches")
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>random: fix typos in get_random_bytes() comment</title>
<updated>2022-10-01T21:37:51+00:00</updated>
<author>
<name>William Zijl</name>
<email>postmaster@gusted.xyz</email>
</author>
<published>2022-10-01T15:36:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=d687772e6d2cbffd91fdda64812f79192c1e7ca0'/>
<id>urn:sha1:d687772e6d2cbffd91fdda64812f79192c1e7ca0</id>
<content type='text'>
Remove extra whitespace and add a missing word to a sentence describing
get_random_bytes().

Signed-off-by: William Zijl &lt;postmaster@gusted.xyz&gt;
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>random: schedule jitter credit for next jiffy, not in two jiffies</title>
<updated>2022-10-01T10:04:21+00:00</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2022-09-30T22:31:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=122733471384be8c23f019fbbd46bdf7be561dcd'/>
<id>urn:sha1:122733471384be8c23f019fbbd46bdf7be561dcd</id>
<content type='text'>
Counterintuitively, mod_timer(..., jiffies + 1) will cause the timer to
fire not in the next jiffy, but in two jiffies. The way to cause
the timer to fire in the next jiffy is with mod_timer(..., jiffies).
Doing so then lets us bump the upper bound back up again.

Fixes: 50ee7529ec45 ("random: try to actively add entropy rather than passively wait for it")
Fixes: 829d680e82a9 ("random: cap jitter samples per bit to factor of HZ")
Cc: Dominik Brodowski &lt;linux@dominikbrodowski.net&gt;
Cc: Sebastian Andrzej Siewior &lt;bigeasy@linutronix.de&gt;
Cc: Sultan Alsawaf &lt;sultan@kerneltoast.com&gt;
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>random: add 8-bit and 16-bit batches</title>
<updated>2022-09-29T19:37:27+00:00</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2022-09-28T16:47:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=585cd5fe9f7378601b1d4915ad6e9088333b5e5e'/>
<id>urn:sha1:585cd5fe9f7378601b1d4915ad6e9088333b5e5e</id>
<content type='text'>
There are numerous places in the kernel that would be sped up by having
smaller batches. Currently those callsites do `get_random_u32() &amp; 0xff`
or similar. Since these are pretty spread out, and will require patches
to multiple different trees, let's get ahead of the curve and lay the
foundation for `get_random_u8()` and `get_random_u16()`, so that it's
then possible to start submitting conversion patches leisurely.

Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>random: use init_utsname() instead of utsname()</title>
<updated>2022-09-29T19:37:27+00:00</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2022-09-27T09:26:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=dd54fd7dfa4574fe350b75a90693dc6552c535e3'/>
<id>urn:sha1:dd54fd7dfa4574fe350b75a90693dc6552c535e3</id>
<content type='text'>
Rather than going through the current-&gt; indirection for utsname, at this
point in boot, init_utsname()==utsname(), so just use it directly that
way. Additionally, init_utsname() appears to be available nearly always,
so move it into random_init_early().

Suggested-by: Kees Cook &lt;keescook@chromium.org&gt;
Reviewed-by: Kees Cook &lt;keescook@chromium.org&gt;
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>random: split initialization into early step and later step</title>
<updated>2022-09-29T19:36:27+00:00</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2022-09-26T15:43:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=f62384995e4cb7703e5295779c44135c5311770d'/>
<id>urn:sha1:f62384995e4cb7703e5295779c44135c5311770d</id>
<content type='text'>
The full RNG initialization relies on some timestamps, made possible
with initialization functions like time_init() and timekeeping_init().
However, these are only available rather late in initialization.
Meanwhile, other things, such as memory allocator functions, make use of
the RNG much earlier.

So split RNG initialization into two phases. We can provide arch
randomness very early on, and then later, after timekeeping and such are
available, initialize the rest.

This ensures that, for example, slabs are properly randomized if RDRAND
is available. Without this, CONFIG_SLAB_FREELIST_RANDOM=y loses a degree
of its security, because its random seed is potentially deterministic,
since it hasn't yet incorporated RDRAND. It also makes it possible to
use a better seed in kfence, which currently relies on only the cycle
counter.

Another positive consequence is that on systems with RDRAND, running
with CONFIG_WARN_ALL_UNSEEDED_RANDOM=y results in no warnings at all.

One subtle side effect of this change is that on systems with no RDRAND,
RDTSC is now only queried by random_init() once, committing the moment
of the function call, instead of multiple times as before. This is
intentional, as the multiple RDTSCs in a loop before weren't
accomplishing very much, with jitter being better provided by
try_to_generate_entropy(). Plus, filling blocks with RDTSC is still
being done in extract_entropy(), which is necessarily called before
random bytes are served anyway.

Cc: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Reviewed-by: Kees Cook &lt;keescook@chromium.org&gt;
Reviewed-by: Dominik Brodowski &lt;linux@dominikbrodowski.net&gt;
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>random: use expired timer rather than wq for mixing fast pool</title>
<updated>2022-09-28T16:17:53+00:00</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2022-09-22T16:46:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=748bc4dd9e663f23448d8ad7e58c011a67ea1eca'/>
<id>urn:sha1:748bc4dd9e663f23448d8ad7e58c011a67ea1eca</id>
<content type='text'>
Previously, the fast pool was dumped into the main pool periodically in
the fast pool's hard IRQ handler. This worked fine and there weren't
problems with it, until RT came around. Since RT converts spinlocks into
sleeping locks, problems cropped up. Rather than switching to raw
spinlocks, the RT developers preferred we make the transformation from
originally doing:

    do_some_stuff()
    spin_lock()
    do_some_other_stuff()
    spin_unlock()

to doing:

    do_some_stuff()
    queue_work_on(some_other_stuff_worker)

This is an ordinary pattern done all over the kernel. However, Sherry
noticed a 10% performance regression in qperf TCP over a 40gbps
InfiniBand card. Quoting her message:

&gt; MT27500 Family [ConnectX-3] cards:
&gt; Infiniband device 'mlx4_0' port 1 status:
&gt; default gid: fe80:0000:0000:0000:0010:e000:0178:9eb1
&gt; base lid: 0x6
&gt; sm lid: 0x1
&gt; state: 4: ACTIVE
&gt; phys state: 5: LinkUp
&gt; rate: 40 Gb/sec (4X QDR)
&gt; link_layer: InfiniBand
&gt;
&gt; Cards are configured with IP addresses on private subnet for IPoIB
&gt; performance testing.
&gt; Regression identified in this bug is in TCP latency in this stack as reported
&gt; by qperf tcp_lat metric:
&gt;
&gt; We have one system listen as a qperf server:
&gt; [root@yourQperfServer ~]# qperf
&gt;
&gt; Have the other system connect to qperf server as a client (in this
&gt; case, it’s X7 server with Mellanox card):
&gt; [root@yourQperfClient ~]# numactl -m0 -N0 qperf 20.20.20.101 -v -uu -ub --time 60 --wait_server 20 -oo msg_size:4K:1024K:*2 tcp_lat

Rather than incur the scheduling latency from queue_work_on, we can
instead switch to running on the next timer tick, on the same core. This
also batches things a bit more -- once per jiffy -- which is okay now
that mix_interrupt_randomness() can credit multiple bits at once.

Reported-by: Sherry Yang &lt;sherry.yang@oracle.com&gt;
Tested-by: Paul Webb &lt;paul.x.webb@oracle.com&gt;
Cc: Sherry Yang &lt;sherry.yang@oracle.com&gt;
Cc: Phillip Goerl &lt;phillip.goerl@oracle.com&gt;
Cc: Jack Vogel &lt;jack.vogel@oracle.com&gt;
Cc: Nicky Veitch &lt;nicky.veitch@oracle.com&gt;
Cc: Colm Harrington &lt;colm.harrington@oracle.com&gt;
Cc: Ramanan Govindarajan &lt;ramanan.govindarajan@oracle.com&gt;
Cc: Sebastian Andrzej Siewior &lt;bigeasy@linutronix.de&gt;
Cc: Dominik Brodowski &lt;linux@dominikbrodowski.net&gt;
Cc: Tejun Heo &lt;tj@kernel.org&gt;
Cc: Sultan Alsawaf &lt;sultan@kerneltoast.com&gt;
Cc: stable@vger.kernel.org
Fixes: 58340f8e952b ("random: defer fast pool mixing to worker")
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>random: avoid reading two cache lines on irq randomness</title>
<updated>2022-09-28T16:17:30+00:00</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2022-09-22T16:46:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=9ee0507e896b45af6d65408c77815800bce30008'/>
<id>urn:sha1:9ee0507e896b45af6d65408c77815800bce30008</id>
<content type='text'>
In order to avoid reading and dirtying two cache lines on every IRQ,
move the work_struct to the bottom of the fast_pool struct. add_
interrupt_randomness() always touches .pool and .count, which are
currently split, because .mix pushes everything down. Instead, move .mix
to the bottom, so that .pool and .count are always in the first cache
line, since .mix is only accessed when the pool is full.

Fixes: 58340f8e952b ("random: defer fast pool mixing to worker")
Reviewed-by: Sebastian Andrzej Siewior &lt;bigeasy@linutronix.de&gt;
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
</feed>
