<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/drivers/char/hw_random/core.c, branch linux-5.16.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.16.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.16.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2021-05-28T07:11:45Z</updated>
<entry>
<title>hwrng: core - Use DEVICE_ATTR_&lt;RW|RO&gt; macro</title>
<updated>2021-05-28T07:11:45Z</updated>
<author>
<name>YueHaibing</name>
</author>
<published>2021-05-20T13:57:13Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=98f481f22de235b5356f9fa94b0fcffeacc772d8'/>
<id>urn:sha1:98f481f22de235b5356f9fa94b0fcffeacc772d8</id>
<content type='text'>
Use DEVICE_ATTR_RW()/DEVICE_ATTR_RO() helper instead of
plain DEVICE_ATTR, which makes the code a bit shorter and
easier to read.

Signed-off-by: YueHaibing &lt;yuehaibing@huawei.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>hwrng: core - remove redundant initialization of variable err</title>
<updated>2021-05-28T07:11:44Z</updated>
<author>
<name>Shaokun Zhang</name>
</author>
<published>2021-05-20T07:56:11Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=cb028f1662a9910d4b8e3fbe9eb38f7a545540a3'/>
<id>urn:sha1:cb028f1662a9910d4b8e3fbe9eb38f7a545540a3</id>
<content type='text'>
'err' will be assigned later and cleanup the redundant initialization.

Cc: PrasannaKumar Muralidharan &lt;prasannatsmkumar@gmail.com&gt;
Cc: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
Signed-off-by: Shaokun Zhang &lt;zhangshaokun@hisilicon.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>hwrng: core - convert sysfs sprintf/snprintf family to sysfs_emit</title>
<updated>2021-03-26T09:02:34Z</updated>
<author>
<name>Zihao Tang</name>
</author>
<published>2021-03-16T12:34:12Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=91253022821def2a986f6d14762cbacde625b73c'/>
<id>urn:sha1:91253022821def2a986f6d14762cbacde625b73c</id>
<content type='text'>
Fix the following coccicheck warning:

drivers/char/hw_random/core.c:399:8-16: WARNING: use scnprintf or sprintf.

Signed-off-by: Zihao Tang &lt;tangzihao1@hisilicon.com&gt;
Signed-off-by: Jay Fang &lt;f.fangjian@huawei.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>hwrng: core - remove redundant initialization of variable ret</title>
<updated>2020-07-31T08:25:29Z</updated>
<author>
<name>Colin Ian King</name>
</author>
<published>2020-07-24T10:10:01Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=45645709704f94d2625ef15fbf7bcae51aeab975'/>
<id>urn:sha1:45645709704f94d2625ef15fbf7bcae51aeab975</id>
<content type='text'>
The variable ret is being initialized with a value that is never read
and it is being updated later with a new value.  The initialization is
redundant and can be removed.

Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King &lt;colin.king@canonical.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6</title>
<updated>2019-11-26T03:49:58Z</updated>
<author>
<name>Linus Torvalds</name>
</author>
<published>2019-11-26T03:49:58Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=642356cb5f4a8c82b5ca5ebac288c327d10df236'/>
<id>urn:sha1:642356cb5f4a8c82b5ca5ebac288c327d10df236</id>
<content type='text'>
Pull crypto updates from Herbert Xu:
 "API:
   - Add library interfaces of certain crypto algorithms for WireGuard
   - Remove the obsolete ablkcipher and blkcipher interfaces
   - Move add_early_randomness() out of rng_mutex

  Algorithms:
   - Add blake2b shash algorithm
   - Add blake2s shash algorithm
   - Add curve25519 kpp algorithm
   - Implement 4 way interleave in arm64/gcm-ce
   - Implement ciphertext stealing in powerpc/spe-xts
   - Add Eric Biggers's scalar accelerated ChaCha code for ARM
   - Add accelerated 32r2 code from Zinc for MIPS
   - Add OpenSSL/CRYPTOGRAMS poly1305 implementation for ARM and MIPS

  Drivers:
   - Fix entropy reading failures in ks-sa
   - Add support for sam9x60 in atmel
   - Add crypto accelerator for amlogic GXL
   - Add sun8i-ce Crypto Engine
   - Add sun8i-ss cryptographic offloader
   - Add a host of algorithms to inside-secure
   - Add NPCM RNG driver
   - add HiSilicon HPRE accelerator
   - Add HiSilicon TRNG driver"

