Commit Graph

301767 Commits

Author SHA1 Message Date
nia d644da2ee9 Use ENVIRONMENT section 2023-07-01 10:47:12 +00:00
rillig 6aee6dcfa0 lint: constify, reduce indentation
No functional change.
2023-07-01 10:04:27 +00:00
rillig 5eadae9e5a lint: clean up comments in lint1.h 2023-07-01 09:59:51 +00:00
rillig 52f3b73d82 lint: clean up duplicate and dead code for integer constants
No functional change.
2023-07-01 09:31:55 +00:00
rillig b1cae80086 doc/CHANGES: fix typos 2023-07-01 09:21:47 +00:00
rillig c6d4ed97fd lint: clean up typos 2023-07-01 09:21:31 +00:00
rillig 102b73ba9b tests/make: show how to use indirect conditions in the '?:' modifier 2023-07-01 09:06:34 +00:00
skrll 9d814dceba Fix build when KERNHIST defined, but not UVMHIST 2023-07-01 07:10:13 +00:00
rillig ed2a91d216 jemalloc: enable lint again, it is no longer broken
Since today, lint handles unnamed struct/union correctly.
2023-07-01 06:29:14 +00:00
rillig 130b20d8de lint: fix initialization of unnamed union member 2023-07-01 06:09:24 +00:00
gutteridge 7408a707bd audioplay.1: fix sentence punctuation 2023-06-30 23:36:47 +00:00
rillig 91f591a176 tests/lint: test initializing an unnamed union 2023-06-30 22:27:47 +00:00
uwe 31f1ed95bf getentropy(3): use .Sx to xref CAVEATS 2023-06-30 22:15:14 +00:00
christos 498dfa02ae new OpenPAM. 2023-06-30 21:48:15 +00:00
christos 0d9d0fd8a3 merge openpam ximenia 2023-06-30 21:46:20 +00:00
riastradh b36d83c44f getrandom(2), getentropy(3): Rework man pages.
Make supportable promises.  Omit needless verbiage.  Give caveats
with cross-references to entropy(7).  Emphasize that security is
necessarily relative to system configuration.

XXX pullup-10
2023-06-30 21:44:22 +00:00
riastradh e857694c31 rc.conf(5): Set entropy=wait by default.
We no longer block indefinitely -- if nothing else, the hardclock
timer should yield enough samples to unblock /dev/random on all but
the most severely deterministic machines -- so it should be generally
safe for availability to set entropy=wait.

This doesn't guarantee that HWRNG/seed has been provided before you
run ssh-keygen or call getentropy(3) in a user application, but it
does raise the security above netbsd<=9.

PR security/55659
PR lib/56905

XXX pullup-10
2023-06-30 21:44:09 +00:00
christos 024a2e8c04 Import ximenia (last was tabebuia)
- BUGFIX: Fix race condition in openpam_ttyconv(3) when used with
  expect scripts.

- BUGFIX: In openpam_set_option(3), when removing an option, properly
  decrement the option count.

- BUGFIX: In openpam_subst(3), avoid incrementing past the end of the
  template.
2023-06-30 21:44:02 +00:00
riastradh 2cfa14dfd4 security(5): Check kern.entropy.needed for confident entropy.
Don't test whether a non-blocking read from /dev/random would return
data.

For the sake of availability, /dev/random will unblock based on sources
like timer interrupts, which we can't confidently assert anything about
the actual unpredictability of.

Here, the goal is to highlight systems that have neither obtained
entropy from an HWRNG with a confident entropy assessment, nor been
seeded from a source the operator knows about.

XXX pullup-10
2023-06-30 21:42:29 +00:00
riastradh 96b2c7de8d entropy(9): Reintroduce netbsd<=9 time-delta estimator for unblocking.
The system will (in a subsequent change) by default block for this
condition before almost all of userland is running (including
/etc/rc.d/sshd key generation).  That way, a never-blocking
getentropy(3) API will never return any data without at least
best-effort entropy like netbsd<=9 did to applications except in
single-user mode (where you have to be careful about everything
anyway) or in the few processes that run before a seed can even be
loaded (where blocking indefinitely, e.g. when generating a stack
protector cookie in libc, could pose a severe availability problem
that can't be configured away, but where the security impact is low).

However, (in another subsequent change) we will continue to use
_only_ HWRNG driver estimates and seed estimates, and _not_
time-delta estimator, for _warning_ about security in motd, daily
security report, etc.  And if HWRNG/seed provides enough entropy
before time-delta estimator does, that will unblock /dev/random too.

The result is:

- Machines with HWRNG or seed won't warn about entropy and will
  essentially never block -- even on first boot without a seed, it
  will take only as long as the fastest HWRNG to unblock.

- Machines with neither HWRNG nor seed:
  . will warn about entropy, giving feedback about security;
    and
  . will avoid returning anything more predictable than netbsd<=9;
    but
  . won't block (much) longer than netbsd<=9 would (and won't block
    again after blocking once, except with kern.entropy.depletion=1 for
    testing).

  (The threshold for unblocking is now somewhat higher than before:
  512 samples that pass the time-delta estimator, rather than 80 as
  it used to be.)

  And, of course, adding a seed (or HWRNG) will prevent both warnings
  and blocking.

