Linux kernel source tree
Go to file
Linus Torvalds 4be500a1fd UPSTREAM: random: try to actively add entropy rather than passively wait for it
For 5.3 we had to revert a nice ext4 IO pattern improvement, because it
caused a bootup regression due to lack of entropy at bootup together
with arguably broken user space that was asking for secure random
numbers when it really didn't need to.

See commit 72dbcf7215 (Revert "ext4: make __ext4_get_inode_loc plug").

This aims to solve the issue by actively generating entropy noise using
the CPU cycle counter when waiting for the random number generator to
initialize.  This only works when you have a high-frequency time stamp
counter available, but that's the case on all modern x86 CPU's, and on
most other modern CPU's too.

What we do is to generate jitter entropy from the CPU cycle counter
under a somewhat complex load: calling the scheduler while also
guaranteeing a certain amount of timing noise by also triggering a
timer.

I'm sure we can tweak this, and that people will want to look at other
alternatives, but there's been a number of papers written on jitter
entropy, and this should really be fairly conservative by crediting one
bit of entropy for every timer-induced jump in the cycle counter.  Not
because the timer itself would be all that unpredictable, but because
the interaction between the timer and the loop is going to be.

Even if (and perhaps particularly if) the timer actually happens on
another CPU, the cacheline interaction between the loop that reads the
cycle counter and the timer itself firing is going to add perturbations
to the cycle counter values that get mixed into the entropy pool.

As Thomas pointed out, with a modern out-of-order CPU, even quite simple
loops show a fair amount of hard-to-predict timing variability even in
the absense of external interrupts.  But this tries to take that further
by actually having a fairly complex interaction.

This is not going to solve the entropy issue for architectures that have
no CPU cycle counter, but it's not clear how (and if) that is solvable,
and the hardware in question is largely starting to be irrelevant.  And
by doing this we can at least avoid some of the even more contentious
approaches (like making the entropy waiting time out in order to avoid
the possibly unbounded waiting).

Change-Id: I77f527785e5d3fa90c14c8887201c2c0ae8b85db
Cc: Ahmed Darwish <darwish.07@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Theodore Ts'o <tytso@mit.edu>
Cc: Nicholas Mc Guire <hofrat@opentech.at>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: Willy Tarreau <w@1wt.eu>
Cc: Alexander E. Patrakov <patrakov@gmail.com>
Cc: Lennart Poettering <mzxreary@0pointer.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Tao Huang <huangtao@rock-chips.com>
(cherry picked from commit 50ee7529ec)
2019-11-25 08:53:16 +08:00
arch ARM: dts: rockchip: rk3126-bnd-d708: fix clang warning 2019-11-22 12:24:51 +08:00
block Merge remote branch 'android-4.19' of https://android.googlesource.com/kernel/common 2019-10-28 20:26:28 +08:00
certs rk: revert to v4.4 2019-02-10 00:33:21 +08:00
crypto This is the 4.19.79 stable release 2019-10-11 19:13:57 +02:00
Documentation ASoC: rockchip: i2s: Adds properties to specify playback/capture capability 2019-11-19 10:09:48 +08:00
drivers UPSTREAM: random: try to actively add entropy rather than passively wait for it 2019-11-25 08:53:16 +08:00
firmware
fs Merge remote branch 'android-4.19' of https://android.googlesource.com/kernel/common 2019-10-28 20:26:28 +08:00
include video: rockchip: remove unused vcodec driver 2019-11-18 15:25:12 +08:00
init ANDROID: initramfs: call free_initrd() when skipping init 2019-11-14 19:17:07 +08:00
ipc This is the 4.19.65 stable release 2019-08-06 20:08:18 +02:00
kernel Merge remote branch 'android-4.19' of https://android.googlesource.com/kernel/common 2019-10-28 20:26:28 +08:00
lib Merge remote branch 'android-4.19' of https://android.googlesource.com/kernel/common 2019-10-28 20:26:28 +08:00
LICENSES LICENSES: Remove CC-BY-SA-4.0 license text 2018-10-18 11:28:50 +02:00
mm Merge remote branch 'android-4.19' of https://android.googlesource.com/kernel/common 2019-10-28 20:26:28 +08:00
net net: rfkill-bt: control bt host wake when power on bt 2019-11-22 14:54:53 +08:00
samples samples, bpf: suppress compiler warning 2019-07-14 08:11:04 +02:00
scripts rk: add scripts/clang-wrapper.py 2019-11-22 12:43:07 +08:00
security Merge remote branch 'android-4.19' of https://android.googlesource.com/kernel/common 2019-10-28 20:26:28 +08:00
sound ASoC: codecs: Adds support for conexant cx2072x 2019-11-22 15:16:38 +08:00
tools Merge remote branch 'android-4.19' of https://android.googlesource.com/kernel/common 2019-10-28 20:26:28 +08:00
usr kbuild: clean compressed initramfs image 2019-10-07 18:57:16 +02:00
virt KVM: coalesced_mmio: add bounds checking 2019-09-21 07:16:44 +02:00
.checkpatch.conf
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore rk: .gitignore: ignore boot.img/kernel.img/resource.img/zboot.mg 2019-02-15 18:31:05 +08:00
.mailmap rk: revert to v4.4 2019-02-10 00:33:21 +08:00
.scmversion
abi_gki_aarch64.xml ANDROID: enable CONFIG_ION_SYSTEM_HEAP for GKI 2019-09-23 23:26:20 -07:00
build.config.aarch64 ANDROID: refactor build.config files to remove duplication 2019-10-22 18:27:12 -07:00
build.config.common ANDROID: refactor build.config files to remove duplication 2019-10-22 18:27:12 -07:00
build.config.gki ANDROID: refactor build.config files to remove duplication 2019-10-22 18:27:12 -07:00
build.config.gki.aarch64 ANDROID: refactor build.config files to remove duplication 2019-10-22 18:27:12 -07:00
build.config.gki.x86_64 ANDROID: refactor build.config files to remove duplication 2019-10-22 18:27:12 -07:00
build.config.x86_64 ANDROID: refactor build.config files to remove duplication 2019-10-22 18:27:12 -07:00
COPYING
CREDITS 9p: remove Ron Minnich from MAINTAINERS 2018-08-17 16:20:26 -07:00
Kbuild rk: revert to v4.4 2019-02-10 00:33:21 +08:00
Kconfig
logo_kernel.bmp rk: logo: update logo file 2019-08-29 19:45:37 +08:00
logo.bmp rk: logo: update logo file 2019-08-29 19:45:37 +08:00
MAINTAINERS This is the 4.19.80 stable release 2019-10-17 15:33:07 -07:00
Makefile Merge remote branch 'android-4.19' of https://android.googlesource.com/kernel/common 2019-10-28 20:26:28 +08:00
README

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.
See Documentation/00-INDEX for a list of what is contained in each file.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.