* git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (285 commits)
  crypto: vmx - Avoid weird build failures
  crypto: lib/chacha20poly1305 - use chacha20_crypt()
  crypto: x86/chacha - only unregister algorithms if registered
  crypto: chacha_generic - remove unnecessary setkey() functions
  crypto: amlogic - enable working on big endian kernel
  crypto: sun8i-ce - enable working on big endian
  crypto: mips/chacha - select CRYPTO_SKCIPHER, not CRYPTO_BLKCIPHER
  hwrng: ks-sa - Enable COMPILE_TEST
  crypto: essiv - remove redundant null pointer check before kfree
  crypto: atmel-aes - Change data type for "lastc" buffer
  crypto: atmel-tdes - Set the IV after {en,de}crypt
  crypto: sun4i-ss - fix big endian issues
  crypto: sun4i-ss - hide the Invalid keylen message
  crypto: sun4i-ss - use crypto_ahash_digestsize
  crypto: sun4i-ss - remove dependency on not 64BIT
  crypto: sun4i-ss - Fix 64-bit size_t warnings on sun4i-ss-hash.c
  MAINTAINERS: Add maintainer for HiSilicon SEC V2 driver
  crypto: hisilicon - add DebugFS for HiSilicon SEC
  Documentation: add DebugFS doc for HiSilicon SEC
  crypto: hisilicon - add SRIOV for HiSilicon SEC
  ...
