Home | History | Annotate | only in /src/tests/lib/libc/gen
History log of /src/tests/lib/libc/gen
RevisionDateAuthorComments
 1.61 15-Sep-2025  riastradh ctype(3): New environment variable LIBC_ALLOWCTYPEABUSE.

If set, this does not force the ctype(3) functions to crash when
passed invalid inputs -- instead, they will return nonsense results,
and possibly print warnings to stderr, as is their right in
implementing undefined behaviour.

The nature of the nonsense results is unspecified. Currently, is*()
will always return true (even if that leads to mutually contradictory
conclusions, like isalpha and isdigit, or isgraph and isblank), and
tolower/toupper() will always return EOF. But perhaps in the future
the results may be randomized.

This way, if an application like firefox crashes on ctype abuse, you
can opt to accept the consequences of nonsense results instead by
running `env LIBC_ALLOWCTYPEABUSE= firefox' until the application is
fixed.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.60 22-Apr-2025  nia branches: 1.60.2;
Add basic tests for timespec_get(3), timespec_getres(3)

PR standards/58608
 1.59 30-Mar-2025  riastradh ctype(3): Disable guard page in static libc.

Adding the guard page may have overflown several small installation
media. Let's try to keep this case small.

Update the tests to detect the cases where we will be running against
a libc without a guard page on the LC_CTYPE=C tables, and skip
testing abuse detection when it would rely on the guard page.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.58 28-Mar-2025  riastradh t_ctype: New test for ctype(3) functions/macros.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.57 13-Mar-2025  riastradh execve(2), posix_spawn(2): Add test case for an embarrassing bug.

PR kern/58091: after fork/execve or posix_spawn, parent kill(child,
SIGTERM) has race condition making it unreliable
 1.56 27-Aug-2024  riastradh arc4random(3): Add automatic tests.

This verifies that:
- arc4random zeroes its state and reseeds itself on fork
- arc4random reseeds itself on entropy consolidation (e.g., VM clone)
- arc4random falls back to global state if it can't allocate local
state because address space limits cause mmap to fail

NOTE: This adds a new libc symbol __arc4random_global, but it's in
the reserved namespace and only used by t_arc4random, so no libc
minor bump.

PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork
 1.55 31-May-2022  riastradh branches: 1.55.2; 1.55.4;
libc: Reintroduce getentropy.

This was introduced two years ago when the getrandom/getentropy API
question was still open, and removed because the discussion was
ongoing. Now getentropy is more widely adopted and soon to be in
POSIX. So reintroduce the symbol into libc since we'll be keeping it
anyway. Discussion of details of the semantics, as interpreted by
NetBSD, is ongoing, but the symbol needs to get in before the
netbsd-10 branch. The draft POSIX text is
(https://www.opengroup.org/austin/docs/austin_1110.pdf):

SYNOPSIS
#include <unistd.h>

int getentropy(void *buffer, size_t length);

DESCRIPTION
The getentropy() function shall write length bytes of data
starting at the location pointed to by buffer. The output
shall be unpredictable high quality random data, generated by
a cryptographically secure pseudo-random number
generator. The maximum permitted value for the length
argument is given by the {GETENTROPY_MAX} symbolic constant
defined in <limits.h>.

RETURN VALUES
Upon successful completion, getentropy() shall return 0;
otherwise, -1 shall be retunred and errno set to indicate the
error.

ERRORS
The getentropy() function shall fail if:

[EINVAL] The value of length is greater than
{GETENTROPY_MAX}.

The getentropy() function may fail if:

[ENOSYS] The system does not provide the necessary
source of entropy.

RATIONALE
The getentropy() function is not a cancellation point.

Minor changes from the previous introduction of getentropy into libc:

- Return EINVAL, not EIO, on buflen > 256.
- Define GETENTROPY_MAX in limits.h.

The declaration of getentropy in unistd.h and definition of
GETENTROPY_MAX in limits.h are currently conditional on
_NETBSD_SOURCE. When the next revision of POSIX is finalized, we can
expose them also under _POSIX_C_SOURCE > 20yymmL as usual -- and this
can be done as a pullup without breaking existing compiled programs.
 1.54 22-Feb-2020  kamil Update t_siginfo.c build rules

Add logic for MKSANITIZER/MKLIBCSANITIZER checks.
 1.53 26-Apr-2019  maya -frounding-math is gcc specific, help clang builds
 1.52 24-Apr-2019  christos PR/54000: Andreag Gustafsson: Compile the rounding test with
-fround-math since with gcc-7, the default mode ignores fenv settings
(the same effect can be achieved with -O0 :-)

https://gcc.gnu.org/wiki/FloatingPointMath
 1.51 09-Feb-2017  christos branches: 1.51.12;
remove exect, it will not be fixed and it will be removed.
 1.50 09-Dec-2016  kamil branches: 1.50.2;
Attach t_exect to ATF tests and distribution

Add missing SIGTRAP handler. Assert there that the signal is SIGTRAP as
expected and si_code TRAP_TRACE.

This test will break on some ports that have dummy or incomplete
implementation of exect(2).

This test works on amd64 correctly.

Sponsored by <The NetBSD Foundation>
 1.49 22-Dec-2015  christos branches: 1.49.2;
Add __TEST_FENV
 1.48 22-Dec-2015  christos Put have fenv elsewhere.
 1.47 22-Dec-2015  martin Sync list of fenv enabled architectures again (PR 48633), this time for mips
addition.
 1.46 21-Dec-2015  martin While PR 48633 is not properly fixed, keep the additional lists of
fenv-enabled architectures in sync.
 1.45 08-Jul-2015  matt Build t_fpgetmask/t_fpgetround for aarch64 since they are now in libc
 1.44 27-Dec-2014  martin Enable fenv for arm
 1.43 10-Aug-2014  martin Do not set HAVE_FENV for arm as long as it misses feenableexcept().
 1.42 10-Aug-2014  martin Use the same condition for HAVE_FENV
 1.41 10-Aug-2014  matt Changes to existing files to enable building AARCH64 userland.
evbarm64-el
This is clang only. While gcc4.8 supports aarch64, no netbsd support has
been written for aarch64 with gcc4.8.
 1.40 29-Apr-2014  uebayasi Minimal execve(2) ATF test.
 1.39 30-Jan-2014  joerg branches: 1.39.2;
Add test for uint64 to real long double conversion.
 1.38 08-Nov-2012  pgoyette Convert old src/regress/timer&waiter tests to ATF
 1.37 13-Apr-2012  njoly branches: 1.37.2;
Do not re-add -mieee option on alpha, it's already set by default.
 1.36 18-Mar-2012  jruoho Add a case for PR lib/41558. It is unclear whether this is a bug, but at
least it is documented now. Probably it would be better to follow Linux,
where the test case does not fail.
 1.35 17-Mar-2012  jruoho Add few basic tests for realpath(3).
 1.34 13-Feb-2012  martin Move posix_spawn tests to lib/libc/gen/posix_spawn - they test both libc
and kernel, but that is an implementation detail unrelated to the tests
themselfs.
Ok: releng
 1.33 08-Nov-2011  jruoho Few naive checks for cpuset(3) and ftok(3).
 1.32 05-Nov-2011  jruoho Few naive checks for time(3).
 1.31 30-Sep-2011  christos branches: 1.31.2;
Make the rounding test work properly, and actually test the rounding modes.
 1.30 19-Sep-2011  jruoho Move duplicate ldexp(3) test out from the tests/libc.
 1.29 19-Sep-2011  jruoho Move the tests/libc/ieeefp to tests/libc/gen to match the structure of libc.
Also rename the test files to gain functional scope.
 1.28 07-Jul-2011  jruoho Move 't_glob_star' to 't_glob' for glob(3).
 1.27 07-Jul-2011  jruoho Move 't_syslog_pthread' to 't_syslog' for consistency with libc.
 1.26 14-Jun-2011  jruoho Test that assert(3) works.
 1.25 03-Jun-2011  jruoho Test also setdomainname(3).
 1.24 02-Jun-2011  jruoho Few naive tests for sethostname(3).
 1.23 10-May-2011  jruoho branches: 1.23.2;
Few naive tests for pause(3).
 1.22 09-May-2011  jruoho Few basic tests for closefrom(3).
 1.21 05-May-2011  jruoho Try to mirror the real source with the test directory structure (otherwise
the latter carries a risk of becoming a difficult mess to manage.)
 1.20 05-May-2011  jruoho Few fundamental consistency checks for alarm(2).
 1.19 17-Apr-2011  jruoho Test nice(3) also with threads.
 1.18 10-Apr-2011  jruoho A naive test case for getcwd(3).
 1.17 05-Apr-2011  jruoho Add simple test cases for ttyname(3), strtod(3), and getgrent(3).
 1.16 04-Apr-2011  jruoho Few simple tests for nice(3).
 1.15 24-Mar-2011  jruoho Sort.
 1.14 24-Mar-2011  jruoho Add a naive test case for raise(3).
 1.13 13-Jan-2011  pgoyette Continuing the (re)organization of the lib/libc atf regression tests
 1.12 02-Jan-2011  pgoyette One more reference to HAVE_SIGINFO bites the dust
 1.11 01-Jan-2011  pgoyette Build t_ldexp test always. The test itself determines if it is running
on an unsupported platform (vax) and exits.
 1.10 28-Dec-2010  pgoyette Fix name of t_ldexp test from previous
 1.9 28-Dec-2010  pgoyette Don't build ldexp tests on vax
 1.8 28-Dec-2010  pgoyette Migrate the ldexp test to atf
 1.7 28-Dec-2010  pgoyette Migrate the remaining libc/gen tests to atf
 1.6 25-Dec-2010  pgoyette Correctly added the conditional part, but now need to remove the original
unconditional part.
 1.5 25-Dec-2010  pgoyette Don't include the siginfo tests unless we actually have siginfo ability!
 1.4 25-Dec-2010  pgoyette Move the siginfo tests from regress to atf. While here, add a new test
for PR/43655.

XXX The sigchild_dump test currently fails when execute under atf-run.
XXX It does not fail when executed directly from the shell, so there's
XXX something in atf that prevents the child process from dumping.
 1.3 22-Dec-2010  pgoyette Migrate a couple more tests from the old regress structure to atf
 1.2 17-Dec-2010  pooka Add an isolated test case for PR lib/44248.
 1.1 06-Sep-2010  christos Add tests for GLOB_STAR
 1.23.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.31.2.4 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.31.2.3 16-Jan-2013  yamt sync with (a bit old) head
 1.31.2.2 17-Apr-2012  yamt sync with head
 1.31.2.1 10-Nov-2011  yamt sync with head
 1.37.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.37.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.39.2.1 10-Aug-2014  tls Rebase.
 1.49.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.49.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.50.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.51.12.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.51.12.1 10-Jun-2019  christos Sync with HEAD
 1.55.4.1 02-Aug-2025  perseant Sync with HEAD
 1.55.2.1 09-Oct-2024  martin Pull up following revision(s) (requested by riastradh in ticket #939):

distrib/sets/lists/debug/module.md.amd64: revision 1.18
sys/modules/Makefile: revision 1.292
lib/libc/gen/arc4random.c: revision 1.34
lib/libc/gen/arc4random.c: revision 1.35
lib/libc/gen/arc4random.c: revision 1.36
lib/libc/gen/arc4random.c: revision 1.37
sys/kern/kern_entropy.c: revision 1.70
lib/libc/gen/arc4random.c: revision 1.38
sys/kern/kern_entropy.c: revision 1.71
lib/libc/gen/getentropy.3: revision 1.8
distrib/sets/lists/modules/md.amd64: revision 1.103
share/man/man4/rnd.4: revision 1.42
share/man/man4/rnd.4: revision 1.44
lib/libc/include/arc4random.h: revision 1.1
distrib/sets/lists/man/mi: revision 1.1786
sys/arch/i386/conf/GENERIC: revision 1.1258
sys/modules/acpivmgenid/acpivmgenid.ioconf: revision 1.1
sys/arch/amd64/conf/ALL: revision 1.190
distrib/sets/lists/debug/mi: revision 1.446
sys/arch/i386/conf/ALL: revision 1.521
lib/libc/gen/Makefile.inc: revision 1.219
distrib/sets/lists/debug/module.md.i386: revision 1.12
sys/dev/acpi/acpi_vmgenid.c: revision 1.1
sys/dev/acpi/acpi_vmgenid.c: revision 1.2
lib/libc/include/reentrant.h: revision 1.22
sys/arch/evbarm/conf/GENERIC64: revision 1.219
share/man/man4/Makefile: revision 1.735
distrib/sets/lists/modules/md.i386: revision 1.100
distrib/sets/lists/tests/mi: revision 1.1334
lib/libc/gen/arc4random.3: revision 1.22
sys/dev/acpi/files.acpi: revision 1.133
lib/libc/gen/arc4random.3: revision 1.23
tests/lib/libc/gen/t_arc4random.c: revision 1.1
sys/sys/entropy.h: revision 1.6
sys/arch/amd64/conf/GENERIC: revision 1.614
sys/modules/acpivmgenid/Makefile: revision 1.1
share/man/man4/acpivmgenid.4: revision 1.1
lib/libc/gen/Makefile.inc: revision 1.220
tests/lib/libc/gen/Makefile: revision 1.56
share/man/man4/acpivmgenid.4: revision 1.2
share/man/man4/acpivmgenid.4: revision 1.3

(all via patch)

Catch up with all the lint warnings since exit on warning was disabled.

Disable 'missing header declaration' and 'nested extern' warnings for now.
acpivmgenid(4): New driver for virtual machine generation ID.

Added to amd64/ALL and i386/ALL kernel configurations, and made
available as a loadable module acpivmgenid.kmod on x86, for now.
TBD: Add to all ACPI-supporting GENERIC kernels.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

entropy(9): Factor out subroutines to reset and gather entropy.
`Reset' means we keep the data in the pool, but assume it had zero
entropy. `Gather' means we request samples from all on-demand
sources and wait for the synchronous ones to complete.

No functional change intended, other than to expose new symbols --
just preparation to expose these to acpivmgenid(4), so it can use
these when the VM host notifies us that we, the guest, have been
cloned.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

acpivmgenid(4): Reset and gather entropy on VM clone notification.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random(3): Reseed if system entropy epoch changes.
This can happen, for example, if the system is a VM instance, and the
VM is cloned.

This incurs the cost of a system call on every arc4random call, which
is unfortunate, but
1. we don't currently have a (machine-independent) mechanism for
exposing a read-only page to userland shared by the kernel to
enable a cheaper access path to the entropy epoch; and
2. the algorithm here -- a simple application of ChaCha -- is likely
also a bottleneck and could be much cheaper by
(a) using sys/crypto/chacha for machine-dependent vectorized
ChaCha code, and
(b) filling a buffer (somewhere between a cipher block and a page)
in a batch at a time, instead of running ChaCha to generate
only 32 bytes at a time.
So although this might be a performance hit, the security benefit is
worthwhile and we have a clear path to do better than reversing the
performance hit later.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

acpivmgenid(4): Nix BUGS that have been squashed.
Reference kern.entropy.epoch for the remaining bug (which is a
performance issue, not a security issue).
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

entropy(9): Allow unprivileged reads of sysctl kern.entropy.epoch.

Applications need this in order to know when to reseed. (We should
also expose it through a page shared read-only with userland for
cheaper access, but until we do, let's let applications get at it
through sysctl.)
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random.c: Fix test program.

This isn't wired up anywhere, but let's reduce the bitrot. It was
helpful in reminding me that kern.entropy.epoch was, for reasons I
can't remember, restricted to privileged access.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

amd64, evbarm, i386: Add acpivmgenid(4) to GENERIC.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

rnd(4): Document kern.entropy.epoch is unprivileged and elaborate.
Cross-reference acpivmgenid(4).
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random(3): Note that arc4random respects kern.entropy.epoch.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork
Add debug info for new acpivmgenid module

arc4random(3): Add automatic tests.

This verifies that:
- arc4random zeroes its state and reseeds itself on fork
- arc4random reseeds itself on entropy consolidation (e.g., VM clone)
- arc4random falls back to global state if it can't allocate local
state because address space limits cause mmap to fail

NOTE: This adds a new libc symbol __arc4random_global, but it's in
the reserved namespace and only used by t_arc4random, so no libc
minor bump.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

getentropy(3): Note intent to reseed on VM clone, and caveats.

Tidy markup and pacify some mandoc -Tlint complaints while here.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

Bump dates on man pages recently updated to mention VM clones.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random(3): Pacify some of lint's complaints.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random: suppress another lint warning
 1.60.2.1 01-Oct-2025  martin Pull up following revision(s) (requested by riastradh in ticket #45):

tests/lib/libc/gen/t_ctype.c: revision 1.12
lib/libc/gen/ctype_.c: revision 1.24
lib/libc/locale/rune.c: revision 1.50
tests/lib/libc/gen/Makefile: revision 1.61
lib/libc/gen/tolower_.c: revision 1.18
lib/libc/gen/isctype.c: revision 1.29
distrib/sets/lists/tests/mi: revision 1.1394
lib/libc/gen/toupper_.c: revision 1.18
lib/libc/gen/ctype_guard.h: revision 1.8
lib/libc/locale/Makefile.inc: revision 1.69
lib/libc/gen/ctype.3: revision 1.32
lib/libc/gen/ctype.3: revision 1.33
distrib/sets/lists/debug/mi: revision 1.486
tests/lib/libc/gen/h_ctype_abuse.c: revision 1.1
tests/lib/libc/gen/h_ctype_abuse.c: revision 1.2

ctype(3): New environment variable LIBC_ALLOWCTYPEABUSE.

If set, this does not force the ctype(3) functions to crash when
passed invalid inputs -- instead, they will return nonsense results,
and possibly print warnings to stderr, as is their right in
implementing undefined behaviour.

The nature of the nonsense results is unspecified. Currently, is*()
will always return true (even if that leads to mutually contradictory
conclusions, like isalpha and isdigit, or isgraph and isblank), and
tolower/toupper() will always return EOF. But perhaps in the future
the results may be randomized.

This way, if an application like firefox crashes on ctype abuse, you
can opt to accept the consequences of nonsense results instead by
running `env LIBC_ALLOWCTYPEABUSE= firefox' until the application is
fixed.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
ctype(3): Document LIBC_ALLOWCTYPEABUSE.

