Commit Graph

18819 Commits

Author SHA1 Message Date
christos 945f88fd2e put back the new gdb 2023-08-09 14:57:19 +00:00
mrg 832d47522a introduce new GCC 12 warning disables and use them in a few places
this introduces 4 new warning disable flags:

   CC_WNO_MISSING_TEMPLATE_KEYWORD
   CC_WNO_REGISTER
   CC_WNO_STRINGOP_OVERREAD
   CC_WNO_ARRAY_BOUNDS

and documents them in README.warnings.  of these, the string op
and array bounds are both problematic (real bugs) and also spurious
(not real bugs), and the other 2 are mostly temporary for older
3rd party code.

add some new uses of CC_WNO_STRINGOP_OVERFLOW.

fix m68k build for gallium and GCC 12.
2023-08-08 06:27:31 +00:00
mrg 69fe22838c put amd64 back to GDB 11. it doesn't build for me, or others.
the first problem is that this rule:

GDBvn.texi: ${DIST}/gdb/version.in
	echo "@set GDBVN $$(${TOOL_CAT} ${.ALLSRC})" > ${.TARGET}

conflicts with the "GDBvn.texi" in the source tree and fail to write
this file with r/o source trees.

the second problem is that gdbserver fails to link because it compiles
the wrong file to create target.o.  this seems like a very bad make or
bsd.*.mk bug -- "SRCS= .. target.cc ...", and yet, make manages to
compile the file "target.c" to create target.o, and then the required
symbols the rest of gdbserver needs are missing.

the third problem is that when you make it build the right target.cc,
it wants bfd.h, and gmp.h, and even after solving those issues, i'm
still getting a fourth issue linking gdbserver and thus reverting.
2023-08-08 03:44:12 +00:00
riastradh ce8aefde95 style(5): Advise against new struct typedefs and explain why.
Proposed on tech-kern:
https://mail-index.netbsd.org/tech-kern/2023/07/11/msg028950.html

Positive feedback to general concept, negative feedback to specifics
and phrasing of the first iteration but no objections to latest
iteration after several weeks at:
https://mail-index.netbsd.org/tech-kern/2023/07/16/msg028994.html
2023-08-07 18:01:42 +00:00
riastradh 138a94ebea rnd(4): Document `entropy: best effort' in random(4). 2023-08-07 06:27:37 +00:00
christos acba6b74f4 switch gdb to 13.20 for x86_64 2023-08-06 20:44:49 +00:00
jschauma 503ec6d006 +RAT register allocation table 2023-08-04 15:42:09 +00:00
riastradh 3586ae1d3b entropy(9): Simplify stages. Split interrupt vs non-interrupt paths.
- Nix the entropy stage (cold, warm, hot).  Just use the usual kernel
  `cold' (cold: single-core, single-thread; interrupts may happen),
  and don't make any three-way distinction about whether interrupts
  or threads or other CPUs can be running.

  Instead, while cold, use splhigh/splx or forbid paths to come from
  interrupt context, and while warm, use mutex or the per-CPU hard
  and soft interrupt paths for low latency.  This comes at a small
  cost to some interrupt latency, since we may stir the pool in
  interrupt context -- but only for a very short window early at boot
  between configure and configure2, so it's hard to imagine it
  matters much.

- Allow rnd_add_uint32 to run in hard interrupt context or with spin
  locks held, but defer processing to softint and drop samples on the
  floor if buffer is full.  This is mainly used for cheaply tossing
  samples from drivers for non-HWRNG devices into the entropy pool,
  so it is often used from interrupt context and/or under spin locks.

- New rnd_add_data_intr provides the interrupt-like data entry path
  for arbitrary buffers and driver-specified entropy estimates: defer
  processing to softint and drop samples on the floor if buffer is
  full.

- Document that rnd_add_data is forbidden under spin locks outside
  interrupt context (will crash in LOCKDEBUG), and inadvisable in
  interrupt context (but technically permitted just in case there are
  compatibility issues for now); later we can forbid it altogether in
  interrupt context or under spin locks.

- Audit all uses of rnd_add_data to use rnd_add_data_intr where it
  might be used in interrupt context or under a spin lock.

This fixes a regression from last year when the global entropy lock
was changed from IPL_VM (spin) to IPL_SOFTSERIAL (adaptive).  Thought
I'd caught all the problems from that, but another one bit three
different people this week, presumably because of recent changes that
led to more non-HWRNG drivers entering the entropy consolidation
path from rnd_add_uint32.

