busybox/util-linux
Jason A. Donenfeld 4b407bacd4 seedrng: import SeedRNG utility for kernel RNG seed files
The RNG can't actually be seeded from a shell script, due to the
reliance on ioctls and the fact that entropy written into the
unprivileged /dev/urandom device is not immediately mixed in, making
subsequent seed reads dangerous. For this reason, the seedrng project
provides a basic "C script" meant to be copy and pasted into projects
like Busybox and tweaked as needed: <https://git.zx2c4.com/seedrng/about/>.

The SeedRNG construction has been part of systemd's seeder since
January, and recently was added to Android, OpenRC, and Void's Runit,
with more integrations on their way depending on context. Virtually
every single Busybox-based distro I have seen seeds things in wrong,
incomplete, or otherwise dangerous way. For example, fixing this issue
in Buildroot requires first for Busybox to have this fix.

This commit imports it into Busybox and wires up the basic config. The
utility itself is tiny, and unlike the example code from the SeedRNG
project, we can re-use libbb's existing hash functions, rather than
having to ship a standalone BLAKE2s, which makes this even smaller.

function                                             old     new   delta
seedrng_main                                           -    1463   +1463
.rodata                                           107858  108665    +807
seed_from_file_if_exists                               -     697    +697
packed_usage                                       34414   34519    +105
static.longopts                                        -      38     +38
static.seedrng_prefix                                  -      26     +26
seed_dir                                               -       8      +8
non_creditable_seed                                    -       8      +8
lock_file                                              -       8      +8
creditable_seed                                        -       8      +8
applet_names                                        2747    2755      +8
applet_main                                         3192    3200      +8
------------------------------------------------------------------------------
(add/remove: 9/0 grow/shrink: 4/0 up/down: 3184/0)           Total: 3184 bytes
   text	   data	    bss	    dec	    hex	filename
 973776	   4219	   1816	 979811	  ef363	busybox_old
 977035	   4227	   1848	 983110	  f0046	busybox_unstripped

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2022-04-20 15:20:29 +02:00
..
volume_id decrease paddign: gcc-9.3.1 slaps 32-byte alignment on arrays willy-nilly 2020-11-30 13:03:03 +01:00
acpid.c decrease paddign: gcc-9.3.1 slaps 32-byte alignment on arrays willy-nilly 2020-11-30 13:03:03 +01:00
blkdiscard.c blkdiscard: accept -f (force) as no-op 2021-09-10 00:20:05 +02:00
blkid.c build system: drop PLATFORM_LINUX 2020-08-13 17:12:56 +02:00
blockdev.c blockdev: support --get/setra 2021-06-16 17:00:56 +02:00
cal.c libbb: factor out fflush_stdout_and_exit(EXIT_SUCCESS) 2022-01-04 23:31:58 +01:00
chrt.c libbb: factor out fflush_stdout_and_exit(EXIT_SUCCESS) 2022-01-04 23:31:58 +01:00
Config.src restore documentation on the build config language 2018-06-06 15:16:48 +02:00
dmesg.c *: --help tweaks 2021-06-14 20:47:20 +02:00
eject.c build system: drop PLATFORM_LINUX 2020-08-13 17:12:56 +02:00
fallocate.c config: update size information 2018-12-28 03:20:17 +01:00
fatattr.c build system: drop PLATFORM_LINUX 2020-08-13 17:12:56 +02:00
fbset.c *: add NOINLINEs where code noticeably shrinks 2021-10-10 13:50:53 +02:00
fdformat.c build system: drop PLATFORM_LINUX 2020-08-13 17:12:56 +02:00
fdisk_aix.c fdisk_aix: fix aliasing warning, comment out unused global variables 2019-10-04 17:16:15 +02:00
fdisk_gpt.c libbb: introduce and use fputs_stdout 2021-02-03 20:52:40 +01:00
fdisk_osf.c libbb: code shrink: introduce and use [_]exit_SUCCESS() 2022-01-05 22:16:06 +01:00
fdisk_sgi.c decrease paddign: gcc-9.3.1 slaps 32-byte alignment on arrays willy-nilly 2020-11-30 13:03:03 +01:00
fdisk_sun.c *: add more beneficial NOINLINEs 2021-10-10 14:32:05 +02:00
fdisk.c fdisk: recognize EBBR protective partitions 2022-01-06 10:55:53 +01:00
findfs.c build system: drop PLATFORM_LINUX 2020-08-13 17:12:56 +02:00
flock.c *: more --help tweaking 2021-06-13 03:51:55 +02:00
freeramdisk.c build system: drop PLATFORM_LINUX 2020-08-13 17:12:56 +02:00
fsck_minix.c libbb: code shrink: introduce and use [_]exit_SUCCESS() 2022-01-05 22:16:06 +01:00
fsfreeze.c build system: drop PLATFORM_LINUX 2020-08-13 17:12:56 +02:00
fstrim.c help text: replace [OPTIONS] with actual options (if not too long) 2020-12-13 22:34:05 +01:00
getopt.c getopt: code shrink 2021-09-16 01:09:32 +02:00
hexdump_xxd.c libbb: factor out fflush_stdout_and_exit(EXIT_SUCCESS) 2022-01-04 23:31:58 +01:00
hexdump.c *: slap on a few ALIGN* where appropriate 2022-02-06 19:53:10 +01:00
hwclock.c libbb: introduce and use xgettimeofday(), do not truncate 64-bit time_t in shells 2020-12-30 23:48:01 +01:00
ionice.c ionice: implement -t 2021-06-17 13:45:13 +02:00
ipcrm.c config: update size information 2018-12-28 03:20:17 +01:00
ipcs.c libbb: factor out fflush_stdout_and_exit(EXIT_SUCCESS) 2022-01-04 23:31:58 +01:00
Kbuild.src Convert all util-linux/* applets to "new style" applet definitions 2016-11-23 11:46:32 +01:00
last_fancy.c libbb: factor out fflush_stdout_and_exit(EXIT_SUCCESS) 2022-01-04 23:31:58 +01:00
last.c libbb: factor out fflush_stdout_and_exit(EXIT_SUCCESS) 2022-01-04 23:31:58 +01:00
losetup.c mount: support the sizelimit and offset option for loop devices 2020-10-01 00:31:11 +02:00
lspci.c libbb: shrink recursive_action() by reducing memory pressure 2020-10-01 21:52:16 +02:00
lsusb.c libbb: shrink recursive_action() by reducing memory pressure 2020-10-01 21:52:16 +02:00
mdev.c mdev: tweak --help 2021-10-08 14:30:50 +02:00
mesg.c libbb: reduce the overhead of single parameter bb_error_msg() calls 2019-07-02 11:35:03 +02:00
minix.h more bionic fixes 2016-03-14 19:34:15 +01:00
mkfs_ext2_test.sh fix more instances of ": $((a++))" in shell scripts 2017-07-15 19:20:45 +02:00
mkfs_ext2.c decrease paddign: gcc-9.3.1 slaps 32-byte alignment on arrays willy-nilly 2020-11-30 13:03:03 +01:00
mkfs_ext2.txt mkfs_ext2: use compatible inode sizes; add -I <inodesize>. (by Vladimir) 2009-10-22 12:12:17 +02:00
mkfs_minix.c build system: drop PLATFORM_LINUX 2020-08-13 17:12:56 +02:00
mkfs_reiser.c build system: drop PLATFORM_LINUX 2020-08-13 17:12:56 +02:00
mkfs_vfat.c mkfs.vfat: fix volume label to be padded with space 2022-01-23 23:07:07 +01:00
mkswap.c libbb: add and use infrastructure for fixed page size optimization 2020-12-14 18:54:30 +01:00
more.c config: update size information 2018-12-28 03:20:17 +01:00
mount.c mount: "mount -o rw ...." should not fall back to RO mount 2021-10-08 02:20:10 +02:00
mountpoint.c *: more --help tweaking 2021-06-13 03:51:55 +02:00
nologin.c nologin: make it possible to build it as single applet 2020-06-24 15:05:22 +02:00
nsenter.c *: slap on a few ALIGN* where appropriate 2022-02-06 19:53:10 +01:00
pivot_root.c build system: drop PLATFORM_LINUX 2020-08-13 17:12:56 +02:00
rdate.c libbb: introduce and use xsettimeofday() 2020-12-16 21:36:36 +01:00
rdev.c config: update size information 2018-12-28 03:20:17 +01:00
readprofile.c *: more --help tweaking 2021-06-13 03:51:55 +02:00
renice.c *: more --help tweaks 2021-06-15 10:00:18 +02:00
rev.c rev: correct output for long input lines 2021-08-22 00:08:18 +02:00
rtcwake.c move ADJTIME_PATH define to header files 2020-12-17 20:53:43 +01:00
script.c libbb: introduce and use xgettimeofday(), do not truncate 64-bit time_t in shells 2020-12-30 23:48:01 +01:00
scriptreplay.c config: update size information 2018-12-28 03:20:17 +01:00
seedrng.c seedrng: import SeedRNG utility for kernel RNG seed files 2022-04-20 15:20:29 +02:00
setarch.c build system: drop PLATFORM_LINUX 2020-08-13 17:12:56 +02:00
setpriv.c help text tweaks 2020-12-18 04:12:51 +01:00
setsid.c config: update size information 2018-12-28 03:20:17 +01:00
swaponoff.c build system: drop PLATFORM_LINUX 2020-08-13 17:12:56 +02:00
switch_root.c switch_root: code shrink - use iterate_on_dir() 2021-06-24 17:54:11 +02:00
taskset.c taskset: fix printf format mismatch in !FEATURE_TASKSET_FANCY config. closes 14616 2022-03-01 10:49:17 +01:00
uevent.c help text tweaks 2020-12-18 04:12:51 +01:00
umount.c help text: replace [OPTIONS] with actual options (if not too long) 2020-12-13 22:34:05 +01:00
unshare.c *: slap on a few ALIGN* where appropriate 2022-02-06 19:53:10 +01:00
wall.c config: update size information 2018-12-28 03:20:17 +01:00