If this is pulled up to netbsd-11, we should tweak the text to make
it apply to 11 too.
PR lib/58208: ctype(3) provides poor runtime feedback of abuse

ctype(3): Fix build of tests on machines with unsigned char.
Could maybe phrase this better but this'll do for now.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.1 13-Mar-2025  riastradh branches: 1.1.4;
execve(2), posix_spawn(2): Fix build of tests after previous.

Forgot to add a file.

PR kern/58091: after fork/execve or posix_spawn, parent kill(child,
SIGTERM) has race condition making it unreliable
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 13-Mar-2025  perseant file Makefile.inc was added on branch perseant-exfatfs on 2025-08-02 05:58:04 +0000
 1.2 15-Sep-2025  riastradh branches: 1.2.2;
ctype(3): Fix build of tests on machines with unsigned char.

Could maybe phrase this better but this'll do for now.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.1 15-Sep-2025  riastradh ctype(3): New environment variable LIBC_ALLOWCTYPEABUSE.

If set, this does not force the ctype(3) functions to crash when
passed invalid inputs -- instead, they will return nonsense results,
and possibly print warnings to stderr, as is their right in
implementing undefined behaviour.

The nature of the nonsense results is unspecified. Currently, is*()
will always return true (even if that leads to mutually contradictory
conclusions, like isalpha and isdigit, or isgraph and isblank), and
tolower/toupper() will always return EOF. But perhaps in the future
the results may be randomized.

This way, if an application like firefox crashes on ctype abuse, you
can opt to accept the consequences of nonsense results instead by
running `env LIBC_ALLOWCTYPEABUSE= firefox' until the application is
fixed.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.2.2.2 01-Oct-2025  martin Pull up following revision(s) (requested by riastradh in ticket #45):

tests/lib/libc/gen/t_ctype.c: revision 1.12
lib/libc/gen/ctype_.c: revision 1.24
lib/libc/locale/rune.c: revision 1.50
tests/lib/libc/gen/Makefile: revision 1.61
lib/libc/gen/tolower_.c: revision 1.18
lib/libc/gen/isctype.c: revision 1.29
distrib/sets/lists/tests/mi: revision 1.1394
lib/libc/gen/toupper_.c: revision 1.18
lib/libc/gen/ctype_guard.h: revision 1.8
lib/libc/locale/Makefile.inc: revision 1.69
lib/libc/gen/ctype.3: revision 1.32
lib/libc/gen/ctype.3: revision 1.33
distrib/sets/lists/debug/mi: revision 1.486
tests/lib/libc/gen/h_ctype_abuse.c: revision 1.1
tests/lib/libc/gen/h_ctype_abuse.c: revision 1.2

ctype(3): New environment variable LIBC_ALLOWCTYPEABUSE.

If set, this does not force the ctype(3) functions to crash when
passed invalid inputs -- instead, they will return nonsense results,
and possibly print warnings to stderr, as is their right in
implementing undefined behaviour.

The nature of the nonsense results is unspecified. Currently, is*()
will always return true (even if that leads to mutually contradictory
conclusions, like isalpha and isdigit, or isgraph and isblank), and
tolower/toupper() will always return EOF. But perhaps in the future
the results may be randomized.

This way, if an application like firefox crashes on ctype abuse, you
can opt to accept the consequences of nonsense results instead by
running `env LIBC_ALLOWCTYPEABUSE= firefox' until the application is
fixed.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
ctype(3): Document LIBC_ALLOWCTYPEABUSE.

If this is pulled up to netbsd-11, we should tweak the text to make
it apply to 11 too.
PR lib/58208: ctype(3) provides poor runtime feedback of abuse

ctype(3): Fix build of tests on machines with unsigned char.
Could maybe phrase this better but this'll do for now.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.2.2.1 15-Sep-2025  martin file h_ctype_abuse.c was added on branch netbsd-11 on 2025-10-01 17:41:14 +0000
 1.1 13-Mar-2025  riastradh branches: 1.1.4;
execve(2), posix_spawn(2): Add test case for an embarrassing bug.

PR kern/58091: after fork/execve or posix_spawn, parent kill(child,
SIGTERM) has race condition making it unreliable
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 13-Mar-2025  perseant file h_execsig.c was added on branch perseant-exfatfs on 2025-08-02 05:58:04 +0000
 1.6 15-Dec-2021  gson When running the tests under "qemu -accel kvm" on a Linux host,
isQEMU_TCG() should return false. Fixes multiple test cases that were
failing with "Test case was expecting a failure but none were raised"
on that platform.
 1.5 23-Aug-2020  gson Provide separate functions to check for running under qemu in general
and for running under qemu's built-in TCG CPU emulation (as opposed to
hardware virtualization via NVMM or KVM).
 1.4 03-Jan-2015  gson Need stdlib.h for EXIT_FAILURE
 1.3 14-Apr-2013  martin branches: 1.3.2; 1.3.8; 1.3.10;