In my attempt to preserve the rnd(9) API for the (now long-since
abandoned) prospect of pullup to netbsd-9 in my rewrite of the
entropy subsystem in 2020, I didn't introduce a separate entry point
for entering entropy from interrupt context or equivalent, i.e., spin
locks held, and instead made rnd_add_data rely on cpu_intr_p() to
decide whether to process the whole sample under a lock or only take
as much as there's buffer space for before scheduling a softint.  In
retrospect, that was a mistake (though perhaps not as much of a
mistake as other entropy API decisions...), a mistake which is
finally getting rectified now by rnd_add_data_intr.

XXX pullup-10
2023-08-04 07:38:53 +00:00
gutteridge ee4f5428fe acronyms.comp: add ONCE 2023-08-04 03:59:00 +00:00
rin f91ef6a605 bsd.own.mk: Revert CC_WNO_USE_AFTER_FREE
This is an undefined behavior in general. Implementation details of
pointer are not defined in C standards; it is not necessarily address
of memory objects.

Pointed out by uwe@. Thanks!!
2023-08-03 14:55:54 +00:00
rin da04be2518 bsd.own.mk: Introduce CC_WNO_USE_AFTER_FREE for GCC12
-Wuse-after-free for GCC 12 is premature. It fires on a common idiom:

	newbuf = realloc(buf, size);
	p = newbuf + (p - buf);

Let shut this up for GCC 12 (with hoping it gets improved for 13!).
2023-08-03 13:33:26 +00:00
gutteridge c12abbe8a5 acronyms.comp: add MLO, MMC, SPL
It takes a lot of acronyms to boot a kernel!
2023-08-03 02:32:16 +00:00
riastradh c59176887b percpu(9): percpu_create ctor may be called later, not synchronously. 2023-08-02 06:24:46 +00:00
andvar 538aaa59ec s/diabled/disabled/. 2023-08-01 20:41:48 +00:00
andvar 4d6b356985 s/intrerrupt/interrupt/. 2023-08-01 20:39:15 +00:00
mrg 718c7faca0 we skipped GCC 11, so change the test to GCC 12. 2023-08-01 06:52:06 +00:00
rin e38fc7d6bc web2: sort -f, dedup. Fix ATF failure for nbperf(1). 2023-08-01 03:28:53 +00:00
christos ea52ff2b8a we ended up importing 13.2 2023-07-31 17:35:31 +00:00
tsutsui 2d72037083 Use proper variables for interface names in examples. 2023-07-31 16:09:01 +00:00
dholland 1482d081f7 web2: restore snit, accidentally lost in -r1.49 2023-07-31 05:36:41 +00:00
dholland 9252c23337 web2: since we seem to be accumulating personal names in here, add a bunch. 2023-07-31 05:35:44 +00:00
wiz d9edfcdd69 New sentence, new line. 2023-07-30 00:11:32 +00:00
gdt ee36da189c nvmm(4): Document that VMX Unrestricted Guest is required 2023-07-29 23:11:50 +00:00
lukem 07c42e4bc2 bsd.own.mk: force MKSTRIPSYM=no if MKDEBUG=yes
Local symbols are desirable with MKDEBUG=yes, so don't strip them.
Per request from mrg@
2023-07-23 16:52:37 +00:00
lukem cff541e1aa bsd.own.mk: style: block comments, move CC_flag vars
Add #{ .. #} block comments to a long conditional.

Move the CC_flag variables closer to other compiler-related
variables instead of being in the middle of some arch-specific
overrides.
2023-07-23 16:49:29 +00:00
lukem 3575dfc126 bsd.README: sync with mk.conf(5), deduping entries
Remove most duplication of variables already documented in mk.conf(5).
Add lists of supported and obsolete mk.conf(5) variables
so that searches in this document at least find them
(as per BUILDING).

Sync text from mk.conf(5) for entries that remain.
Explicitly document DESTDIR and RELEASEDIR.

Replace MKMAN=no antipattern with NOMAN=.

