NetBSD/sys/kern/files.kern
riastradh 5084c1b50f Rewrite entropy subsystem.
Primary goals:

1. Use cryptography primitives designed and vetted by cryptographers.
2. Be honest about entropy estimation.
3. Propagate full entropy as soon as possible.
4. Simplify the APIs.
5. Reduce overhead of rnd_add_data and cprng_strong.
6. Reduce side channels of HWRNG data and human input sources.
7. Improve visibility of operation with sysctl and event counters.

Caveat: rngtest is no longer used generically for RND_TYPE_RNG
rndsources.  Hardware RNG devices should have hardware-specific
health tests.  For example, checking for two repeated 256-bit outputs
works to detect AMD's 2019 RDRAND bug.  Not all hardware RNGs are
necessarily designed to produce exactly uniform output.

ENTROPY POOL

- A Keccak sponge, with test vectors, replaces the old LFSR/SHA-1
  kludge as the cryptographic primitive.

- `Entropy depletion' is available for testing purposes with a sysctl
  knob kern.entropy.depletion; otherwise it is disabled, and once the
  system reaches full entropy it is assumed to stay there as far as
  modern cryptography is concerned.

- No `entropy estimation' based on sample values.  Such `entropy
  estimation' is a contradiction in terms, dishonest to users, and a
  potential source of side channels.  It is the responsibility of the
  driver author to study the entropy of the process that generates
  the samples.

- Per-CPU gathering pools avoid contention on a global queue.

- Entropy is occasionally consolidated into global pool -- as soon as
  it's ready, if we've never reached full entropy, and with a rate
  limit afterward.  Operators can force consolidation now by running
  sysctl -w kern.entropy.consolidate=1.

- rndsink(9) API has been replaced by an epoch counter which changes
  whenever entropy is consolidated into the global pool.
  . Usage: Cache entropy_epoch() when you seed.  If entropy_epoch()
    has changed when you're about to use whatever you seeded, reseed.
  . Epoch is never zero, so initialize cache to 0 if you want to reseed
    on first use.
  . Epoch is -1 iff we have never reached full entropy -- in other
    words, the old rnd_initial_entropy is (entropy_epoch() != -1) --
    but it is better if you check for changes rather than for -1, so
    that if the system estimated its own entropy incorrectly, entropy
    consolidation has the opportunity to prevent future compromise.

- Sysctls and event counters provide operator visibility into what's
  happening:
  . kern.entropy.needed - bits of entropy short of full entropy
  . kern.entropy.pending - bits known to be pending in per-CPU pools,
    can be consolidated with sysctl -w kern.entropy.consolidate=1
  . kern.entropy.epoch - number of times consolidation has happened,
    never 0, and -1 iff we have never reached full entropy

CPRNG_STRONG

- A cprng_strong instance is now a collection of per-CPU NIST
  Hash_DRBGs.  There are only two in the system: user_cprng for
  /dev/urandom and sysctl kern.?random, and kern_cprng for kernel
  users which may need to operate in interrupt context up to IPL_VM.

  (Calling cprng_strong in interrupt context does not strike me as a
  particularly good idea, so I added an event counter to see whether
  anything actually does.)

- Event counters provide operator visibility into when reseeding
  happens.

INTEL RDRAND/RDSEED, VIA C3 RNG (CPU_RNG)

- Unwired for now; will be rewired in a subsequent commit.
2020-04-30 03:28:18 +00:00

235 lines
6.9 KiB
Plaintext