Mark the test function as inline, so we don't get warnings if it is not
actually used.
 1.2 12-Apr-2013  christos don't pay for sysctl if we don't have to.
 1.1 12-Apr-2013  christos easier way to find if we are on qemu.
 1.3.10.1 12-Jan-2015  snj Pull up following revision(s) (requested by gson in ticket #413):
tests/lib/libc/gen/isqemu.h: revision 1.4
Need stdlib.h for EXIT_FAILURE
 1.3.8.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.3.8.1 14-Apr-2013  yamt file isqemu.h was added on branch yamt-pagecache on 2014-05-22 11:42:20 +0000
 1.3.2.2 23-Jun-2013  tls resync from head
 1.3.2.1 14-Apr-2013  tls file isqemu.h was added on branch tls-maxphys on 2013-06-23 06:28:56 +0000
 1.2 10-May-2011  jruoho Fix comment/string typos.
 1.1 05-May-2011  jruoho Few fundamental consistency checks for alarm(2).
 1.5 09-Mar-2025  riastradh branches: 1.5.4;
arc4random(3): Provide a fallback in case pthread_atfork fails.

This is considerably more work and burden on testing than simply
statically preallocating a bit of storage for pthread_atfork to
eliminate the failure mode altogether, but it is less work than
arguing further over the atfork interface:
https://mail-index.NetBSD.org/source-changes-d/2025/03/02/msg014387.html

PR lib/59117: arc4random has some failure modes it shouldn't
 1.4 06-Mar-2025  riastradh t_arc4random: Test arc4random_global.per_thread, not .initialized.

If arc4random_initialize has been called, and thr_keycreate failed,
then .initialized will be true but .per_thread will be false -- and
.thread_key will be garbage (some other thread key for another
purpose, most likely). This path was enabled by allowing
thr_keycreate to fail instead of aborting the process.

This hasn't caused trouble yet, mainly because we don't do anything
to inject faults into thr_keycreate in these tests. Tweak the
global_threadkeylimit test while here to provoke a crash with the
wrong conditional.

Fix a similar edge case in the little test program embedded in
arc4random.c (which should maybe just go away now that we have atf
tests).

PR lib/59117: arc4random has some failure modes it shouldn't
 1.3 05-Mar-2025  riastradh t_arc4random: Verify arc4random works without fds.

It must work in an empty chroot where /dev/urandom doesn't exist, and
it must work when the file descriptor resource limit is exceeded.

Prompted by discussion around:

PR lib/59117: arc4random has some failure modes it shouldn't

Fortunately these are not failure modes of the current arc4random
implementation! But it is important to test them nevertheless, to
forestall any temptation to invent new failure modes.
 1.2 02-Mar-2025  riastradh arc4random(3): Avoid failure due to thread key limits.

If thr_keycreate (a.k.a. pthread_key_create) fails, fall back to
using globally serialized state instead of per-thread state. This is
unlikely to happen but arc4random(3) should work even if it does.
New test case forces exercising this path (at least, simulating the
effect of key creation failure).

PR lib/59117: arc4random has some failure modes it shouldn't
 1.1 27-Aug-2024  riastradh branches: 1.1.2;
arc4random(3): Add automatic tests.

This verifies that:
- arc4random zeroes its state and reseeds itself on fork
- arc4random reseeds itself on entropy consolidation (e.g., VM clone)
- arc4random falls back to global state if it can't allocate local
state because address space limits cause mmap to fail

NOTE: This adds a new libc symbol __arc4random_global, but it's in
the reserved namespace and only used by t_arc4random, so no libc
minor bump.

PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork
 1.1.2.2 09-Oct-2024  martin Pull up following revision(s) (requested by riastradh in ticket #939):

distrib/sets/lists/debug/module.md.amd64: revision 1.18
sys/modules/Makefile: revision 1.292
lib/libc/gen/arc4random.c: revision 1.34
lib/libc/gen/arc4random.c: revision 1.35
lib/libc/gen/arc4random.c: revision 1.36
lib/libc/gen/arc4random.c: revision 1.37
sys/kern/kern_entropy.c: revision 1.70
lib/libc/gen/arc4random.c: revision 1.38
sys/kern/kern_entropy.c: revision 1.71
lib/libc/gen/getentropy.3: revision 1.8
distrib/sets/lists/modules/md.amd64: revision 1.103
share/man/man4/rnd.4: revision 1.42
share/man/man4/rnd.4: revision 1.44
lib/libc/include/arc4random.h: revision 1.1
distrib/sets/lists/man/mi: revision 1.1786
sys/arch/i386/conf/GENERIC: revision 1.1258
sys/modules/acpivmgenid/acpivmgenid.ioconf: revision 1.1
sys/arch/amd64/conf/ALL: revision 1.190
distrib/sets/lists/debug/mi: revision 1.446
sys/arch/i386/conf/ALL: revision 1.521
lib/libc/gen/Makefile.inc: revision 1.219
distrib/sets/lists/debug/module.md.i386: revision 1.12
sys/dev/acpi/acpi_vmgenid.c: revision 1.1
sys/dev/acpi/acpi_vmgenid.c: revision 1.2
lib/libc/include/reentrant.h: revision 1.22
sys/arch/evbarm/conf/GENERIC64: revision 1.219
share/man/man4/Makefile: revision 1.735
distrib/sets/lists/modules/md.i386: revision 1.100
distrib/sets/lists/tests/mi: revision 1.1334
lib/libc/gen/arc4random.3: revision 1.22
sys/dev/acpi/files.acpi: revision 1.133
lib/libc/gen/arc4random.3: revision 1.23
tests/lib/libc/gen/t_arc4random.c: revision 1.1
sys/sys/entropy.h: revision 1.6
sys/arch/amd64/conf/GENERIC: revision 1.614
sys/modules/acpivmgenid/Makefile: revision 1.1
share/man/man4/acpivmgenid.4: revision 1.1
lib/libc/gen/Makefile.inc: revision 1.220
tests/lib/libc/gen/Makefile: revision 1.56
share/man/man4/acpivmgenid.4: revision 1.2
share/man/man4/acpivmgenid.4: revision 1.3

(all via patch)

Catch up with all the lint warnings since exit on warning was disabled.

Disable 'missing header declaration' and 'nested extern' warnings for now.
acpivmgenid(4): New driver for virtual machine generation ID.

Added to amd64/ALL and i386/ALL kernel configurations, and made
available as a loadable module acpivmgenid.kmod on x86, for now.
TBD: Add to all ACPI-supporting GENERIC kernels.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

entropy(9): Factor out subroutines to reset and gather entropy.
`Reset' means we keep the data in the pool, but assume it had zero
entropy. `Gather' means we request samples from all on-demand
sources and wait for the synchronous ones to complete.

No functional change intended, other than to expose new symbols --
just preparation to expose these to acpivmgenid(4), so it can use
these when the VM host notifies us that we, the guest, have been
cloned.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

acpivmgenid(4): Reset and gather entropy on VM clone notification.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random(3): Reseed if system entropy epoch changes.
This can happen, for example, if the system is a VM instance, and the
VM is cloned.

This incurs the cost of a system call on every arc4random call, which
is unfortunate, but
1. we don't currently have a (machine-independent) mechanism for
exposing a read-only page to userland shared by the kernel to
enable a cheaper access path to the entropy epoch; and
2. the algorithm here -- a simple application of ChaCha -- is likely
also a bottleneck and could be much cheaper by
(a) using sys/crypto/chacha for machine-dependent vectorized
ChaCha code, and
(b) filling a buffer (somewhere between a cipher block and a page)
in a batch at a time, instead of running ChaCha to generate
only 32 bytes at a time.
So although this might be a performance hit, the security benefit is
worthwhile and we have a clear path to do better than reversing the
performance hit later.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

acpivmgenid(4): Nix BUGS that have been squashed.
Reference kern.entropy.epoch for the remaining bug (which is a
performance issue, not a security issue).
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

entropy(9): Allow unprivileged reads of sysctl kern.entropy.epoch.

Applications need this in order to know when to reseed. (We should
also expose it through a page shared read-only with userland for
cheaper access, but until we do, let's let applications get at it
through sysctl.)
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random.c: Fix test program.

This isn't wired up anywhere, but let's reduce the bitrot. It was
helpful in reminding me that kern.entropy.epoch was, for reasons I
can't remember, restricted to privileged access.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

amd64, evbarm, i386: Add acpivmgenid(4) to GENERIC.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

rnd(4): Document kern.entropy.epoch is unprivileged and elaborate.
Cross-reference acpivmgenid(4).
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random(3): Note that arc4random respects kern.entropy.epoch.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork
Add debug info for new acpivmgenid module

arc4random(3): Add automatic tests.

This verifies that:
- arc4random zeroes its state and reseeds itself on fork
- arc4random reseeds itself on entropy consolidation (e.g., VM clone)
- arc4random falls back to global state if it can't allocate local
state because address space limits cause mmap to fail

NOTE: This adds a new libc symbol __arc4random_global, but it's in
the reserved namespace and only used by t_arc4random, so no libc
minor bump.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

getentropy(3): Note intent to reseed on VM clone, and caveats.

Tidy markup and pacify some mandoc -Tlint complaints while here.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

Bump dates on man pages recently updated to mention VM clones.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random(3): Pacify some of lint's complaints.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random: suppress another lint warning
 1.1.2.1 27-Aug-2024  martin file t_arc4random.c was added on branch netbsd-10 on 2024-10-09 13:25:13 +0000
 1.5.4.2 02-Aug-2025  perseant Sync with HEAD
 1.5.4.1 09-Mar-2025  perseant file t_arc4random.c was added on branch perseant-exfatfs on 2025-08-02 05:58:04 +0000
 1.3 10-Jan-2017  christos PR/51807: Ngie Cooper: disable core file generation in :assert_false,
:assert_true
 1.2 14-Jun-2011  jruoho branches: 1.2.2; 1.2.26;
Avoid ATF_REQUIRE() inside a child process.
 1.1 14-Jun-2011  jruoho Test that assert(3) works.
 1.2.26.1 20-Mar-2017  pgoyette Sync with HEAD
 1.2.2.2 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.2.2.1 14-Jun-2011  cherry file t_assert.c was added on branch cherry-xenmp on 2011-06-23 14:20:39 +0000
 1.2 07-Jul-2011  jruoho Rename some test case names for consistency. No functional change.
 1.1 22-Dec-2010  pgoyette Migrate a couple more tests from the old regress structure to atf
 1.5 12-Apr-2022  andvar s/sould/should/ and s/shoud/should/
 1.4 11-May-2011  jruoho Adjust.
 1.3 09-May-2011  jruoho On a second thought, require that close(2) fails for a descriptor already
closed with closefrom(3). For some odd reason (yet to be determined), this
check fails on 5.99.51 (amd64).
 1.2 09-May-2011  jruoho Remove superfluous close(2) pointed out by martin@.
 1.1 09-May-2011  jruoho Few basic tests for closefrom(3).
 1.1 08-Nov-2011  jruoho branches: 1.1.2;
Few naive checks for cpuset(3) and ftok(3).
 1.1.2.2 10-Nov-2011  yamt sync with head
 1.1.2.1 08-Nov-2011  yamt file t_cpuset.c was added on branch yamt-pagecache on 2011-11-10 14:31:52 +0000
 1.12 15-Sep-2025  riastradh ctype(3): New environment variable LIBC_ALLOWCTYPEABUSE.

If set, this does not force the ctype(3) functions to crash when
passed invalid inputs -- instead, they will return nonsense results,
and possibly print warnings to stderr, as is their right in
implementing undefined behaviour.

The nature of the nonsense results is unspecified. Currently, is*()
will always return true (even if that leads to mutually contradictory
conclusions, like isalpha and isdigit, or isgraph and isblank), and
tolower/toupper() will always return EOF. But perhaps in the future
the results may be randomized.

This way, if an application like firefox crashes on ctype abuse, you
can opt to accept the consequences of nonsense results instead by
running `env LIBC_ALLOWCTYPEABUSE= firefox' until the application is
fixed.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.11 30-Mar-2025  riastradh branches: 1.11.2; 1.11.4;
ctype(3): Disable guard page in static libc.

Adding the guard page may have overflown several small installation
media. Let's try to keep this case small.

Update the tests to detect the cases where we will be running against
a libc without a guard page on the LC_CTYPE=C tables, and skip
testing abuse detection when it would rely on the guard page.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.10 29-Mar-2025  riastradh ctype(3): Put guard pages before the C ctype/tolower/toupper tables.

This also only affects machines where char is signed for now. (But
maybe it would be worth doing unconditionally; users could still try
to pass in explicit `signed char' inputs.)

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.9 29-Mar-2025  riastradh ctype(3): Summon a demon from caller's nose if abused out-of-line.

This way, applications which opt for the out-of-line functions will
crash with a potentially meaningful message to stderr if they pass
inputs on which the ctype(3) functions are undefined. (If fd 2 is
something else, tough -- this is nasal demon country, and they fly
where they please, application intent be damned.)

This probably won't catch many applications -- but it might catch C++
applications at runtime that can't be caught at build-time because
they eschew the macros.

The cost is a single predicted-not-taken branch -- it's checking c
for membership in the interval [-1,0xff] when we're already computing
c + 1, so it can be a single unsigned-compare. By deferring the
message and abort to an out-of-line function we avoid a stack frame
in the good case. And this is for the unlikely, out-of-line versions
of the ctype(3) functions -- most applications get the inline macros.
So I'm not concerned by the prospect of a performance impact.

Update the tests so they recognize SIGABRT as noisy failure too, not
just SIGSEGV.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.8 28-Mar-2025  riastradh t_ctype: More const is more better!

No functional change intended -- we never intended to write to this
array anyway.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.7 28-Mar-2025  riastradh t_ctype: Factor loop out of macro-generated functions.

No functional change intended.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.6 28-Mar-2025  riastradh t_ctype: Test some more code points with potential for EOF confusion.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.5 28-Mar-2025  riastradh t_ctype: Include UCHAR_MAX in the range of inputs tested.

It should definitely be included because it is important to distinguish
it from EOF!

Noted by rillig@.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.4 28-Mar-2025  riastradh t_ctype: Test explicit setlocale(LC_CTYPE, "C").

And do so after other setlocales -- just in case this behaves
differently from the default environment before any setlocale.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.3 28-Mar-2025  riastradh libc: Put guard pages before locale ctype/tolower/toupper tables.

This way, triggering the undefined behaviour of negative inputs to
the ctype functions leads to instant SIGSEGV, rather than silently
giving bonkers (and likely nondeterministic) answers. (See ctype(3)
man page for details.)

This only affects non-default locales, i.e., locales other than C.
The C locale's tables are statically linked into libc, and the
symbols defining them are baked into the ABI, so putting a guard page
before them will require either some careful elven surgery (which is
a class I must have missed back in university), or copying them into
dynamically allocated memory (which is a cost I'm reluctant to incur
on all programs using libc).

This also only affects machines where char is signed for now. (But
maybe it would be worth doing unconditionally; users could still try
to pass in explicit `signed char' inputs.)

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.2 28-Mar-2025  riastradh t_ctype: Fix tests on platforms where char is unsigned.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.1 28-Mar-2025  riastradh t_ctype: New test for ctype(3) functions/macros.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.11.4.2 02-Aug-2025  perseant Sync with HEAD
 1.11.4.1 30-Mar-2025  perseant file t_ctype.c was added on branch perseant-exfatfs on 2025-08-02 05:58:04 +0000
 1.11.2.1 01-Oct-2025  martin Pull up following revision(s) (requested by riastradh in ticket #45):

tests/lib/libc/gen/t_ctype.c: revision 1.12
lib/libc/gen/ctype_.c: revision 1.24
lib/libc/locale/rune.c: revision 1.50
tests/lib/libc/gen/Makefile: revision 1.61
lib/libc/gen/tolower_.c: revision 1.18
lib/libc/gen/isctype.c: revision 1.29
distrib/sets/lists/tests/mi: revision 1.1394
lib/libc/gen/toupper_.c: revision 1.18
lib/libc/gen/ctype_guard.h: revision 1.8
lib/libc/locale/Makefile.inc: revision 1.69
lib/libc/gen/ctype.3: revision 1.32
lib/libc/gen/ctype.3: revision 1.33
distrib/sets/lists/debug/mi: revision 1.486
tests/lib/libc/gen/h_ctype_abuse.c: revision 1.1
tests/lib/libc/gen/h_ctype_abuse.c: revision 1.2

ctype(3): New environment variable LIBC_ALLOWCTYPEABUSE.

If set, this does not force the ctype(3) functions to crash when
passed invalid inputs -- instead, they will return nonsense results,
and possibly print warnings to stderr, as is their right in
implementing undefined behaviour.

The nature of the nonsense results is unspecified. Currently, is*()
will always return true (even if that leads to mutually contradictory
conclusions, like isalpha and isdigit, or isgraph and isblank), and
tolower/toupper() will always return EOF. But perhaps in the future
the results may be randomized.

This way, if an application like firefox crashes on ctype abuse, you
can opt to accept the consequences of nonsense results instead by
running `env LIBC_ALLOWCTYPEABUSE= firefox' until the application is
fixed.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
ctype(3): Document LIBC_ALLOWCTYPEABUSE.

If this is pulled up to netbsd-11, we should tweak the text to make
it apply to 11 too.
PR lib/58208: ctype(3) provides poor runtime feedback of abuse

ctype(3): Fix build of tests on machines with unsigned char.
Could maybe phrase this better but this'll do for now.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.11 19-Jun-2018  gson No semicolon after macro do ... while (0) wrapper.
 1.10 11-Jan-2017  christos branches: 1.10.12;
more error checks
 1.9 11-Jan-2017  christos fix mismatched paren, also the previous commit should say and check error
for -1.
 1.8 11-Jan-2017  christos wrap the macro in do/while.
 1.7 10-Jan-2017  christos PR/51808: Ngie Cooper: fix leaks, sort includes, check returns
 1.6 19-Oct-2013  christos branches: 1.6.8;
fix unused variable warnings
 1.5 18-Mar-2012  jruoho branches: 1.5.2;
To be on the safe side, use the category/number notation when referring to
PRs (otherwise third-party sed-scripts might miss the references). Also
remove white-space.
 1.4 07-Jul-2011  jruoho branches: 1.4.2;
Rename some test case names for consistency. No functional change.
 1.3 11-Jun-2011  christos Turn warns on for all tests and fix all the bugs.
 1.2 07-Apr-2011  jruoho branches: 1.2.2;
Remove the following (literal) text in the TNF copyrights:

* This code is derived from software contributed to The NetBSD Foundation
* by
*

XXX: If these originated from you and you want your name to be mentioned,
please add it.
 1.1 28-Dec-2010  pgoyette Migrate the remaining libc/gen tests to atf
 1.2.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.4.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.4.2.1 17-Apr-2012  yamt sync with head
 1.5.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6.8.1 20-Mar-2017  pgoyette Sync with HEAD
 1.10.12.1 25-Jun-2018  pgoyette Sync with HEAD
 1.7 06-May-2024  riastradh tests/lib/libc/gen/t_floatunditf: Nix __HAVE_LONG_DOUBLE conditional.

Conversion from uint64_t to long double should work on all ports,
including those where long double is the same as double, i.e., where
__HAVE_LONG_DOUBLE is undefined.

Instead, conditionalize the test cases on how many bits of precision
long double has in the significand, according to LDBL_MANT_DIG. The
conditionals here should handle binary128, powerpc double-dekker
(~106-bit precision), x86 extended precision (80-bit), m68k extended
precision (80-bit), and VAX D (56-bit).
 1.6 04-Nov-2014  justin PR misc/49356 remove unnecessary references to atf-c/config.h

The function included via this header is not used and is removed in
later versions of atf, so let us avoid it.
 1.5 02-Feb-2014  martin branches: 1.5.4; 1.5.8;
Add a few more test values from the range that sparc64 previously would
have got wrong.
 1.4 01-Feb-2014  martin Skip testcase inside its body for architectures w/o long double support
 1.3 01-Feb-2014  martin Print a slightly more helpfull message in case of test failure
 1.2 30-Jan-2014  joerg No unused functions if there is no long double support.
 1.1 30-Jan-2014  joerg Add test for uint64 to real long double conversion.
 1.5.8.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.5.8.1 02-Feb-2014  tls file t_floatunditf.c was added on branch tls-maxphys on 2014-08-20 00:04:49 +0000
 1.5.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.5.4.1 02-Feb-2014  yamt file t_floatunditf.c was added on branch yamt-pagecache on 2014-05-22 11:42:20 +0000
 1.6 13-Apr-2024  rillig tests/fmtcheck: show that fmtcheck does not support "%2$s"
 1.5 13-Dec-2017  rin Revert rev 1.4: fmtcheck(3) neglect unused trailing arguments as before.
"%d" is a valid format string with default format string "%d %s", etc.
 1.4 07-Dec-2017  kre Correct a couple of broken test cases:
"%d" does not take the same args as "%d %s"
"%%" does not take the same args as "%llx"
How did these ever survive any kind of even basic sanity check?
 1.3 14-Jun-2014  apb Update fmtcheck(3) test now that pointers and longs are differentiated.
 1.2 07-Jul-2011  jruoho branches: 1.2.8; 1.2.18;
Rename some test case names for consistency. No functional change.
 1.1 28-Dec-2010  pgoyette Migrate the remaining libc/gen tests to atf
 1.2.18.1 10-Aug-2014  tls Rebase.
 1.2.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.7 31-Oct-2016  dholland Add another case related to the ones from PR 49278: [A-\\].
 1.6 12-Oct-2014  christos branches: 1.6.2;
You need double the number of backslashes in a pattern, since \\ -> '\' in
the string which means escape. Now the tests don't fail.
 1.5 12-Oct-2014  justin Add expect fail for PR lib/49278
 1.4 12-Oct-2014  justin Add some fnmatch test cases from other C library test suites
 1.3 08-Apr-2012  jruoho branches: 1.3.2;
Append few basic test cases.
 1.2 25-Mar-2012  christos PR/41558 has been fixed.
 1.1 18-Mar-2012  jruoho Add a case for PR lib/41558. It is unclear whether this is a bug, but at
least it is documented now. Probably it would be better to follow Linux,
where the test case does not fail.
 1.3.2.2 17-Apr-2012  yamt sync with head
 1.3.2.1 08-Apr-2012  yamt file t_fnmatch.c was added on branch yamt-pagecache on 2012-04-17 00:09:10 +0000
 1.6.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.8 08-Apr-2025  riastradh t_fpclassify: Fix build on vax after #if'ing out subnormal tests.

Must've neglected to compile-test this _on vax_, oops.

PR port-vax/59261: t_fpclassify tests are failing
 1.7 07-Apr-2025  riastradh tests: Use `#if __*_HAS_DENORM__', not `#ifdef __*_HAS_DENORM__'.

The compiler defines this to zero on, e.g., VAX.

PR port-vax/59261: t_fpclassify tests are failing
 1.6 09-May-2024  riastradh branches: 1.6.2;
tests/lib/libc/gen/t_fpclassify: Test fpclassify on non-IEEE754 too.

Just exclude the subnormal parts on non-IEEE754 architectures
according to __FLT/DBL/LDBL_HAS_DENORM__.
 1.5 09-May-2024  riastradh tests/lib/libc/gen/t_fpclassify: Spruce this up a bit.

Provide more useful diagnostics when tests fail.
 1.4 07-May-2024  riastradh tests/lib/libc/gen/t_fpclassify: Enable long double tests.

The necessary long double symbols should all be available now. If
there are any architectures where they're not, we can fix those
architectures.
 1.3 01-Oct-2011  christos branches: 1.3.44; 1.3.52;
add a missing E
 1.2 01-Oct-2011  christos use _FLOAT_IEEE754 instead of vax.
 1.1 19-Sep-2011  jruoho Move the tests/libc/ieeefp to tests/libc/gen to match the structure of libc.
Also rename the test files to gain functional scope.
 1.3.52.1 23-Aug-2024  martin Pull up following revision(s) (requested by riastradh in ticket #790):

tests/lib/libc/gen/t_fpclassify.c: revision 1.4
tests/lib/libc/gen/t_fpclassify.c: revision 1.5

tests/lib/libc/gen/t_fpclassify: Enable long double tests.

The necessary long double symbols should all be available now. If
there are any architectures where they're not, we can fix those
architectures.

tests/lib/libc/gen/t_fpclassify: Spruce this up a bit.
Provide more useful diagnostics when tests fail.
 1.3.44.2 23-Aug-2024  martin Back out previous - accidently commited to the wrong branch
 1.3.44.1 23-Aug-2024  martin Pull up following revision(s) (requested by riastradh in ticket #790):

tests/lib/libc/gen/t_fpclassify.c: revision 1.4
tests/lib/libc/gen/t_fpclassify.c: revision 1.5

tests/lib/libc/gen/t_fpclassify: Enable long double tests.

The necessary long double symbols should all be available now. If
there are any architectures where they're not, we can fix those
architectures.

tests/lib/libc/gen/t_fpclassify: Spruce this up a bit.
Provide more useful diagnostics when tests fail.
 1.6.2.1 02-Aug-2025  perseant Sync with HEAD
 1.22 14-May-2024  riastradh t_fpsetmask, t_fenv: Skip fp exception trap tests on RISC-V.

No architectural support for fp exception traps.

While here, make the macros behave a little better as C statements.
 1.21 23-Aug-2020  gson Expect failure only when running under qemu's TCG CPU emulation, not
when running under hardware virtualization such as qemu -accel nvmm.
 1.20 25-Apr-2019  kamil Fix typo in 'exceptions'
 1.19 30-Jan-2019  martin Clean up terminology: modern arm CPUs do properly implement IEEE 754
floating point exceptions - but some (actually all currently know ones)
do not implement sending traps when these exceptions are raised.

Pointed out by Peter Maydell.
 1.18 23-Jan-2019  martin There are aarch64 Cortex cpus that do not trap on some floating point
exceptions - so apply the arm handling for aarch64 as well.
 1.17 16-Dec-2018  sevan port-macppc/46319 is marked as resolved now.
Test on 8.99.26 build of NetBSD/macppc
 1.16 12-Mar-2016  martin branches: 1.16.14; 1.16.16;
Fix masking for the fpsetmask_basic test, pointed out by Timo Buhrmester
 1.15 18-Nov-2014  martin Skip the tests on ARM if the NEON fpu does not support exceptions (Cortex).
 1.14 04-Nov-2014  justin PR misc/49356 remove unnecessary references to atf-c/config.h

The function included via this header is not used and is removed in
later versions of atf, so let us avoid it.
 1.13 09-Feb-2014  jmmv Use compiler builtins instead of atf_arch and atf_machine.

The atf_arch and atf_machine configuration variables were removed from
atf-0.19 without me realizing that some tests were querying them directly.

Instead of reintroducing those variables, just rely on compiler builtins
as many other tests already do.

Should fix PR bin/48582.
 1.12 14-Apr-2013  martin Backout previous - which did not include the change described in the log
message anyway but pure accidental white space changes. The whole change
was not needed any more after fixing isqemu.h.
Thanks to agc for pointing it out.
 1.11 14-Apr-2013  martin Do not include isqemu.h if we are not going to use the test
 1.10 12-Apr-2013  christos easier way to find if we are on qemu.
 1.9 13-Apr-2012  jruoho branches: 1.9.2;
Xfail on qemu unconditionally after all.
 1.8 11-Apr-2012  jruoho Flip previous (i386/qemu fails, not the amd64/qemu).
 1.7 11-Apr-2012  jruoho Revisit the previous: fails on qemu/amd64 but not qemu/i386.
 1.6 11-Apr-2012  jruoho As it turned out, the fpsetmask(3) tests were unnecessarily skipped on Qemu.
Thus, remove xfails that do not trigger.
 1.5 10-Apr-2012  jruoho Do not skip the tests on Qemu, but point to PR misc/44767 instead.
 1.4 10-Apr-2012  jruoho Point to port-macppc/46319 when failing on macppc.
 1.3 19-Oct-2011  njoly branches: 1.3.2;
Add basic fpsetmask test to exercize setting/clearing bits.
 1.2 01-Oct-2011  christos use _FLOAT_IEEE754 instead of vax.
 1.1 19-Sep-2011  jruoho Move the tests/libc/ieeefp to tests/libc/gen to match the structure of libc.
Also rename the test files to gain functional scope.
 1.3.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.3.2.1 17-Apr-2012  yamt sync with head
 1.9.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.9.2.1 23-Jun-2013  tls resync from head
 1.16.16.1 10-Jun-2019  christos Sync with HEAD
 1.16.14.2 26-Jan-2019  pgoyette Sync with HEAD
 1.16.14.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.8 29-Oct-2024  riastradh fpsetround(3): Don't toggle all the other bits in fpcr on aarch64.

PR port-arm/58782: fpsetround flips all the other fpcsr bits on aarch64
 1.7 28-Oct-2024  riastradh fpsetround(3): Test that this doesn't flip on FTZ by accident.

PR port-arm/58782: fpsetround flips all the other fpcsr bits on aarch64
 1.6 01-Oct-2011  christos branches: 1.6.44; 1.6.52; 1.6.54;
use _FLOAT_IEEE754 instead of vax.
 1.5 30-Sep-2011  christos add more tests.
 1.4 30-Sep-2011  christos add symbolic name printing.
 1.3 30-Sep-2011  christos print stderr, when things go wrong.
 1.2 30-Sep-2011  christos Make the rounding test work properly, and actually test the rounding modes.
 1.1 19-Sep-2011  jruoho Move the tests/libc/ieeefp to tests/libc/gen to match the structure of libc.
Also rename the test files to gain functional scope.
 1.6.54.1 02-Aug-2025  perseant Sync with HEAD
 1.6.52.1 01-Nov-2024  martin Pull up following revision(s) (requested by rin in ticket #996):

tests/lib/libc/gen/t_fpsetround.c: revision 1.7
tests/lib/libc/gen/t_fpsetround.c: revision 1.8
lib/libc/arch/aarch64/gen/fpsetround.c: revision 1.4

fpsetround(3): Test that this doesn't flip on FTZ by accident.
PR port-arm/58782: fpsetround flips all the other fpcsr bits on aarch64

fpsetround(3): Don't toggle all the other bits in fpcr on aarch64.
PR port-arm/58782: fpsetround flips all the other fpcsr bits on aarch64
 1.6.44.1 20-Nov-2024  martin Pull up following revision(s) (requested by riastradh in ticket #1923):

tests/lib/libc/gen/t_fpsetround.c: revision 1.7
tests/lib/libc/gen/t_fpsetround.c: revision 1.8
lib/libc/arch/aarch64/gen/fpsetround.c: revision 1.4

fpsetround(3): Test that this doesn't flip on FTZ by accident.
PR port-arm/58782: fpsetround flips all the other fpcsr bits on aarch64

fpsetround(3): Don't toggle all the other bits in fpcr on aarch64.
PR port-arm/58782: fpsetround flips all the other fpcsr bits on aarch64
 1.3 16-Jul-2019  martin PR misc/54382: whenever open(2) is called with O_CREAT, make sure to
pass an open mode argument.
 1.2 10-Jan-2017  christos branches: 1.2.14;
PR/51809: Ngie Cooper: fix file descriptor leak
 1.1 08-Nov-2011  jruoho branches: 1.1.2; 1.1.24;
Few naive checks for cpuset(3) and ftok(3).
 1.1.24.1 20-Mar-2017  pgoyette Sync with HEAD
 1.1.2.2 10-Nov-2011  yamt sync with head
 1.1.2.1 08-Nov-2011  yamt file t_ftok.c was added on branch yamt-pagecache on 2011-11-10 14:31:52 +0000
 1.2.14.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.3 27-Jul-2011  jruoho As per PR bin/45180, do not traverse too deep.
 1.2 16-Jun-2011  joerg Use proper format strings.
 1.1 10-Apr-2011  jruoho branches: 1.1.2;
A naive test case for getcwd(3).
 1.1.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.1 31-May-2022  riastradh libc: Reintroduce getentropy.

This was introduced two years ago when the getrandom/getentropy API
question was still open, and removed because the discussion was
ongoing. Now getentropy is more widely adopted and soon to be in
POSIX. So reintroduce the symbol into libc since we'll be keeping it
anyway. Discussion of details of the semantics, as interpreted by
NetBSD, is ongoing, but the symbol needs to get in before the
netbsd-10 branch. The draft POSIX text is
(https://www.opengroup.org/austin/docs/austin_1110.pdf):

SYNOPSIS
#include <unistd.h>

int getentropy(void *buffer, size_t length);

DESCRIPTION
The getentropy() function shall write length bytes of data
starting at the location pointed to by buffer. The output
shall be unpredictable high quality random data, generated by
a cryptographically secure pseudo-random number
generator. The maximum permitted value for the length
argument is given by the {GETENTROPY_MAX} symbolic constant
defined in <limits.h>.

RETURN VALUES
Upon successful completion, getentropy() shall return 0;
otherwise, -1 shall be retunred and errno set to indicate the
error.

ERRORS
The getentropy() function shall fail if:

[EINVAL] The value of length is greater than
{GETENTROPY_MAX}.

The getentropy() function may fail if:

[ENOSYS] The system does not provide the necessary
source of entropy.

RATIONALE
The getentropy() function is not a cancellation point.

Minor changes from the previous introduction of getentropy into libc:

- Return EINVAL, not EIO, on buflen > 256.
- Define GETENTROPY_MAX in limits.h.

The declaration of getentropy in unistd.h and definition of
GETENTROPY_MAX in limits.h are currently conditional on
_NETBSD_SOURCE. When the next revision of POSIX is finalized, we can
expose them also under _POSIX_C_SOURCE > 20yymmL as usual -- and this
can be done as a pullup without breaking existing compiled programs.
 1.2 11-May-2011  njoly Typo in error message.
 1.1 05-Apr-2011  jruoho Add simple test cases for ttyname(3), strtod(3), and getgrent(3).
 1.10 13-Mar-2020  rillig t_glob.c: clean up test code

In struct vfs_file, using an int as a boolean is an anachronism and has
been replaced with a single-character file type, like in ls(1).

Some other redundant test code has been removed as well since it was
either unreachable or existed only for performance reasons.
 1.9 13-Mar-2020  rillig t_glob.c: add test cases for hidden directory and file

The existing test code was geared towards every little bit of
performance. It even duplicated the file definitions in vfs_stat in order
to avoid a few strcmp calls. This made the test code fragile. Therefore,
vfs_stat has been rewritten completely to not duplicate any information
from the vfs.

In vfs_stat, the returned st_mode is now more realistic. It had been 0
before. The file mode is only logged when it makes sense. In the ENOENT
case it is not logged anymore.

The debug logging for opendir/closedir now logs the same pointer, so that
the corresponding calls can be matched easily. Failed vfs_opendir calls
are logged as well, to get a more complete picture of which callbacks are
called.
 1.8 13-Mar-2020  rillig t_glob.c: use distinct names for test structures

Before, the structures and functions defined by the test used the same
prefix as the code to be tested. This made it difficult to draw a line
between these parts.
 1.7 13-Mar-2020  rillig t_glob.c: move expected globbing result directly into the test cases

This makes the tests more self-contained. The example directory tree that
is common to all the tests is still defined elsewhere, but in the same
file. Setting up the example directory structure in each test would make
the tests even more independent and read.
 1.6 26-Apr-2017  christos branches: 1.6.10;
- add range tests
- be more descriptive about errors
 1.5 14-Jan-2017  christos branches: 1.5.4;
PR/51825: Ngie Cooper: use the non _ version of the macro
 1.4 13-Jan-2017  christos Don't play with "../.." in includes for h_macros.h; deal with it centrally.
Minor fixes.
 1.3 02-Jan-2013  martin branches: 1.3.12;
Remove check for GLOB_NOCHECK - the behaviour has been changed again, so it
will return a modified pattern.
 1.2 18-Dec-2012  christos - make our stat function return ENOENT if a file is not found.
- add a GLOB_NOMATCH check
 1.1 07-Jul-2011  jruoho branches: 1.1.2; 1.1.8;
Move 't_glob_star' to 't_glob' for glob(3).
 1.1.8.1 25-Feb-2013  tls resync with head
 1.1.2.1 23-Jan-2013  yamt sync with head
 1.3.12.1 20-Mar-2017  pgoyette Sync with HEAD
 1.5.4.1 02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.6.10.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.8 07-Jul-2011  jruoho Move 't_glob_star' to 't_glob' for glob(3).
 1.7 07-Jul-2011  jruoho Rename some test case names for consistency. No functional change.
 1.6 03-Nov-2010  christos add Makefile.inc everywhere so that we can set WARNS=4 by default. Amazing
how many bugs this found :-)
 1.5 13-Oct-2010  pooka Use actual buffer size instead of sizeof(char *). Makes the test
work on non-64bit platforms.
 1.4 13-Oct-2010  pooka fix -DDEBUG
 1.3 11-Oct-2010  christos use "RZ()" instead of ATF_CHECK(), since ATF_CHECK does not deal with errno.
This is repulsive, specially the part about hard-coding the h_macros.h file
in the c code.
 1.2 11-Oct-2010  christos don't use err(), from pooka.
CV: ----------------------------------------------------------------------
 1.1 06-Sep-2010  christos Add tests for GLOB_STAR
 1.10 11-Mar-2019  kre Explicitly test for PR lib/54053

A suitable test was actually there already - but the results
were not verified. So just add a test that the result string
is what is expected. (Previously for len==128 and bytes==10000
it would have returned "0E" now it returns 10000 as it should.)
 1.9 10-Jan-2017  christos branches: 1.9.14;
PR/51810: Ngie Cooper: don't leak buf
 1.8 18-Mar-2012  jruoho branches: 1.8.14;
To be on the safe side, use the category/number notation when referring to
PRs (otherwise third-party sed-scripts might miss the references). Also
remove white-space.
 1.7 17-Mar-2012  christos This does not fail anymore. Explain why the test was modified.
 1.6 15-Mar-2012  joerg Mark w_printf as __printflike and fix a format string error.
 1.5 07-Jul-2011  jruoho branches: 1.5.2; 1.5.4;
Rename some test case names for consistency. No functional change.
 1.4 11-Jun-2011  christos Turn warns on for all tests and fix all the bugs.
 1.3 06-Apr-2011  jruoho branches: 1.3.2;
Mark this also as expected failure.
 1.2 06-Apr-2011  jruoho Formally verify the numerous bugs in humanize_number(3).
From PR lib/44097, by yamt@.
 1.1 28-Dec-2010  pgoyette Migrate the remaining libc/gen tests to atf
 1.3.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.5.4.1 17-Mar-2012  bouyer Pull up following revision(s) (requested by joerg in ticket #119):
tests/lib/libc/stdio/t_printf.c: revision 1.5
tests/lib/libc/stdio/t_scanf.c: revision 1.2
tests/lib/libc/gen/t_humanize_number.c: revision 1.6
Mark w_printf as __printflike and fix a format string error.
Fix format strings to properly quote %.
 1.5.2.1 17-Apr-2012  yamt sync with head
 1.8.14.1 20-Mar-2017  pgoyette Sync with HEAD
 1.9.14.1 10-Jun-2019  christos Sync with HEAD
 1.6 07-Apr-2025  riastradh tests/lib/libc/gen/t_isnan: Fix architecture conditionals.

1. Skip isinf_basic on VAX. We have no other way to query `does this
architecture support infinities?' and other tests already use
isinf(HUGE_VAL) to determine that, so let's just make sure it
works correctly on VAX.

2. Don't skip these tests on m68k. This was originally conditional
on m68000 (which is to say, NetBSD's MACHINE_ARCH for Motorola
68010 CPUs, i.e., the sun2 port), and was later mistakenly changed
to m68k. But there's no reason any m68k, 68010 or later, should
skip this -- the floating-point format of the ABI does have NaN
and infinity, whether it's a softfloat ABI or hardfloat ABI.

PR misc/59266: t_isnan:isinf_basic test is bogus on some ports
 1.5 04-Nov-2014  justin branches: 1.5.28;
PR misc/49356 remove unnecessary references to atf-c/config.h

The function included via this header is not used and is removed in
later versions of atf, so let us avoid it.
 1.4 09-Feb-2014  jmmv Use compiler builtins instead of atf_arch and atf_machine.

The atf_arch and atf_machine configuration variables were removed from
atf-0.19 without me realizing that some tests were querying them directly.

Instead of reintroducing those variables, just rely on compiler builtins
as many other tests already do.

Should fix PR bin/48582.
 1.3 16-Sep-2013  martin Retry previous
 1.2 16-Sep-2013  martin Make it compile on archs where NAN is not defined - previously it only
compiled by chance (and details of the __isnan macro) on vax.
 1.1 19-Sep-2011  jruoho branches: 1.1.2; 1.1.8;
Move the tests/libc/ieeefp to tests/libc/gen to match the structure of libc.
Also rename the test files to gain functional scope.
 1.1.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.5.28.1 02-Aug-2025  perseant Sync with HEAD
 1.6 19-Sep-2011  jruoho Move duplicate ldexp(3) test out from the tests/libc.
 1.5 07-Apr-2011  jruoho Remove the following (literal) text in the TNF copyrights:

* This code is derived from software contributed to The NetBSD Foundation
* by
*

XXX: If these originated from you and you want your name to be mentioned,
please add it.
 1.4 20-Feb-2011  jmmv Adjust tests now that the values of atf_arch and atf_machine have been
reversed to carry their real intended meanings.

This is part of PR bin/44305.
 1.3 03-Jan-2011  pgoyette branches: 1.3.2;
Don't run FP Exception tests under qemu - they don't work.

While here, properly skip certain tests on vax architecture. (It is
not legal to have a test-program with zero test cases, so each test
case needs to check-and-skip.)
 1.2 01-Jan-2011  pgoyette Build t_ldexp test always. The test itself determines if it is running
on an unsupported platform (vax) and exits.
 1.1 28-Dec-2010  pgoyette Migrate the ldexp test to atf
 1.3.2.1 05-Mar-2011  bouyer Sync with HEAD
 1.8 18-Mar-2012  jruoho Move the references to PRs from code comments to the test description. Once
ATF has the ability to output the metadata in the HTML reports, it should be
easy to traverse between releng and gnats -reports via links.
 1.7 01-May-2011  jruoho branches: 1.7.4;
PR lib/42587 was fixed; remove xfail.
 1.6 25-Apr-2011  njoly In nice_err testcase, use ATF_REQUIRE_ERRNO.
 1.5 17-Apr-2011  jruoho Test nice(3) also with threads.
 1.4 10-Apr-2011  jruoho "wrong return value" -> "wrong errno".
 1.3 06-Apr-2011  jruoho As there is PR lib/42587, mark tiny POSIX error as expected failure.
 1.2 04-Apr-2011  jruoho Use _exit(2).
 1.1 04-Apr-2011  jruoho Few simple tests for nice(3).
 1.7.4.1 17-Apr-2012  yamt sync with head
 1.1 10-May-2011  jruoho Few naive tests for pause(3).
 1.6 03-Nov-2016  kamil Prefer modern simple past tense and past participle of catch

The "catched" form is obsolete and nonstandard, prefer "caught".
 1.5 10-May-2011  jruoho branches: 1.5.26;
Add also a simplistic stress unit test.
 1.4 09-May-2011  jruoho Add one more naive unit test.
 1.3 05-Apr-2011  jruoho Rename some tests. No functional change.
 1.2 30-Mar-2011  jruoho Add missing __RCSID(3).
 1.1 24-Mar-2011  jruoho Add a naive test case for raise(3).
 1.5.26.1 04-Nov-2016  pgoyette Sync with HEAD
 1.5 07-Mar-2015  isaki Reduce the number of loops.
It avoids timeout on slow machines, and I think that 100,000
times loop also satisfies the evaluation.
PR lib/49664 (no comments)
 1.4 14-Feb-2015  isaki uint64_t -> uint32_t. 32bit is sufficient in this case
and it improved the performance approx 7% on my 68030.
see also PR lib/49664.
 1.3 07-Jul-2011  jruoho Rename some test case names for consistency. No functional change.
 1.2 13-Jan-2011  pgoyette Repair some printf formats
 1.1 13-Jan-2011  pgoyette Continuing the (re)organization of the lib/libc atf regression tests
 1.3 05-May-2011  jruoho Try to mirror the real source with the test directory structure (otherwise
the latter carries a risk of becoming a difficult mess to manage.)
 1.2 07-Apr-2011  jruoho Remove the following (literal) text in the TNF copyrights:

* This code is derived from software contributed to The NetBSD Foundation
* by
*

XXX: If these originated from you and you want your name to be mentioned,
please add it.
 1.1 28-Dec-2010  pgoyette Migrate the remaining libc/gen tests to atf
 1.2 27-Mar-2012  njoly branches: 1.2.2;
Adjust the memset size to not override the nul byte at the end of buffer
array.
 1.1 17-Mar-2012  jruoho Add few basic tests for realpath(3).
 1.2.2.2 17-Apr-2012  yamt sync with head
 1.2.2.1 27-Mar-2012  yamt file t_realpath.c was added on branch yamt-pagecache on 2012-04-17 00:09:10 +0000
 1.2 25-Mar-2012  joerg Be UTF8 clean.
 1.1 03-Jun-2011  jruoho branches: 1.1.2; 1.1.4;
Test also setdomainname(3).
 1.1.4.1 17-Apr-2012  yamt sync with head
 1.1.2.2 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.1.2.1 03-Jun-2011  cherry file t_setdomainname.c was added on branch cherry-xenmp on 2011-06-23 14:20:39 +0000
 1.3 25-Mar-2012  joerg Be UTF8 clean.
 1.2 02-Jun-2011  jruoho branches: 1.2.2; 1.2.4;
Cleanup.
 1.1 02-Jun-2011  jruoho Few naive tests for sethostname(3).
 1.2.4.1 17-Apr-2012  yamt sync with head
 1.2.2.2 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.2.2.1 02-Jun-2011  cherry file t_sethostname.c was added on branch cherry-xenmp on 2011-06-23 14:20:39 +0000
 1.55 04-Sep-2024  rin t_siginfo:adraln: Brush up skip message for x86

Note that:

1. No data address is reported back for alignment check exception, as per
Intel SDM (June 2024).

2. Kernel sets faulting PC to si_addr.

3. 2. is compliant to siginfo(2), at least:

> For SIGILL, SIGFPE, SIGBUS and SIGSEGV ... si_addr contains
> the address of the faulting instruction or data and ...

4. IEEE Std 1003.1-2024 does not require si_addr for SIGBUS. For SIGILL
and SIGSEGV, e.g., it is required (SHALL) to store faulting PC and
data address, respectively, on the other hand.
 1.54 04-Sep-2024  rin t_siginfo:sigbus_adraln: Skip rather than expect_fail on x86

This is an architecture-defined behavior, not a failure.
 1.53 29-Jun-2024  rin branches: 1.53.2;
t_siginfo: sigbus_adraln: Skip for vax

According to "VAX Architecture Handbook", misaligned access does
not trap, although it has performance penalty.
 1.52 20-May-2024  riastradh t_siginfo: More volatile to prevent optimization.
 1.51 14-May-2024  riastradh t_siginfo: Use volatile to prevent optimization.
 1.50 14-May-2024  riastradh t_siginfo: No SIGFPE on RISC-V.
 1.49 04-Aug-2023  rin t_siginfo:sigfpe_int: Adjust for GCC12

Do not use constant 1 as numerator to raise integer division by zero.
GCC >= 12 optimizes (1 / i) into (abs(i) == 1 ? i : 0), even for -O0.
 1.48 07-May-2023  skrll RISC-V support that works on QEMU with a single hart.

Thanks for Simon Burge for plic(4).
 1.47 07-May-2022  rin branches: 1.47.2;
Skip sigfpe_int also for sh3; integer division by zero is not trapped.
 1.46 10-Dec-2021  andvar s/occured/occurred/ in comments, log messages and man pages.
 1.45 13-Jan-2021  skrll skip sigbus_adraln on MIPS
 1.44 11-Jan-2021  skrll PR/55715: pmax testbed panics with "assertion "asid == curcpu()->ci_pmap_asid_cur" failed"

It's GXemul that has the bug! Unfortunately, there's no way (currently) to
detect if we're running under GXemul emulation, so disable for all mips
for now. Hopefully, GXemul will get fixed soon.
 1.43 10-Jan-2021  skrll PR/55715: pmax testbed panics with "assertion "asid == curcpu()->ci_pmap_asid_cur" failed"

disable the sigbus_adraln test on qemu for now
 1.42 13-Oct-2020  rin For aarch64eb, no SIGBUS signal for unaligned accesses.
Convert to preprocessor directives.
 1.41 24-Aug-2020  gson Expect a failure to trap unaligned acesses only when running under
qemu's TCG CPU emulation, not when running under hardware virtualization
such as qemu -accel nvmm.
 1.40 20-Jun-2020  rin Skip sigbus_adraln for powerpc.

SIGBUS for unaligned accesses is not mandatory for powerpc;
most processors (not all, e.g., 403) can deal with that.
 1.39 22-Feb-2020  kamil Disable the t_siginfo test under MKSANITIZER / MKLIBCSANITIZER

Signal crash events are incompatible with sanitizers.
 1.38 21-Feb-2020  kamil Mark division by 0 as expected in sigfpe_int

Disable ubsan instrumentation on the operation.
 1.37 11-Feb-2020  riastradh aarch64 doesn't trap integer division by zero either.
 1.36 25-Apr-2019  kamil Fix typo in 'exceptions'
 1.35 30-Jan-2019  martin Clean up terminology: modern arm CPUs do properly implement IEEE 754
floating point exceptions - but some (actually all currently know ones)
do not implement sending traps when these exceptions are raised.

Pointed out by Peter Maydell.
 1.34 26-Jan-2019  martin aarch64 does not trap on unaligned acces
 1.33 23-Jan-2019  martin There are aarch64 Cortex cpus that do not trap on some floating point
exceptions - so apply the arm handling for aarch64 as well.
 1.32 17-Jan-2018  maya branches: 1.32.2; 1.32.4;
Improve portability of headers and sort them.

From Ngie Cooper in PR bin/51833
 1.31 05-Mar-2017  chs reenable sigfpe_flt on powerpc now that FPU exceptions work.
 1.30 22-Dec-2015  christos branches: 1.30.2; 1.30.4;
Add __TEST_FENV
 1.29 17-Feb-2015  isaki m68k (except sun2) never issue SIGBUS on unaligned accesses.
PR lib/49653. Thanks martin@.
 1.28 13-Feb-2015  martin Fix strange editor mishap and start block comment on its own line.
 1.27 29-Dec-2014  martin Include <ieeefp.h> even for the <fenv.h> case since we use fpsetmask()
to detect ARM Cortex NEON fpus.
 1.26 19-Nov-2014  martin Skip the SIGFPE test on arm when the FPU does not provide exception handling.
 1.25 19-Nov-2014  martin Use machdep.unaligned_sigbus to skip the unaligned access test on arm
as well.
 1.24 04-Nov-2014  justin PR misc/49356 remove unnecessary references to atf-c/config.h

The function included via this header is not used and is removed in
later versions of atf, so let us avoid it.
 1.23 09-Feb-2014  jmmv Use compiler builtins instead of atf_arch and atf_machine.

The atf_arch and atf_machine configuration variables were removed from
atf-0.19 without me realizing that some tests were querying them directly.

Instead of reintroducing those variables, just rely on compiler builtins
as many other tests already do.

Should fix PR bin/48582.
 1.22 26-Jan-2014  matt Support using fenv instead of fpsetmask if HAVE_FENV is defined.
 1.21 25-Jan-2014  skrll Use English spelling of alignment.
 1.20 12-Apr-2013  christos use one qemu test
 1.19 12-Apr-2013  christos easier way to find if we are on qemu.
 1.18 13-Jun-2012  njoly branches: 1.18.2;
Skip sigbus_adraln testcase on alpha unless global
machdep.unaligned_sigbus sysctl is enabled.
 1.17 23-Apr-2012  martin Revert previous, si_addr is expected to be the faulting *data* address
(mmm, consistent standards).
Add a few tweaks to prevent the compiler's optimizer outsmarting the test.
 1.16 22-Apr-2012  martin Do not compare si_addr (address of faulting instruction) against the
unaligned data address causing the fault - this will always fail.
If anybody knows a portable way to get the data address involved in the
fault, please fix the test case as originally intended.
 1.15 20-Apr-2012  jym ATF test for SIGBUS => BUS_ADRALN (invalid address alignment).

That one is tedious to test under x86: alignment exceptions are
not reported by this architecture unless you ask for them explicitely (by
setting the PSL_AC bit). The brokenness does not end there: %cr2 should
contain the address where the unaligned access occured, alas, it does not.

I am not aware of other architectures where this could happen. Still, my
knowledge is limited; if there is one, feel free to send me a mail and I
will update the test accordingly.

Adding insult to injury, this test can fail in various funny ways with VMs:
- under x86 QEMU, no trap() happens. As ring 3 code stays almost untouched by
QEMU VMM, I suppose the exception can only be triggered when the host
itself is capable of catching unaligned accesses.
- under Virtual Box with HVM support, i386 works fine, but amd64 fails with a
SIGILL (Illegal instruction) that happens right before entering the
signal handler. No idea why, and trying to debug it with gdb freezes the VM
(including ddb breaks).

Anyway, tested with:
- i386: P4 host, anita, Virtual Box HVM (Mac OS X)
- amd64: anita, Virtual Box HVM (Mac OS X)

XXX I would appreciate if someone could test it under a real amd64 host with
an up-to-date kernel, so I can reasonably assume that the culprit is
Virtual Box and not our amd64 port (my test machine being off line
I cannot do it myself). Results from other arches would be a plus too.

Initial issue reported by Nicolas Joly on port-amd64. Thanks!
 1.14 18-Mar-2012  jruoho To be on the safe side, use the category/number notation when referring to
PRs (otherwise third-party sed-scripts might miss the references). Also
remove white-space.
 1.13 17-Mar-2012  christos annotate the PR that failed, and has been fixed.
 1.12 01-Oct-2011  christos branches: 1.12.2;
use _FLOAT_IEEE754 instead of vax.
 1.11 24-May-2011  joerg Use volatile for explicit 0 dereference
 1.10 02-Mar-2011  riz Skip the sigfpe_flt and sigfpe_int tests on powerpc; powerpc does
not fault on divide-by-zero. As discussed on tech-userlevel.
 1.9 01-Mar-2011  pooka Attempt further qemu heuristics to avoid failures due to non-working FPU
 1.8 03-Jan-2011  pgoyette branches: 1.8.2;
Don't run FP Exception tests under qemu - they don't work.

While here, properly skip certain tests on vax architecture. (It is
not legal to have a test-program with zero test cases, so each test
case needs to check-and-skip.)
 1.7 02-Jan-2011  pgoyette If we survive the check for wrong signal code, reset our expectation to
"pass" before checking the signal errno.
 1.6 02-Jan-2011  pgoyette Fix $NetBSD$ keyword
 1.5 31-Dec-2010  mlelstv return from an SIGFPE handler is not defined when the hardware
caused the exception. Use sigsetjmp/siglongjmp to resume the
test function instead.
 1.4 27-Dec-2010  njoly Do use integer arithmetics to generate FPE_INTDIV in sigfpe_int testcase.

Ok pgoyette.
 1.3 26-Dec-2010  pgoyette Re-enable printing of MD data, with appropriate casts.
 1.2 26-Dec-2010  pgoyette For now, don't try to print out machine-dependant stuff. When I figure
out what the right format strings are, I'll re-enable it.
 1.1 25-Dec-2010  pgoyette Move the siginfo tests from regress to atf. While here, add a new test
for PR/43655.

XXX The sigchild_dump test currently fails when execute under atf-run.
XXX It does not fail when executed directly from the shell, so there's
XXX something in atf that prevents the child process from dumping.
 1.8.2.1 05-Mar-2011  bouyer Sync with HEAD
 1.12.2.4 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.12.2.3 30-Oct-2012  yamt sync with head
 1.12.2.2 23-May-2012  yamt sync with head.
 1.12.2.1 17-Apr-2012  yamt sync with head
 1.18.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.18.2.1 23-Jun-2013  tls resync from head
 1.30.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.30.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.32.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.32.4.1 10-Jun-2019  christos Sync with HEAD
 1.32.2.1 26-Jan-2019  pgoyette Sync with HEAD
 1.47.2.1 13-Sep-2024  martin Pull up following revision(s) (requested by rin in ticket #856):

tests/lib/libc/gen/t_siginfo.c: revision 1.54
tests/lib/libc/gen/t_siginfo.c: revision 1.55

t_siginfo:sigbus_adraln: Skip rather than expect_fail on x86

This is an architecture-defined behavior, not a failure.
t_siginfo:adraln: Brush up skip message for x86

Note that:
1. No data address is reported back for alignment check exception, as per
Intel SDM (June 2024).
2. Kernel sets faulting PC to si_addr.
3. 2. is compliant to siginfo(2), at least:
For SIGILL, SIGFPE, SIGBUS and SIGSEGV ... si_addr contains
the address of the faulting instruction or data and ...
4. IEEE Std 1003.1-2024 does not require si_addr for SIGBUS. For SIGILL
and SIGSEGV, e.g., it is required (SHALL) to store faulting PC and
data address, respectively, on the other hand.
 1.53.2.1 02-Aug-2025  perseant Sync with HEAD
 1.14 08-Apr-2025  riastradh tests/lib/libc/gen/t_sleep: Sprinkle a few more diagnostics.

PR misc/59254: tests/lib/libc/gen/t_sleep:kevent: intermittent failures
 1.13 06-Apr-2025  riastradh tests/lib/libc/gen/t_sleep: Sprinkle diagnostics.

PR misc/59254: tests/lib/libc/gen/t_sleep:kevent: intermittent failures
 1.12 06-Apr-2025  riastradh tests/lib/libc/gen/t_sleep: Nix trailing whitespace.

No functional change intended.

Preparation for:

misc/59254: tests/lib/libc/gen/t_sleep:kevent: intermittent failures
 1.11 10-Jan-2017  maya branches: 1.11.26;
remove duplicate include.

(also move so it is alphabetical, hence the weird diff)
 1.10 10-Jan-2017  christos PR/51811: Ngie Cooper: Fix include file portability.
 1.9 11-Aug-2016  kre Correct use of incorrect errno - should have no real practical effect.
 1.8 15-Jul-2014  gson branches: 1.8.6;
space after comma
 1.7 12-Apr-2013  christos branches: 1.7.4;
easier way to find if we are on qemu.
 1.6 17-Mar-2013  jmmv Do not special-case qemu when expecting the failure due to PR kern/43997.

I am sporadically observing this in my real machine as well. It's harder
to trigger, but it happens.
 1.5 09-Nov-2012  pgoyette branches: 1.5.2; 1.5.4;
More clean-up, and adjust timing of kevent test to avoid issues with
PR kern/43887
 1.4 09-Nov-2012  pgoyette Remove unnecessary header file and an unused variable.
Adjust timing parameters to reduce overall elapsed time, and document
the parameters.
Clean-up status handling for kevent test.
Deal with QEMU timer-related issues (PR-43997).
 1.3 08-Nov-2012  pgoyette Provide clear explanation of test-case failures.
 1.2 08-Nov-2012  pgoyette Remove a debug printf(), and fix the format in another.

Should resolve build break.
 1.1 08-Nov-2012  pgoyette Convert old src/regress/timer&waiter tests to ATF
 1.5.4.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.5.4.2 16-Jan-2013  yamt sync with (a bit old) head
 1.5.4.1 09-Nov-2012  yamt file t_sleep.c was added on branch yamt-pagecache on 2013-01-16 05:34:00 +0000
 1.5.2.4 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.5.2.3 23-Jun-2013  tls resync from head
 1.5.2.2 09-Nov-2012  pgoyette More clean-up, and adjust timing of kevent test to avoid issues with
PR kern/43887
 1.5.2.1 09-Nov-2012  pgoyette file t_sleep.c was added on branch tls-maxphys on 2012-11-09 20:13:25 +0000
 1.7.4.1 10-Aug-2014  tls Rebase.
 1.8.6.1 20-Mar-2017  pgoyette Sync with HEAD
 1.11.26.1 02-Aug-2025  perseant Sync with HEAD
 1.3 03-Jul-2020  jruoho Verify that PR lib/55041 is no longer an issue.
 1.2 18-Mar-2012  jruoho Move the references to PRs from code comments to the test description. Once
ATF has the ability to output the metadata in the HTML reports, it should be
easy to traverse between releng and gnats -reports via links.
 1.1 07-Jul-2011  jruoho branches: 1.1.2;
Move 't_syslog_pthread' to 't_syslog' for consistency with libc.
 1.1.2.1 17-Apr-2012  yamt sync with head
 1.4 07-Jul-2011  jruoho Move 't_syslog_pthread' to 't_syslog' for consistency with libc.
 1.3 07-Jul-2011  jruoho Rename some test case names for consistency. No functional change.
 1.2 30-Dec-2010  pooka Test is no longer expected to hang.

PR lib/44248 closed when test associate with PR fails ==> brick dholland
 1.1 17-Dec-2010  pooka Add an isolated test case for PR lib/44248.
 1.4 10-Jan-2017  christos PR/51812: Ngie Cooper: According to ToG gettimeofday() needs <sys/time.h>
 1.3 31-Oct-2014  justin branches: 1.3.2;
PR misc/49342 fix issue where time can tick during tests

Note there are still potential issues as the clock being tested is not
monotonic but it should now not fail unless time is being adjusted.
 1.2 11-Nov-2011  jruoho Fix wrong format string.
 1.1 05-Nov-2011  jruoho branches: 1.1.2;
Few naive checks for time(3).
 1.1.2.3 17-Apr-2012  yamt sync with head
 1.1.2.2 10-Nov-2011  yamt sync with head
 1.1.2.1 05-Nov-2011  yamt file t_time.c was added on branch yamt-pagecache on 2011-11-10 14:31:52 +0000
 1.3.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.1 22-Apr-2025  nia branches: 1.1.4;
Add basic tests for timespec_get(3), timespec_getres(3)

PR standards/58608
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 22-Apr-2025  perseant file t_timespec_get.c was added on branch perseant-exfatfs on 2025-08-02 05:58:04 +0000
 1.4 10-Jan-2017  christos PR/51813: Ngie Cooper: don't leak fd :ttyname_err
 1.3 01-May-2011  jruoho branches: 1.3.26;
Test also ttyname_r(3).
 1.2 08-Apr-2011  jruoho Adjust the test with stdin(3).
 1.1 05-Apr-2011  jruoho Add simple test cases for ttyname(3), strtod(3), and getgrent(3).
 1.3.26.1 20-Mar-2017  pgoyette Sync with HEAD
 1.14 12-Aug-2023  riastradh vis(3): Fix one more buffer overrun in an edge case.

PR lib/57573

XXX pullup-10
XXX pullup-9
XXX pullup-8
 1.13 12-Aug-2023  riastradh vis(3): Fix main part of PR lib/57573.

From Kyle Evans <kevans@FreeBSD.org>.

XXX pullup-10
XXX pullup-9
XXX pullup-8
 1.12 12-Aug-2023  riastradh vis(3) tests: Test another overflow edge case.

Related to PR lib/57573.

XXX pullup-10
XXX pullup-9
XXX pullup-8
 1.11 12-Aug-2023  riastradh vis(3) tests: Expand tests and diagnostic outputs on failure.

PR lib/57573

XXX pullup-10
XXX pullup-9
XXX pullup-8
 1.10 12-Aug-2023  riastradh vis(3) tests: Add xfail test for encoding overflow.

From Kyle Evans <kevans@FreeBSD.org>.

PR lib/57573

XXX pullup-10
XXX pullup-9
XXX pullup-8
 1.9 10-Jan-2017  christos branches: 1.9.6; 1.9.16; 1.9.24;
PR/51806: Ngie Cooper: Only run the vis locale test if VIS_NOLOCALE is defined
 1.8 23-May-2015  christos branches: 1.8.2;
Add a VIS_NOLOCALE test
 1.7 08-Sep-2014  christos add null and empty tests.
 1.6 13-Feb-2013  christos - check the results of the vis functions
- zero output to make sure things work
- don't use encodings that don't work
- fix the style on decoding
 1.5 11-Feb-2013  christos check the results of encoding and decoding
 1.4 06-Nov-2011  christos branches: 1.4.6;
add tests for \x and \xx
 1.3 07-Jul-2011  jruoho branches: 1.3.2;
Move 't_syslog_pthread' to 't_syslog' for consistency with libc.
 1.2 12-Mar-2011  christos Fix various vis/unvis issues:
- no need for all the weak symbols
- define a new _VIS_END flag for UNVIS_END so that there are no collisions
between and vis and unvis flags.
- add bound versions of the vis and unvis functions that take the length of
the destination buffer. Unlike the OpenBSD ones they return -1 or NULL if
the buffer is not large enough, instead of silently truncating.
 1.1 28-Dec-2010  pgoyette Migrate the remaining libc/gen tests to atf
 1.3.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.3.2.1 10-Nov-2011  yamt sync with head
 1.4.6.1 25-Feb-2013  tls resync with head
 1.8.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.9.24.1 09-Dec-2023  martin Pull up following revision(s) (requested by riastradh in ticket #485):

lib/libc/gen/vis.c: revision 1.76-1.86
tests/lib/libc/gen/t_vis.c: revision 1.10-1.14

vis(3): Avoid nonportable MIN in portable code.

vis(3) tests: Add xfail test for encoding overflow.

From Kyle Evans <kevans%FreeBSD.org@localhost>.
PR lib/57573

vis(3) tests: Expand tests and diagnostic outputs on failure.
PR lib/57573

vis(3) tests: Test another overflow edge case.
Related to PR lib/57573.

vis(3): Make maxolen unsigned size_t, not ssize_t.
It is initialized once either to *dlen, which is unsigned size_t, or
to wcslen(start) * MB_MAX_LEN + 1, and wcslen returns unsigned size_t
too. So there appears to have never been any reason for this to be
signed.
Part of PR lib/57573.

vis(3): Make mbslength unsigned.
Sprinkle assertions and comments justifying the proposition that it
would never go negative if signed.
Obviates need to worry about mblength > SSIZE_MAX.
Prompted by PR lib/57573.

vis(3): Avoid arithmetic overflow before calloc(3).
Prompted by PR lib/57573.

vis(3): Call wcslen(start) only once.
It had better not change between these two times!
Prompted by PR lib/57573.

vis(3): Avoid potential arithmetic overflow in maxolen.
Can't easily prove that this overflow is impossible, so let's add a
check.
Prompted by PR lib/57573.

vis(3): Fix main part of PR lib/57573.
From Kyle Evans <kevans%FreeBSD.org@localhost>.

vis(3): Fix one more buffer overrun in an edge case.
PR lib/57573

vis(3): Sort includes. No functional change intended.
Prompted by PR lib/57573.

vis(3): Need <stdint.h> for SIZE_MAX, per C standard.
From Kyle Evans <kevans%FreeBSD.org@localhost>.
Followup to PR lib/57573.

vis(3): Per KNF, sys/param.h comes before sys/types.h.
Which is nice because that's also lexicographic.
 1.9.16.1 09-Dec-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1774):

lib/libc/gen/vis.c: revision 1.75-1.86
tests/lib/libc/gen/t_vis.c: revision 1.10-1.14

PR 56260: fix out-of-bounds stack read.

vis(3): Avoid nonportable MIN in portable code.

vis(3) tests: Add xfail test for encoding overflow.

From Kyle Evans <kevans%FreeBSD.org@localhost>.
PR lib/57573

vis(3) tests: Expand tests and diagnostic outputs on failure.
PR lib/57573

vis(3) tests: Test another overflow edge case.
Related to PR lib/57573.

vis(3): Make maxolen unsigned size_t, not ssize_t.
It is initialized once either to *dlen, which is unsigned size_t, or
to wcslen(start) * MB_MAX_LEN + 1, and wcslen returns unsigned size_t
too. So there appears to have never been any reason for this to be
signed.
Part of PR lib/57573.

vis(3): Make mbslength unsigned.
Sprinkle assertions and comments justifying the proposition that it
would never go negative if signed.
Obviates need to worry about mblength > SSIZE_MAX.
Prompted by PR lib/57573.

vis(3): Avoid arithmetic overflow before calloc(3).
Prompted by PR lib/57573.

vis(3): Call wcslen(start) only once.
It had better not change between these two times!
Prompted by PR lib/57573.

vis(3): Avoid potential arithmetic overflow in maxolen.
Can't easily prove that this overflow is impossible, so let's add a
check.
Prompted by PR lib/57573.

vis(3): Fix main part of PR lib/57573.
From Kyle Evans <kevans%FreeBSD.org@localhost>.

vis(3): Fix one more buffer overrun in an edge case.
PR lib/57573

vis(3): Sort includes. No functional change intended.
Prompted by PR lib/57573.

vis(3): Need <stdint.h> for SIZE_MAX, per C standard.
From Kyle Evans <kevans%FreeBSD.org@localhost>.
Followup to PR lib/57573.

vis(3): Per KNF, sys/param.h comes before sys/types.h.
Which is nice because that's also lexicographic.
 1.9.6.1 09-Dec-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1923):

lib/libc/gen/vis.c: revision 1.75-1.86
tests/lib/libc/gen/t_vis.c: revision 1.10-1.14

PR 56260: fix out-of-bounds stack read.

vis(3): Avoid nonportable MIN in portable code.

vis(3) tests: Add xfail test for encoding overflow.

From Kyle Evans <kevans%FreeBSD.org@localhost>.
PR lib/57573

vis(3) tests: Expand tests and diagnostic outputs on failure.
PR lib/57573

vis(3) tests: Test another overflow edge case.
Related to PR lib/57573.

vis(3): Make maxolen unsigned size_t, not ssize_t.
It is initialized once either to *dlen, which is unsigned size_t, or
to wcslen(start) * MB_MAX_LEN + 1, and wcslen returns unsigned size_t
too. So there appears to have never been any reason for this to be
signed.
Part of PR lib/57573.

vis(3): Make mbslength unsigned.
Sprinkle assertions and comments justifying the proposition that it
would never go negative if signed.
Obviates need to worry about mblength > SSIZE_MAX.
Prompted by PR lib/57573.

vis(3): Avoid arithmetic overflow before calloc(3).
Prompted by PR lib/57573.

vis(3): Call wcslen(start) only once.
It had better not change between these two times!
Prompted by PR lib/57573.

vis(3): Avoid potential arithmetic overflow in maxolen.
Can't easily prove that this overflow is impossible, so let's add a
check.
Prompted by PR lib/57573.

vis(3): Fix main part of PR lib/57573.
From Kyle Evans <kevans%FreeBSD.org@localhost>.

vis(3): Fix one more buffer overrun in an edge case.
PR lib/57573

vis(3): Sort includes. No functional change intended.
Prompted by PR lib/57573.

vis(3): Need <stdint.h> for SIZE_MAX, per C standard.
From Kyle Evans <kevans%FreeBSD.org@localhost>.
Followup to PR lib/57573.

vis(3): Per KNF, sys/param.h comes before sys/types.h.
Which is nice because that's also lexicographic.
 1.1 29-Apr-2014  uebayasi branches: 1.1.2; 1.1.4; 1.1.8;
Minimal execve(2) ATF test.
 1.1.8.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.8.1 29-Apr-2014  tls file Makefile was added on branch tls-maxphys on 2014-08-20 00:04:49 +0000
 1.1.4.2 10-Aug-2014  tls Rebase.
 1.1.4.1 29-Apr-2014  tls file Makefile was added on branch tls-earlyentropy on 2014-08-10 06:57:21 +0000
 1.1.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.2.1 29-Apr-2014  yamt file Makefile was added on branch yamt-pagecache on 2014-05-22 11:42:20 +0000
 1.4 13-Mar-2025  riastradh execve(2), posix_spawn(2): Don't flush _all_ pending signals.

We need only flush those pending signals whose dispositions have been
reset to the default action when that action is to ignore them --
e.g., if the parent had a signal handler function for SIGCHLD or
SIGWINCH, this is reset to the default disposition, which is to
ignore the signal, so any pending SIGCHLD or SIGWINCH need to be
flushed.

And we have logic to do this already in execsigs(9), via
sigclearset(9), which clears the specified set of signals:

402 sigemptyset(&tset);
403 for (signo = 1; signo < NSIG; signo++) {
404 if (sigismember(&p->p_sigctx.ps_sigcatch, signo)) {
405 prop = sigprop[signo];
406 if (prop & SA_IGNORE) {
407 if ((prop & SA_CONT) == 0)
408 sigaddset(&p->p_sigctx.ps_sigignore,
409 signo);
410 sigaddset(&tset, signo);
411 }
412 SIGACTION_PS(ps, signo).sa_handler = SIG_DFL;
...
420 sigclearall(p, &tset, &kq);

https://nxr.netbsd.org/xref/src/sys/kern/kern_sig.c?r=1.409#394

But back in 2003, when ksiginfo_t was introduced, before that logic
was written, we sprouted an exithook to clear _all_ the signals (and,
more importantly for the time, free the ksiginfo_t records to avoid
leaking memory) -- and we wired it up as an _exechook_ too:

+/*
+ * free all pending ksiginfo on exit
+ */
+static void
+ksiginfo_exithook(struct proc *p, void *v)
+{
+ ksiginfo_t *ksi, *hp = p->p_sigctx.ps_siginfo;
+
+ if (hp == NULL)
+ return;
+ for (;;) {
+ pool_put(&ksiginfo_pool, ksi);
+ if ((ksi = ksi->ksi_next) == hp)
+ break;
+ }
+}
...
+ exithook_establish(ksiginfo_exithook, NULL);
+ exechook_establish(ksiginfo_exithook, NULL);

https://mail-index.netbsd.org/source-changes/2003/09/14/msg133910.html

(The first iteration of ksiginfo_exithook had another bug, of course!
But it was soon fixed; that's not the issue here.)

Later, during the newlock2 branch, sigclearall got added for execsigs
to free only the ksiginfo_t records for those signals whose
disposition is being reset to a default action of ignoring the
signal:

void
execsigs(struct proc *p)
{
...
+ sigset_t tset;
...
- for (signum = 1; signum < NSIG; signum++) {
- if (sigismember(&p->p_sigctx.ps_sigcatch, signum)) {
- prop = sigprop[signum];
+ sigemptyset(&tset);
+ for (signo = 1; signo < NSIG; signo++) {
+ if (sigismember(&p->p_sigctx.ps_sigcatch, signo)) {
+ prop = sigprop[signo];
if (prop & SA_IGNORE) {
if ((prop & SA_CONT) == 0)
sigaddset(&p->p_sigctx.ps_sigignore,
- signum);
- sigdelset(&p->p_sigctx.ps_siglist, signum);
+ signo);
+ sigaddset(&tset, signo);
...
}
+ sigclearall(p, &tset);

https://mail-index.netbsd.org/source-changes/2006/10/21/msg176390.html

And the _exithook_ was removed somewhere along the way in the
newlock2 branch (in favour of simply calling sigclearall in exit1),
but the _exechook_ remained:

-static void ksiginfo_exithook(struct proc *, void *);
+static void ksiginfo_exechook(struct proc *, void *);
...
- exithook_establish(ksiginfo_exithook, NULL);
- exechook_establish(ksiginfo_exithook, NULL);
+ exechook_establish(ksiginfo_exechook, NULL);
...
/*
- * ksiginfo_exithook:
+ * ksiginfo_exechook:
*
- * Free all pending ksiginfo entries from a process on exit.
+ * Free all pending ksiginfo entries from a process on exec.
* Additionally, drain any unused ksiginfo structures in the
* system back to the pool.
+ *
+ * XXX This should not be a hook, every process has signals.
*/
static void
-ksiginfo_exithook(struct proc *p, void *v)
+ksiginfo_exechook(struct proc *p, void *v)
{

https://mail-index.netbsd.org/source-changes/2007/02/05/msg180796.html

The symptom of this mistake is that a signal delivered _during_
execve(2) may be simply discarded, even if it should be caught and
cause the process to terminate.

On the bright side, isn't it a nice feeling when you can solve
problems by commits that consist exclusively of deletions?

PR kern/58091: after fork/execve or posix_spawn, parent kill(child,
SIGTERM) has race condition making it unreliable
 1.3 13-Mar-2025  riastradh execve(2), posix_spawn(2): Add test case for an embarrassing bug.

PR kern/58091: after fork/execve or posix_spawn, parent kill(child,
SIGTERM) has race condition making it unreliable
 1.2 12-Sep-2015  christos branches: 1.2.28;
make error more informative.
 1.1 29-Apr-2014  uebayasi branches: 1.1.2; 1.1.4; 1.1.8;
Minimal execve(2) ATF test.
 1.1.8.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.8.1 29-Apr-2014  tls file t_execve.c was added on branch tls-maxphys on 2014-08-20 00:04:49 +0000
 1.1.4.2 10-Aug-2014  tls Rebase.
 1.1.4.1 29-Apr-2014  tls file t_execve.c was added on branch tls-earlyentropy on 2014-08-10 06:57:21 +0000
 1.1.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.2.1 29-Apr-2014  yamt file t_execve.c was added on branch yamt-pagecache on 2014-05-22 11:42:20 +0000
 1.2.28.1 02-Aug-2025  perseant Sync with HEAD
 1.4 07-Nov-2021  martin Fix linking for multi-source file tests, the second part of the tuple
needs to be the C source file (not the base name)
 1.3 07-Nov-2021  christos new tests for posix_spawn_chdir from Piyush Sachdeva
 1.2 14-Feb-2012  martin branches: 1.2.4;
Add a few more posix_spawn testcases, which should detect everything that
was wrong in the initial version, causing the failure reported in
PR kern/45991.
 1.1 13-Feb-2012  martin Move posix_spawn tests to lib/libc/gen/posix_spawn - they test both libc
and kernel, but that is an implementation detail unrelated to the tests
themselfs.
Ok: releng
 1.2.4.2 17-Apr-2012  yamt sync with head
 1.2.4.1 14-Feb-2012  yamt file Makefile was added on branch yamt-pagecache on 2012-04-17 00:09:11 +0000
 1.1 13-Feb-2012  martin branches: 1.1.4;
Move posix_spawn tests to lib/libc/gen/posix_spawn - they test both libc
and kernel, but that is an implementation detail unrelated to the tests
themselfs.
Ok: releng
 1.1.4.2 17-Apr-2012  yamt sync with head
 1.1.4.1 13-Feb-2012  yamt file Makefile.inc was added on branch yamt-pagecache on 2012-04-17 00:09:11 +0000
 1.2 16-Mar-2025  riastradh tests/lib/libc/gen/posix_spawn: Spruce up a bit.

- KNF
- Don't touch files outside the test working directory.
- No need to pre-clean files -- atf gives us an empty tempdir.
- Use h_macros.h to simplify a lot of checks.
- Use names for enumerated arguments, not magic numbers.
- Check some more syscalls.
- Add include guard.
 1.1 07-Nov-2021  christos branches: 1.1.4;
new tests for posix_spawn_chdir from Piyush Sachdeva
 1.1.4.1 02-Aug-2025  perseant Sync with HEAD
 1.2 16-Mar-2025  riastradh tests/lib/libc/gen/posix_spawn: Spruce up a bit.

- KNF
- Don't touch files outside the test working directory.
- No need to pre-clean files -- atf gives us an empty tempdir.
- Use h_macros.h to simplify a lot of checks.
- Use names for enumerated arguments, not magic numbers.
- Check some more syscalls.
- Add include guard.
 1.1 07-Nov-2021  christos branches: 1.1.4;
new tests for posix_spawn_chdir from Piyush Sachdeva
 1.1.4.1 02-Aug-2025  perseant Sync with HEAD
 1.2 07-Nov-2021  christos new tests for posix_spawn_chdir from Piyush Sachdeva
 1.1 13-Feb-2012  martin branches: 1.1.4;
Move posix_spawn tests to lib/libc/gen/posix_spawn - they test both libc
and kernel, but that is an implementation detail unrelated to the tests
themselfs.
Ok: releng
 1.1.4.2 17-Apr-2012  yamt sync with head
 1.1.4.1 13-Feb-2012  yamt file h_fileactions.c was added on branch yamt-pagecache on 2012-04-17 00:09:11 +0000
 1.1 13-Feb-2012  martin branches: 1.1.4;
Move posix_spawn tests to lib/libc/gen/posix_spawn - they test both libc
and kernel, but that is an implementation detail unrelated to the tests
themselfs.
Ok: releng
 1.1.4.2 17-Apr-2012  yamt sync with head
 1.1.4.1 13-Feb-2012  yamt file h_nonexec.sh was added on branch yamt-pagecache on 2012-04-17 00:09:11 +0000
 1.3 07-Nov-2021  christos new tests for posix_spawn_chdir from Piyush Sachdeva
 1.2 02-May-2021  martin Add test for POSIX_SPAWN_RESETIDS flag
 1.1 13-Feb-2012  martin branches: 1.1.4;
Move posix_spawn tests to lib/libc/gen/posix_spawn - they test both libc
and kernel, but that is an implementation detail unrelated to the tests
themselfs.
Ok: releng
 1.1.4.2 17-Apr-2012  yamt sync with head
 1.1.4.1 13-Feb-2012  yamt file h_spawn.c was added on branch yamt-pagecache on 2012-04-17 00:09:11 +0000
 1.3 07-Nov-2021  christos new tests for posix_spawn_chdir from Piyush Sachdeva
 1.2 21-Aug-2021  andvar fix mainly same typos as in my previous commit but outside sys/dev/dm.
 1.1 13-Feb-2012  martin branches: 1.1.4;
Move posix_spawn tests to lib/libc/gen/posix_spawn - they test both libc
and kernel, but that is an implementation detail unrelated to the tests
themselfs.
Ok: releng
 1.1.4.2 17-Apr-2012  yamt sync with head
 1.1.4.1 13-Feb-2012  yamt file h_spawnattr.c was added on branch yamt-pagecache on 2012-04-17 00:09:11 +0000
 1.11 12-Jul-2025  gutteridge t_fileactions.c: fix typos in comments
 1.10 10-Jul-2025  martin In the test code for PR 59523 move the redirect of stdout to the end of
the fileactions, to avoid any interference with the assumptions of the
test-relevant file actions.
We can not guarantee anny of this anyway (but it did trigger the original
problem and both paths in the kernel before the bug was fixed).
Pointed out by kre.
 1.9 09-Jul-2025  martin Add two test cases triggereing the two paths in posix_spawn
that cause PR 59523.
 1.8 16-Mar-2025  riastradh tests/lib/libc/gen/posix_spawn: Spruce up a bit.

- KNF
- Don't touch files outside the test working directory.
- No need to pre-clean files -- atf gives us an empty tempdir.
- Use h_macros.h to simplify a lot of checks.
- Use names for enumerated arguments, not magic numbers.
- Check some more syscalls.
- Add include guard.
 1.7 07-Nov-2021  christos branches: 1.7.4;
new tests for posix_spawn_chdir from Piyush Sachdeva
 1.6 10-Jan-2017  christos more tests needing <sys/stat.h>
 1.5 09-Apr-2012  martin branches: 1.5.2; 1.5.16;
Fix asynchronous posix_spawn child exit status (and test for it).
 1.4 08-Apr-2012  martin Rework posix_spawn locking and memory management:
- always provide a vmspace for the new proc, initially borrowing from proc0
(this part fixes PR 46286)
- increase parallelism between parent and child if arguments allow this,
avoiding a potential deadlock on exec_lock
- add a new flag for userland to request old (lockstepped) behaviour for
better error reporting
- adapt test cases to the previous two and add a new variant to test the
diagnostics flag
- fix a few memory (and lock) leaks
- provide netbsd32 compat
 1.3 20-Feb-2012  martin Add a test case to call posix_spawn with empty file actions, which reproduced
the (now fixed) PR kern/46038.
 1.2 14-Feb-2012  martin branches: 1.2.2;
Add a few more posix_spawn testcases, which should detect everything that
was wrong in the initial version, causing the failure reported in
PR kern/45991.
 1.1 13-Feb-2012  martin Move posix_spawn tests to lib/libc/gen/posix_spawn - they test both libc
and kernel, but that is an implementation detail unrelated to the tests
themselfs.
Ok: releng
 1.2.2.2 12-Apr-2012  riz Pull up following revision(s) (requested by martin in ticket #175):
sys/kern/kern_exit.c: revision 1.238
tests/lib/libc/gen/posix_spawn/t_fileactions.c: revision 1.4
tests/lib/libc/gen/posix_spawn/t_fileactions.c: revision 1.5
sys/uvm/uvm_extern.h: revision 1.183
lib/libc/gen/posix_spawn_fileactions.c: revision 1.2
sys/kern/kern_exec.c: revision 1.348
sys/kern/kern_exec.c: revision 1.349
sys/compat/netbsd32/syscalls.master: revision 1.95
sys/uvm/uvm_glue.c: revision 1.159
sys/uvm/uvm_map.c: revision 1.317
sys/compat/netbsd32/netbsd32.h: revision 1.95
sys/kern/exec_elf.c: revision 1.38
sys/sys/spawn.h: revision 1.2
sys/sys/exec.h: revision 1.135
sys/compat/netbsd32/netbsd32_execve.c: revision 1.34
Rework posix_spawn locking and memory management:
- always provide a vmspace for the new proc, initially borrowing from proc0
(this part fixes PR 46286)
- increase parallelism between parent and child if arguments allow this,
avoiding a potential deadlock on exec_lock
- add a new flag for userland to request old (lockstepped) behaviour for
better error reporting
- adapt test cases to the previous two and add a new variant to test the
diagnostics flag
- fix a few memory (and lock) leaks
- provide netbsd32 compat
Fix asynchronous posix_spawn child exit status (and test for it).
 1.2.2.1 20-Feb-2012  sborrill Pull up the following revisions(s) (requested by martin in ticket #14):
include/spawn.h: revision 1.2
sys/kern/kern_exec.c: revision 1.341
sys/uvm/uvm_glue.c: revision 1.157
tests/lib/libc/gen/posix_spawn/t_fileactions.c: revision 1.3

posix_spawn: fix kernel bug when passing empty fileactions (PR kern/46038)
and add a test case for this. Fix potential race condition, doublefreeing
of memory and memory leaks in error cases.
 1.5.16.1 20-Mar-2017  pgoyette Sync with HEAD
 1.5.2.2 17-Apr-2012  yamt sync with head
 1.5.2.1 09-Apr-2012  yamt file t_fileactions.c was added on branch yamt-pagecache on 2012-04-17 00:09:11 +0000
 1.7.4.1 02-Aug-2025  perseant Sync with HEAD
 1.12 16-Mar-2025  riastradh tests/lib/libc/gen/posix_spawn: Spruce up a bit.

- KNF
- Don't touch files outside the test working directory.
- No need to pre-clean files -- atf gives us an empty tempdir.
- Use h_macros.h to simplify a lot of checks.
- Use names for enumerated arguments, not magic numbers.
- Check some more syscalls.
- Add include guard.
 1.11 15-Mar-2025  riastradh t_spawn: Add missing dup2 in t_spawn_sig.

Matches what h_execsig expects, and what t_execve_sig arranges: stdin
is a pipe that the parent will write a single byte to after it has
delivered SIGTERM.

Now this should have a higher chance of provoking the bug (though it
was already good enough in cursory testing!).

PR kern/58091: after fork/execve or posix_spawn, parent kill(child,
SIGTERM) has race condition making it unreliable
 1.10 13-Mar-2025  riastradh execve(2), posix_spawn(2): Don't flush _all_ pending signals.

We need only flush those pending signals whose dispositions have been
reset to the default action when that action is to ignore them --
e.g., if the parent had a signal handler function for SIGCHLD or
SIGWINCH, this is reset to the default disposition, which is to
ignore the signal, so any pending SIGCHLD or SIGWINCH need to be
flushed.

And we have logic to do this already in execsigs(9), via
sigclearset(9), which clears the specified set of signals:

402 sigemptyset(&tset);
403 for (signo = 1; signo < NSIG; signo++) {
404 if (sigismember(&p->p_sigctx.ps_sigcatch, signo)) {
405 prop = sigprop[signo];
406 if (prop & SA_IGNORE) {
407 if ((prop & SA_CONT) == 0)
408 sigaddset(&p->p_sigctx.ps_sigignore,
409 signo);
410 sigaddset(&tset, signo);
411 }
412 SIGACTION_PS(ps, signo).sa_handler = SIG_DFL;
...
420 sigclearall(p, &tset, &kq);

https://nxr.netbsd.org/xref/src/sys/kern/kern_sig.c?r=1.409#394

But back in 2003, when ksiginfo_t was introduced, before that logic
was written, we sprouted an exithook to clear _all_ the signals (and,
more importantly for the time, free the ksiginfo_t records to avoid
leaking memory) -- and we wired it up as an _exechook_ too:

+/*
+ * free all pending ksiginfo on exit
+ */
+static void
+ksiginfo_exithook(struct proc *p, void *v)
+{
+ ksiginfo_t *ksi, *hp = p->p_sigctx.ps_siginfo;
+
+ if (hp == NULL)
+ return;
+ for (;;) {
+ pool_put(&ksiginfo_pool, ksi);
+ if ((ksi = ksi->ksi_next) == hp)
+ break;
+ }
+}
...
+ exithook_establish(ksiginfo_exithook, NULL);
+ exechook_establish(ksiginfo_exithook, NULL);

https://mail-index.netbsd.org/source-changes/2003/09/14/msg133910.html

(The first iteration of ksiginfo_exithook had another bug, of course!
But it was soon fixed; that's not the issue here.)

Later, during the newlock2 branch, sigclearall got added for execsigs
to free only the ksiginfo_t records for those signals whose
disposition is being reset to a default action of ignoring the
signal:

void
execsigs(struct proc *p)
{
...
+ sigset_t tset;
...
- for (signum = 1; signum < NSIG; signum++) {
- if (sigismember(&p->p_sigctx.ps_sigcatch, signum)) {
- prop = sigprop[signum];
+ sigemptyset(&tset);
+ for (signo = 1; signo < NSIG; signo++) {
+ if (sigismember(&p->p_sigctx.ps_sigcatch, signo)) {
+ prop = sigprop[signo];
if (prop & SA_IGNORE) {
if ((prop & SA_CONT) == 0)
sigaddset(&p->p_sigctx.ps_sigignore,
- signum);
- sigdelset(&p->p_sigctx.ps_siglist, signum);
+ signo);
+ sigaddset(&tset, signo);
...
}
+ sigclearall(p, &tset);

https://mail-index.netbsd.org/source-changes/2006/10/21/msg176390.html

And the _exithook_ was removed somewhere along the way in the
newlock2 branch (in favour of simply calling sigclearall in exit1),
but the _exechook_ remained:

-static void ksiginfo_exithook(struct proc *, void *);
+static void ksiginfo_exechook(struct proc *, void *);
...
- exithook_establish(ksiginfo_exithook, NULL);
- exechook_establish(ksiginfo_exithook, NULL);
+ exechook_establish(ksiginfo_exechook, NULL);
...
/*
- * ksiginfo_exithook:
+ * ksiginfo_exechook:
*
- * Free all pending ksiginfo entries from a process on exit.
+ * Free all pending ksiginfo entries from a process on exec.
* Additionally, drain any unused ksiginfo structures in the
* system back to the pool.
+ *
+ * XXX This should not be a hook, every process has signals.
*/
static void
-ksiginfo_exithook(struct proc *p, void *v)
+ksiginfo_exechook(struct proc *p, void *v)
{

https://mail-index.netbsd.org/source-changes/2007/02/05/msg180796.html

The symptom of this mistake is that a signal delivered _during_
execve(2) may be simply discarded, even if it should be caught and
cause the process to terminate.

On the bright side, isn't it a nice feeling when you can solve
problems by commits that consist exclusively of deletions?

PR kern/58091: after fork/execve or posix_spawn, parent kill(child,
SIGTERM) has race condition making it unreliable
 1.9 13-Mar-2025  riastradh execve(2), posix_spawn(2): Add test case for an embarrassing bug.

PR kern/58091: after fork/execve or posix_spawn, parent kill(child,
SIGTERM) has race condition making it unreliable
 1.8 31-May-2022  andvar branches: 1.8.4;
s/disbale/disable/ and s/enbale/enable/ in comments. also one more typo fix.
 1.7 22-Nov-2021  christos undef a couple more.
 1.6 20-Nov-2021  christos Merge common code for the chdir cases (Piyush Sachdeva)
I also deduplicated some more code
 1.5 15-Nov-2021  christos Add missing test
 1.4 07-Nov-2021  christos new tests for posix_spawn_chdir from Piyush Sachdeva
 1.3 03-Sep-2021  andvar s/existant/existent/ in comments and messages, plus few more similar fixes.
 1.2 18-Oct-2014  snj src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.1 13-Feb-2012  martin branches: 1.1.4;
Move posix_spawn tests to lib/libc/gen/posix_spawn - they test both libc
and kernel, but that is an implementation detail unrelated to the tests
themselfs.
Ok: releng
 1.1.4.2 17-Apr-2012  yamt sync with head
 1.1.4.1 13-Feb-2012  yamt file t_spawn.c was added on branch yamt-pagecache on 2012-04-17 00:09:11 +0000
 1.8.4.1 02-Aug-2025  perseant Sync with HEAD
 1.7 16-Mar-2025  riastradh tests/lib/libc/gen/posix_spawn: Spruce up a bit.

- KNF
- Don't touch files outside the test working directory.
- No need to pre-clean files -- atf gives us an empty tempdir.
- Use h_macros.h to simplify a lot of checks.
- Use names for enumerated arguments, not magic numbers.
- Check some more syscalls.
- Add include guard.
 1.6 23-May-2022  andvar branches: 1.6.4;
s/controll/control/ in comments.
 1.5 07-Nov-2021  christos new tests for posix_spawn_chdir from Piyush Sachdeva
 1.4 02-May-2021  martin Add test for POSIX_SPAWN_RESETIDS flag
 1.3 21-Dec-2017  christos Fix broken test: we can't assume that the current schedule priority range
will overlap with the requested scheduler range, so get the new scheduler
range, and then try to find a different priority. If that fails (to find
a different scheduling range), give up here.
 1.2 18-Dec-2017  christos Don't use SCHED_OTHER.
 1.1 13-Feb-2012  martin branches: 1.1.4; 1.1.34;
Move posix_spawn tests to lib/libc/gen/posix_spawn - they test both libc
and kernel, but that is an implementation detail unrelated to the tests
themselfs.
Ok: releng
 1.1.34.1 25-Jun-2018  martin Additionally pull up following revision(s) (requested by maya in ticket #892):

tests/lib/libc/gen/posix_spawn/t_spawnattr.c: revision 1.2,1.3

Don't use SCHED_OTHER.

Fix broken test: we can't assume that the current schedule priority range
will overlap with the requested scheduler range, so get the new scheduler
range, and then try to find a different priority. If that fails (to find
a different scheduling range), give up here.
 1.1.4.2 17-Apr-2012  yamt sync with head
 1.1.4.1 13-Feb-2012  yamt file t_spawnattr.c was added on branch yamt-pagecache on 2012-04-17 00:09:11 +0000
 1.6.4.1 02-Aug-2025  perseant Sync with HEAD

RSS XML Feed