Consistently use "option" versus "flag"; option is more generic,
and may include a flag with an argument.
2023-07-22 18:50:31 +00:00
lukem e19f50d0d4 mk.conf(5): tweak BUILDID and option. sort MKKDEBUG
Clarify BUILDID behaviour with OBJMACHINE, and remove unnecessary sentence.
Use option not flag; option may include a flag with an argument.
Sort MKKDEBUG before MKKERBEROS4.
2023-07-22 18:49:40 +00:00
riastradh 17503da2a0 bsd.own.mk: Use MACHINE_ARCH for default MKCTF/MKDTRACE=yes x86.
The substantive impact of this is that it enables MKCTF=yes for Xen
kernels.  This is a change because, when building a Xen kernel
(XEN3_DOM0, XEN3_DOMU), MACHINE is set to `xen', not to `i386' or
`amd64', so the conditional never took effect.

(The side effect of setting MKDTRACE=yes when building Xen kernels is
unlikely to matter; that affects module and userland builds.)

PR port-xen/57535

XXX pullup-10
2023-07-21 20:03:13 +00:00
gutteridge 7a42da0231 entropy.7: add a missing word to a sentence
While here, bump the date to reflect when substantive changes were last
made.
2023-07-20 04:16:14 +00:00
riastradh 17cc32643c signal(7): Clarify semantics of SIGCHLD with SIG_IGN or SA_NOCLDWAIT.
The semantics is not just a nonportable hack for SysV compatibility;
it is enshrined in POSIX.

Related: PR 57527
2023-07-17 14:20:19 +00:00
riastradh 5524172f85 kern: Make time_second and time_uptime macros that work atomically.
These use atomic load on platforms with atomic 64-bit load, and
seqlocks on platforms without.

This has the unfortunate side effect of slightly reducing the real
times available on 32-bit platforms, from ending some time in the
year 584942417218 AD, available on 64-bit platforms, to ending some
time in the year 584942417355 AD.  But during that slightly shorter
time, 32-bit platforms can avoid bugs arising from non-atomic access
to time_uptime and time_second.

Note: All platforms still have non-atomic access problems for
bintime, binuptime, nanotime, nanouptime, &c.  This can be addressed
by putting a seqlock around timebasebin and possibly some other
variable -- to be done in a later change.

XXX kernel ABI change -- deleting symbols
2023-07-17 12:55:20 +00:00
riastradh 5aec88eaa6 signal(7): Clarify quirky SysV-inspired SIGCHLD semantics.
Suggest a portable alternative approach for detaching subprocesses.

Break wall of text into paragraphs while here.
2023-07-15 13:49:26 +00:00
rillig 7c7ed4e6a2 versioningsyscalls.9: fix typo 2023-07-14 09:03:37 +00:00
uwe d412d6c0f7 versioningsyscalls(9): wrap long line in the example 2023-07-10 23:55:13 +00:00
christos 63191be3a4 Forgot to commit the expanded userland portion 2023-07-10 15:54:18 +00:00
riastradh 70ecadb004 ddb: New `show all tstiles' command.
Shows who's waiting for which locks and what the owner is up to.

XXX pullup-10
2023-07-09 17:10:47 +00:00
uwe e200f46a48 versioningsyscalls(9): markup fixes
While here, fix the pasto for the new ino_t and time_t size.
2023-07-09 00:29:49 +00:00
christos e706571b76 Document how system call versioning is done. From this summer's compat-linux
GSoC, by Theodore Preduta.
2023-07-08 16:14:11 +00:00
riastradh 3271fbd4fa curcpu_stable(9): New function for asserting curcpu() is stable. 2023-07-08 13:59:05 +00:00
uwe 92446808ba heartbeat(9): markup fixes
Use .Cd for options.  Don't use the usual <space><tab>, which is
superfluous in the man page.  Paragraph break after the config section
of synopsis, before the C API section.
2023-07-07 15:56:31 +00:00
riastradh 10acd8549e heartbeat(9): Fix grammaro in man page. 2023-07-07 13:19:30 +00:00
wiz 04c9d4b262 Replace main(9) reference with code location 2023-07-07 13:15:00 +00:00
wiz 7057286892 Sort SEE ALSO 2023-07-07 12:59:45 +00:00
riastradh 12861a663c heartbeat(9): New mechanism to check progress of kernel.
This uses hard interrupts to check progress of low-priority soft
interrupts, and one CPU to check progress of another CPU.

If no progress has been made after a configurable number of seconds
(kern.heartbeat.max_period, default 15), then the system panics --
preferably on the CPU that is stuck so we get a stack trace in dmesg
of where it was stuck, but if the stuckness was detected by another
CPU and the stuck CPU doesn't acknowledge the request to panic within
one second, the detecting CPU panics instead.

This doesn't supplant hardware watchdog timers.  It is possible for
hard interrupts to be stuck on all CPUs for some reason too; in that
case heartbeat(9) has no opportunity to complete.

Downside: heartbeat(9) relies on hardclock to run at a reasonably
consistent rate, which might cause trouble for the glorious tickless
future.  However, it could be adapted to take a parameter for an
approximate number of units that have elapsed since the last call on
the current CPU, rather than treating that as a constant 1.

XXX kernel revbump -- changes struct cpu_info layout
2023-07-07 12:34:49 +00:00
jschauma becf7fe907 +CAC - cryptographic access control 2023-07-06 21:10:15 +00:00
lukem 0ae90b729a mk.conf(5): document rump variables
Update mk.conf(5) with the rump variables from
- lib/librumpuser/README.compileopts
- sys/rump/README.compileopts

Add cross-references back to mk.conf(5) in those files.

Ensure that the Default: is listed last in a description,
for consistency with the convention in this file.
2023-07-05 16:40:33 +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
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
gutteridge 5388ce56e6 Add npflog.4 to sets 2023-06-30 00:48:03 +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