# $NetBSD: files.kern,v 1.47 2020/04/30 03:28:18 riastradh Exp $
#
# kernel sources
#
define kern: machdep, uvm
defflag opt_kern.h KERN
defflag opt_script.h SETUIDSCRIPTS FDSCRIPTS
defflag KASLR
file conf/debugsyms.c kern
file conf/param.c kern
file kern/bufq_disksort.c bufq_disksort
file kern/bufq_fcfs.c bufq_fcfs
file kern/bufq_priocscan.c bufq_priocscan
file kern/bufq_readprio.c bufq_readprio | new_bufq_strategy
file kern/compat_stub.c kern
file kern/core_elf32.c exec_elf32
file kern/core_elf64.c exec_elf64
file kern/core_netbsd.c coredump
file kern/cnmagic.c kern
file kern/exec_aout.c exec_aout
file kern/exec_ecoff.c exec_ecoff
file kern/exec_elf32.c exec_elf32
file kern/exec_elf64.c exec_elf64
file kern/exec_script.c exec_script
file kern/exec_subr.c kern
file kern/init_main.c kern
file kern/init_sysctl.c kern
file kern/init_sysctl_base.c kern
file kern/init_sysent.c kern
file kern/kern_acct.c kern
file kern/kern_auth.c kern
file kern/kern_cfglock.c kern
file kern/kern_clock.c kern
file kern/kern_condvar.c kern
file kern/kern_core.c coredump
file kern/kern_cpu.c kern
#kern/kern_ctf.c is only needed as part of dtrace_fbt module
#file kern/kern_ctf.c kdtrace_hooks
file kern/kern_descrip.c kern
file kern/kern_entropy.c kern
file kern/kern_event.c kern
file kern/kern_exec.c kern
file kern/kern_exit.c kern
file kern/kern_fork.c kern
file kern/kern_idle.c kern
file kern/kern_hook.c kern
file kern/kern_kthread.c kern
file kern/kern_ktrace.c ktrace
file kern/kern_ktrace_vfs.c ktrace
file kern/kern_ksyms.c ksyms | ddb | modular needs-flag
file kern/kern_lock.c kern
file kern/kern_lwp.c kern
file kern/kern_malloc.c kern
file kern/kern_module.c kern
file kern/kern_module_hook.c kern
file kern/kern_module_vfs.c kern
file kern/kern_mutex.c kern
file kern/kern_mutex_obj.c kern
file kern/kern_fileassoc.c fileassoc
file kern/kern_ntptime.c kern
file kern/kern_pax.c pax_mprotect | pax_segvguard | pax_aslr
file kern/kern_physio.c kern
file kern/kern_pmf.c kern
file kern/kern_proc.c kern
file kern/kern_prot.c kern
file kern/kern_ras.c kern
file kern/kern_rate.c kern
file kern/kern_reboot.c kern
file kern/kern_resource.c kern
file kern/kern_runq.c kern
file kern/kern_rwlock.c kern
file kern/kern_rwlock_obj.c kern
file kern/kern_scdebug.c kern
file kern/kern_sdt.c kdtrace_hooks
file kern/kern_crashme.c kern
file kern/kern_sig.c kern
file kern/kern_sleepq.c kern
file kern/kern_softint.c kern
file kern/kern_ssp.c kern
file kern/kern_stub.c kern
file kern/kern_subr.c kern
file kern/kern_synch.c kern
file kern/kern_syscall.c kern
file kern/kern_sysctl.c kern
file kern/kern_tc.c kern
file kern/kern_threadpool.c kern
file kern/kern_time.c kern
file kern/kern_timeout.c kern
file kern/kern_turnstile.c kern
file kern/kern_todr.c kern
file kern/kern_uidinfo.c kern
file kern/kern_uuid.c kern
file kern/kgdb_stub.c kgdb
file kern/sched_4bsd.c sched_4bsd
file kern/sched_m2.c sched_m2
file kern/subr_asan.c kasan
file kern/subr_autoconf.c kern
file kern/subr_blist.c vmswap
file kern/subr_bufq.c kern
file kern/subr_callback.c kern
file kern/subr_cprng.c kern
file kern/subr_cpu.c kern
file kern/subr_cpufreq.c kern
file kern/subr_copy.c kern
file kern/subr_csan.c kcsan
file kern/subr_debug.c debug
file kern/subr_device.c kern
file kern/subr_devsw.c kern
file kern/subr_disk.c kern
file kern/subr_disklabel.c kern
file kern/subr_disk_open.c kern
file kern/subr_emul.c kern
file kern/subr_evcnt.c kern
file kern/subr_exec_fd.c kern
file kern/subr_extent.c kern
file kern/subr_hash.c kern
file kern/subr_humanize.c kern
file kern/subr_interrupt.c kern
file kern/subr_iostat.c kern
file kern/subr_ipi.c kern
file kern/subr_kcpuset.c kern
file kern/subr_kcov.c kcov
defflag opt_kmem.h KMEM_SIZE
file kern/subr_kmem.c kern
file kern/subr_kobj.c kern
file kern/subr_kobj_vfs.c kern
file kern/subr_localcount.c kern
file kern/subr_lockdebug.c kern
file kern/subr_log.c kern
file kern/subr_lwp_specificdata.c kern
file kern/subr_msan.c kmsan
file kern/subr_once.c kern
file kern/subr_optstr.c kern
file kern/subr_pcq.c kern
file kern/subr_pcu.c kern
file kern/subr_percpu.c kern
file kern/subr_pool.c kern
file kern/subr_prf.c kern
file kern/subr_prof.c kern
file kern/subr_pserialize.c kern
file kern/subr_psref.c kern
file kern/subr_specificdata.c kern
file kern/subr_tftproot.c tftproot
file kern/subr_time.c kern
file kern/subr_thmap.c kern
file kern/subr_userconf.c userconf
file kern/subr_vmem.c kern
file kern/subr_workqueue.c kern
file kern/subr_xcall.c kern
file kern/sys_aio.c aio
file kern/sys_descrip.c kern
file kern/sys_futex.c kern
file kern/sys_generic.c kern
file kern/sys_module.c kern
file kern/sys_mqueue.c mqueue
file kern/sys_lwp.c kern
file kern/sys_pipe.c !pipe_socketpair
file kern/sys_process.c ptrace_hooks | ktrace
file kern/sys_process_lwpstatus.c kern
file kern/sys_ptrace.c ptrace
file kern/sys_ptrace_common.c ptrace
file kern/sys_pset.c kern
file kern/sys_select.c kern
file kern/sys_sig.c kern
file kern/sys_sched.c kern
file kern/sys_socket.c kern
file kern/syscalls.c syscall_debug | kdtrace_hooks
file kern/sysv_ipc.c sysvshm | sysvsem | sysvmsg
file kern/sysv_msg.c sysvmsg
file kern/sysv_sem.c sysvsem
file kern/sysv_shm.c sysvshm
file kern/tty.c kern
file kern/tty_conf.c kern
file kern/tty_bsdpty.c compat_bsdpty
file kern/tty_pty.c pty needs-flag
file kern/tty_ptm.c pty
file kern/tty_subr.c kern
file kern/tty_tty.c kern
file kern/uipc_accf.c kern
file kern/uipc_domain.c kern
file kern/uipc_mbuf.c kern
file kern/uipc_mbufdebug.c kern & ether & ddb
file net/link_proto.c kern # XXX
file kern/uipc_proto.c kern
file kern/uipc_sem.c kern
file kern/uipc_socket.c kern
file kern/uipc_socket2.c kern
file kern/uipc_syscalls.c kern
file kern/uipc_usrreq.c kern
define vfs: kern
file kern/vfs_bio.c vfs
file kern/vfs_cache.c vfs
file kern/vfs_cwd.c vfs
file kern/vfs_dirhash.c vfs
file kern/vfs_getcwd.c vfs
file kern/vfs_hooks.c vfs
file kern/vfs_init.c vfs
file kern/vfs_lockf.c vfs
file kern/vfs_lookup.c vfs
file kern/vfs_mount.c vfs
file kern/vfs_quotactl.c vfs
file kern/vfs_subr.c vfs
file kern/vfs_syscalls.c vfs
file kern/vfs_trans.c vfs
file kern/vfs_vnode.c vfs
file kern/vfs_vnops.c vfs
file kern/vfs_wapbl.c wapbl
file kern/vfs_xattr.c vfs
file kern/vnode_if.c vfs
file miscfs/deadfs/dead_vfsops.c vfs
file miscfs/deadfs/dead_vnops.c vfs
file miscfs/fifofs/fifo_vnops.c vfs
file miscfs/genfs/genfs_io.c vfs
file miscfs/genfs/genfs_rename.c vfs
file miscfs/genfs/genfs_vfsops.c vfs
file miscfs/genfs/genfs_vnops.c vfs
define layerfs
file miscfs/genfs/layer_subr.c layerfs
file miscfs/genfs/layer_vfsops.c layerfs
file miscfs/genfs/layer_vnops.c layerfs
file miscfs/specfs/spec_vnops.c vfs
defflag KUBSAN
prefix ../common/lib/libc/misc
file ubsan.c kubsan
prefix
makeoptions kubsan CFLAGS+="-fsanitize=undefined"
makeoptions kubsan CPPFLAGS+="-DACPI_MISALIGNMENT_NOT_SUPPORTED"