Home | History | Annotate | Download | only in gen
History log of /src/tests/lib/libc/gen/Makefile
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

RSS XML Feed