The mechanism is:

1. /dev/random will block until _either_

   (a) enough bits of entropy (256) from reliable sources have been
       added to the pool, _or_

   (b) enough samples have been added from any sources (512), passing
       the old time-delta entropy estimator, that the possible
       security benefit doesn't justify holding up availability any
       longer (`best effort'), except on systems with higher security
       requirements like securelevel=2 which can disable non-HWRNG,
       non-seed sources with rndctl_flags in rc.conf(5).

2. dmesg will report `entropy: ready' when 1(a) is satisfied, but if
   1(b) is satisfied first, it will report `entropy: best effort', so
   the concise log messages will reflect the timing and whether in
   any period of time any of the system might be relying on best
   effort entropy.

3. The sysctl knob kern.entropy.needed (and the ioctl RNDGETPOOLSTAT
   variable rndpoolstat_t::added) still reflects the number of bits
   of entropy from reliable sources, so we can still use this to
   suggest regenerating ssh keys.

   This matters on platforms that can only be reached, after flashing
   an installation image, by sshing in over a (private) network, like
   small network appliances or remote virtual machines without
   (interactive) serial consoles.  If we blocked indefinitely at boot
   when generating ssh keys, such platforms would be unusable.  This
   way, platforms are usable, but operators can still be advised at
   login time to regenerate keys as soon as they can actually load
   entropy onto the system, e.g. with rndctl(8) on a seed file copied
   from a local machine over the (private) network.

4. On machines without HWRNG, using a seed file still suppresses
   warnings for users who need more confident security.  But it is no
   longer necessary for availability.

This is a compromise between availability and security:

- The security mechanism of blocking indefinitely on machines without
  HWRNG hurts availability too much, as painful experience over the
  multiple years since I made the mistake of introducing it have
  shown.  (Sorry!)

- The other main alternative, not having a blocking path at all (as I
  pushed for, and as OpenBSD has done for a long time) could
  potentially reduce security vs netbsd<=9, and would run against the
  expectations set by many popular operating systems to the severe
  detriment of public perception of NetBSD security.

Even though we can't _confidently_ assess enough entropy from, e.g.,
sampling interrupt timings, this is the traditional behaviour that
most operating systems provide -- and the result here is a net
nondecrease in security over netbsd<=9, because all paths from the
entropy pool to userland now have at least as high a standard before
returning data as they did in netbsd<=9.

PR kern/55641
PR pkg/55847
PR kern/57185
https://mail-index.netbsd.org/current-users/2020/09/02/msg039470.html
https://mail-index.netbsd.org/current-users/2020/11/21/msg039931.html
https://mail-index.netbsd.org/current-users/2020/12/05/msg040019.html

XXX pullup-10
2023-06-30 21:42:05 +00:00
rillig c7c89cb5fa lint: clean up names related to declaration levels
The previous prefix 'DK_' (declaration level kind) had a conflict with
the 'DK_' (designator kind) in init.c, so change the prefix to 'DLK_'.
The new name for dinfo_t is decl_level, which is more expressive.

No functional change.
2023-06-30 21:39:54 +00:00
rillig e50dbdf451 lint: fix handling of unnamed struct/union members
The support for unnamed struct/union members that was added in decl.c
1.60 from 2015-10-13 was simple but wrong. It didn't cover initializers
of these structures and computed wrong sizes for structures containing
anonymous unions. At that time, the handling of initializers was broken
as well, it was fixed 6 years later in init.c 1.229 from 2021-12-22.

Real-life examples for code that lint couldn't handle are:

	* external/bsd/jemalloc/dist/src/jemalloc.c
	* external/mit/xorg/lib/dri.old/Makefile
2023-06-30 21:06:18 +00:00
rillig 54af47c51a lint: replace macro for unique identifiers with function
No functional change.
2023-06-30 19:43:00 +00:00
rillig f6c9a3ff5c lint: clean up handling of declarations
No functional change.
2023-06-30 19:10:49 +00:00
rillig fc9c97fa4c tests/lint: extend tests for sizeof and alignof 2023-06-30 16:39:17 +00:00
rillig cb8166a1d1 lint: fix computation of bit-field width
When bit-fields in packed structs were added on 2009-10-02, lint assumed
that they would only use 'signed int' or 'unsigned int' as storage unit,
even though C99 also allows _Bool.

The cleanup commit for decl.c 1.225 from 2021-08-28 accidentally changed
the rounding mode for bit-field storage units from round-up to
round-down.
2023-06-30 15:19:09 +00:00
rillig 5c829ba167 lint: clean up packing of structs and unions
No functional change outside debug mode.
2023-06-30 14:39:23 +00:00
rillig 1033a23783 lint: clean up tree.c
No functional change.
2023-06-30 12:21:25 +00:00
rillig 9ae9809bbf lint: make alignof(incomplete enum) an error 2023-06-30 09:26:03 +00:00
rillig bf86468d4c tests/lint: add more tests for sizeof, offsetof, alignof 2023-06-30 09:21:52 +00:00
rillig 4b06b87ea3 lint: use NULL for null pointer constants
No binary change.
2023-06-30 08:48:38 +00:00
rillig 082684fd88 lint: add query for assigning an integer 0 to a pointer 2023-06-30 08:45:22 +00:00
rillig 7aaf3a0593 tests/lint: extend test for sizeof and offsetof 2023-06-30 08:03:01 +00:00
rillig 10704a6fff tests/lint: demonstrate bugs in anonymous struct/union handling 2023-06-30 07:18:02 +00:00
gutteridge 275519e238 PosixDaemon.c: restore NetBSD logging additions lost in merges
Restore part of local modifications r. 1.2 & 1.4 from tsarna@. One
aspect could not be carried forward, as Apple dropped the bug detection
query functionality that was formerly represented by the teststate
member of the DNSServer struct. Otherwise, reapplied almost verbatim,
except for minor consistency and style changes.

This was added again in part as an example should there be a need to
add further logging content for NetBSD's purposes. (DumpStateLog() has
changed further as of Apple's 1790.80.10 release, but should we roll
forward, our means here should still be viable.)
2023-06-30 02:03:58 +00:00
gutteridge 2bc969b373 PosixDaemon.c: convert tabs to spaces to match coding style
Match Apple's coding style for this project. (In part for those of us
who have tabs visually representing four spaces!)
2023-06-30 01:59:45 +00:00
gutteridge 5388ce56e6 Add npflog.4 to sets 2023-06-30 00:48:03 +00:00
gutteridge a1ca5a5447 prepare-import.sh: fix grammar in a comment 2023-06-29 23:59:43 +00:00
gutteridge 01c3b8a04d 3RDPARTY: note latest version of mDNSResponder 2023-06-29 23:52:50 +00:00
gutteridge c5615faf33 npflog.4: add and adjust some details
Add details about the header structure (though the if_npflog.h file is
not presently installed and has a _KERNEL guard). Also adjust some
sentences (requested by riastradh@), and include the original OpenBSD
RCS ID, since much of this content shares that origin.
2023-06-29 23:20:02 +00:00
rillig 742ee62757 lint: clean up member names of declaration levels
No functional change outside debug mode.
2023-06-29 22:52:44 +00:00
nia 3c60e71e80 ch-ch-changes 2023-06-29 21:46:47 +00:00
andvar 7281dd49bd s/determin /determine / in comment. 2023-06-29 21:01:21 +00:00
nia 7956bcaf80 aiomixer(1): Support the informal NO_COLOR standard.
When the NO_COLOR environment variable is set, no ANSI colours will
be displayed.

https://no-color.org/
2023-06-29 19:06:54 +00:00
riastradh d378359a95 vis(3): Avoid nonportable MIN in portable code. 2023-06-29 16:11:31 +00:00
manu 2035893213 Primary bootstrap is now able to read a GPT inside RAIDframe.
Previously, primary bootstrap was able to boot on RAID-1 RAIDframe set
with the limitation that the FFS filesystem had to start at bloc 0 in the
RAID. That allowed inner RAID partitionning with a disklabel, but not with
a GPT.

When booting on a RAID-1 RAIDframe, primary bootstrap now first try a
filesystem at bloc 0 of the RAID as before. On failure, it tries to
read a GPT and load secondary bootstrap from, by priority;
1) the first partition with the bootme attribute set
2) the first partition of type FFS, LFS, CCD or CGD
3) the first partition present in the GPT
2023-06-29 14:18:58 +00:00
rillig 8744a961da lint: use standard terminology for bit-field width
No functional change.
2023-06-29 12:52:06 +00:00
rillig a0a9ca021c lint: clean up initialization of type properties
No functional change.
2023-06-29 10:31:32 +00:00
rillig 0d2b0d606f lint: clean up function names
No functional change.
2023-06-29 09:58:36 +00:00
rillig 7d05a54d9c lint: enhance debug output for diagnostics
Only print the debug message if the diagnostic is active, which is
relevant for c99ism, c11ism and gnuism.

Print more details about the diagnostic or query.
2023-06-29 05:47:41 +00:00