</content>
</entry>
<entry>
<title>Revert "hwrng: core - Freeze khwrng thread during suspend"</title>
<updated>2019-11-17T00:48:17Z</updated>
<author>
<name>Herbert Xu</name>
</author>
<published>2019-11-17T00:48:17Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=08e97aec700aeff54c4847f170e566cbd7e14e81'/>
<id>urn:sha1:08e97aec700aeff54c4847f170e566cbd7e14e81</id>
<content type='text'>
This reverts commit 03a3bb7ae631 ("hwrng: core - Freeze khwrng
thread during suspend"), ff296293b353 ("random: Support freezable
kthreads in add_hwgenerator_randomness()") and 59b569480dc8 ("random:
Use wait_event_freezable() in add_hwgenerator_randomness()").

These patches introduced regressions and we need more time to
get them ready for mainline.

Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>hwrng: core - Fix use-after-free warning in hwrng_register()</title>
<updated>2019-10-23T08:47:00Z</updated>
<author>
<name>Laurent Vivier</name>
</author>
<published>2019-10-14T11:46:32Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=28443671a468489fb147b31687b2157b6ba59c4a'/>
<id>urn:sha1:28443671a468489fb147b31687b2157b6ba59c4a</id>
<content type='text'>
Commit daae28debcb0 has moved add_early_randomness() out of the
rng_mutex and tries to protect the reference of the new rng device
by incrementing the reference counter.

But in hwrng_register(), the function can be called with a new device
that is not set as the current_rng device and the reference has not been
initialized. This patch fixes the problem by not using the reference
counter when the device is not the current one: the reference counter
is only meaningful in the case of the current rng device and a device
is not used if it is not the current one (except in hwrng_register())

The problem has been reported by Marek Szyprowski on ARM 32bit
Exynos5420-based Chromebook Peach-Pit board:

WARNING: CPU: 3 PID: 1 at lib/refcount.c:156 hwrng_register+0x13c/0x1b4
refcount_t: increment on 0; use-after-free.
Modules linked in:
CPU: 3 PID: 1 Comm: swapper/0 Not tainted 5.4.0-rc1-00061-gdaae28debcb0
Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
[&lt;c01124c8&gt;] (unwind_backtrace) from [&lt;c010dfb8&gt;] (show_stack+0x10/0x14)
[&lt;c010dfb8&gt;] (show_stack) from [&lt;c0ae86d8&gt;] (dump_stack+0xa8/0xd4)
[&lt;c0ae86d8&gt;] (dump_stack) from [&lt;c0127428&gt;] (__warn+0xf4/0x10c)
[&lt;c0127428&gt;] (__warn) from [&lt;c01274b4&gt;] (warn_slowpath_fmt+0x74/0xb8)
[&lt;c01274b4&gt;] (warn_slowpath_fmt) from [&lt;c054729c&gt;] (hwrng_register+0x13c/0x1b4)
[&lt;c054729c&gt;] (hwrng_register) from [&lt;c0547e54&gt;] (tpm_chip_register+0xc4/0x274)
...

Reported-by: Marek Szyprowski &lt;m.szyprowski@samsung.com&gt;
Fixes: daae28debcb0 ("hwrng: core - move add_early_randomness() out of rng_mutex")
Tested-by: Marek Szyprowski &lt;m.szyprowski@samsung.com&gt;
Signed-off-by: Laurent Vivier &lt;lvivier@redhat.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>hwrng: core - move add_early_randomness() out of rng_mutex</title>
<updated>2019-10-10T12:36:31Z</updated>
<author>
<name>Laurent Vivier</name>
</author>
<published>2019-09-12T13:30:22Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=daae28debcb03eee837fadfd20788107b325c5a2'/>
<id>urn:sha1:daae28debcb03eee837fadfd20788107b325c5a2</id>
<content type='text'>
add_early_randomness() is called every time a new rng backend is added
and every time it is set as the current rng provider.

add_early_randomness() is called from functions locking rng_mutex,
and if it hangs all the hw_random framework hangs: we can't read sysfs,
add or remove a backend.

This patch move add_early_randomness() out of the rng_mutex zone.
It only needs the reading_mutex.

Signed-off-by: Laurent Vivier &lt;lvivier@redhat.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>hwrng: core - don't wait on add_early_randomness()</title>
<updated>2019-09-20T13:05:33Z</updated>
<author>
<name>Laurent Vivier</name>
</author>
<published>2019-09-17T09:54:50Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=78887832e76541f77169a24ac238fccb51059b63'/>
<id>urn:sha1:78887832e76541f77169a24ac238fccb51059b63</id>
<content type='text'>
add_early_randomness() is called by hwrng_register() when the
hardware is added. If this hardware and its module are present
at boot, and if there is no data available the boot hangs until
data are available and can't be interrupted.

For instance, in the case of virtio-rng, in some cases the host can be
not able to provide enough entropy for all the guests.

We can have two easy ways to reproduce the problem but they rely on
misconfiguration of the hypervisor or the egd daemon:

- if virtio-rng device is configured to connect to the egd daemon of the
host but when the virtio-rng driver asks for data the daemon is not
connected,

- if virtio-rng device is configured to connect to the egd daemon of the
host but the egd daemon doesn't provide data.

The guest kernel will hang at boot until the virtio-rng driver provides
enough data.

To avoid that, call rng_get_data() in non-blocking mode (wait=0)
from add_early_randomness().

Signed-off-by: Laurent Vivier &lt;lvivier@redhat.com&gt;
Fixes: d9e797261933 ("hwrng: add randomness to system from rng...")
Cc: &lt;stable@vger.kernel.org&gt;
Reviewed-by: Theodore Ts'o &lt;tytso@mit.edu&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>hwrng: core - Freeze khwrng thread during suspend</title>
<updated>2019-08-15T11:52:13Z</updated>
<author>
<name>Stephen Boyd</name>
</author>
<published>2019-08-05T23:32:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=03a3bb7ae63150230c5de645dc95e673ebf17e1a'/>
<id>urn:sha1:03a3bb7ae63150230c5de645dc95e673ebf17e1a</id>
<content type='text'>
The hwrng_fill() function can run while devices are suspending and
resuming. If the hwrng is behind a bus such as i2c or SPI and that bus
is suspended, the hwrng may hang the bus while attempting to add some
randomness. It's been observed on ChromeOS devices with suspend-to-idle
(s2idle) and an i2c based hwrng that this kthread may run and ask the
hwrng device for randomness before the i2c bus has been resumed.

Let's make this kthread freezable so that we don't try to touch the
hwrng during suspend/resume. This ensures that we can't cause the hwrng
backing driver to get into a bad state because the device is guaranteed
to be resumed before the hwrng kthread is thawed.

Cc: Andrey Pronin &lt;apronin@chromium.org&gt;
Cc: Duncan Laurie &lt;dlaurie@chromium.org&gt;
Cc: Jason Gunthorpe &lt;jgg@ziepe.ca&gt;
Cc: Arnd Bergmann &lt;arnd@arndb.de&gt;
Cc: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Cc: Guenter Roeck &lt;groeck@chromium.org&gt;
Cc: Alexander Steffen &lt;Alexander.Steffen@infineon.com&gt;
Signed-off-by: Stephen Boyd &lt;swboyd@chromium.org&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
</feed>
