execve: disallow argc == 0The manpage has contained the following verbiage on the matter for justunder 31 years:"At least one argument must be present in the array"Previous to this version, it
execve: disallow argc == 0The manpage has contained the following verbiage on the matter for justunder 31 years:"At least one argument must be present in the array"Previous to this version, it had been prefaced with the weakening phrase"By convention."Carry through and document it the rest of the way. Allowing argc == 0has been a source of security issues in the past, and it's hard toimagine a valid use-case for allowing it. Toss back EINVAL if we endedup not copying in any args for *execve().The manpage change can be considered "Obtained from: OpenBSD"(cherry picked from commit 773fa8cd136a5775241c3e3a70f1997633ebeedf)(cherry picked from commit c9afc7680f3e1f0510518de9de4264553a31aade)
show more ...
libc: tests: hook CPUSET(9) test up to the buildAdd shims to map NetBSD's API to CPUSET(9). Obviously the invalid inputparts of these tests are relatively useless since we're just testing theshim
libc: tests: hook CPUSET(9) test up to the buildAdd shims to map NetBSD's API to CPUSET(9). Obviously the invalid inputparts of these tests are relatively useless since we're just testing theshims that aren't used elsewhere, there's still some amount of value inthe parts testing valid inputs.Differential Revision: https://reviews.freebsd.org/D27307
Revert r351416 to let lib.libc.gen.getmntinfo_test.getmntinfo_test get more testThis is supposed to be fixed by r363068PR: 240049Sponsored by: The FreeBSD Foundation
Enable long double tests on RISC-VSome of the NetBSD contributed tests are gated behind the__HAVE_LONG_DOUBLE flag. This flag seems to be defined only forplatforms whose long double is larger tha
Enable long double tests on RISC-VSome of the NetBSD contributed tests are gated behind the__HAVE_LONG_DOUBLE flag. This flag seems to be defined only forplatforms whose long double is larger than their double. I could notfind this explicitly documented anywhere, but it is implied by thedefinitions in NetBSD's sys/arch/${arch}/include/math.h headers, and thefollowing assertion from the UBSAN code: #ifdef __HAVE_LONG_DOUBLE long double LD; ASSERT(sizeof(LD) > sizeof(uint64_t)); #endifRISC-V has 128-bit long doubles, so enable the tests on this platform,and update the comments to better explain the purpose of this flag.Reviewed by: ngieMFC after: 1 weekDifferential Revision: https://reviews.freebsd.org/D25419
Add missing shell script from r361995Pointy hat: kevansReported by: rpokalaX-MFC-With: r361995
execvp: fix up the ENOEXEC fallbackIf execve fails with ENOEXEC, execvp is expected to rebuild the commandwith /bin/sh instead and try again.The previous version did this, but overlooked two det
execvp: fix up the ENOEXEC fallbackIf execve fails with ENOEXEC, execvp is expected to rebuild the commandwith /bin/sh instead and try again.The previous version did this, but overlooked two details:argv[0] can conceivably be NULL, in which case memp would never getterminated. We must allocate no less than three * sizeof(char *) so we canproperly terminate at all times. For the non-NULL argv standard case, wecount all the non-NULL elements and actually skip the first argument, so weend up capturing the NULL terminator in our bcopy().The second detail is that the spec is actually worded such that we shouldhave been preserving argv[0] as passed to execvp:"[...] executed command shall be as if the process invoked the sh utilityusing execl() as follows:execl(<shell path>, arg0, file, arg1, ..., (char *)0);where <shell path> is an unspecified pathname for the sh utility, file isthe process image file, and for execvp(), where arg0, arg1, and so oncorrespond to the values passed to execvp() in argv[0], argv[1], and so on."So we make this change at this time as well, while we're already touchingit. We decidedly can't preserve a NULL argv[0] as this would be incredibly,incredibly fragile, so we retain our legacy behavior of using "sh" forargv[] in this specific instance.Some light tests are added to try and detect some components of handling theENOEXEC fallback; posix_spawnp_enoexec_fallback_null_argv0 is likely not100% reliable, but it at least won't raise false-alarms and it did result inuseful failures with pre-change libc on my machine.This is a secondary change in D25038.Reported by: Andrew Gierth <andrew_tao173.riddles.org.uk>Reviewed by: jilles, kib, Andrew GierthMFC after: 1 week
Avoid using non-portable dd status=none flagCopying the approach chosen in r309412. This fixes building the libc testson a macOS host since the macOS /bin/dd binary does not support status=none.
Avoid using non-portable dd status=none flagCopying the approach chosen in r309412. This fixes building the libc testson a macOS host since the macOS /bin/dd binary does not support status=none.As there only seem to be two uses, this commit changes the two Makefiles.If this becomes more common, we could also add a wrapper bootstrap scriptthat ignores status= and forwards the remaining args to the real dd.Another alternative would be to remove the status flag and pipe stderr to/dev/null, but them we lose error messages.Reviewed By: brooksDifferential Revision: https://reviews.freebsd.org/D24785
Add sigsetop extensions commonly found in musl libc and glibcThese functions (sigandset, sigisemptyset, sigorset) are commonly availablein at least musl libc and glibc; sigorset, at least, has pro
Add sigsetop extensions commonly found in musl libc and glibcThese functions (sigandset, sigisemptyset, sigorset) are commonly availablein at least musl libc and glibc; sigorset, at least, has proven quite usefulin qemu-bsd-user work for tracking the current process signal mask in a moreself-documenting/aesthetically pleasing manner.Reviewed by: bapt, jilles, pfgMFC after: 1 weekDifferential Revision: https://reviews.freebsd.org/D22187
lib.libc.gen.getmntinfo_test.getmntinfo_test is unstable since 8/20, skip itin CI env temporarily for more offline diagnosisPR: 240049Sponsored by: The FreeBSD Foundation
Include a mode when creating files with openat().Reviewed by: asomersObtained from: CheriBSDMFC after: 1 weekSponsored by: DARPA, AFRLDifferential Revision: https://reviews.freebsd.org/D20989
Drop "All rights reserved" from my copyright statements.Reviewed by: rgrimesMFC after: 1 monthDifferential Revision: https://reviews.freebsd.org/D19485
getentropy(3): Fallback to kern.arandom sysctl on older kernelsOn older kernels, when userspace program disables SIGSYS, catch ENOSYS andemulate getrandom(2) syscall with the kern.arandom sysctl (
getentropy(3): Fallback to kern.arandom sysctl on older kernelsOn older kernels, when userspace program disables SIGSYS, catch ENOSYS andemulate getrandom(2) syscall with the kern.arandom sysctl (via existingarc4_sysctl wrapper).Special care is taken to faithfully emulate EFAULT on NULL pointers, becausesysctl(3) as used by kern.arandom ignores NULL oldp. (This was caught bygetentropy(3) ATF tests.)Reported by: kibReviewed by: kibDiscussed with: delphijSponsored by: Dell EMC IsilonDifferential Revision: https://reviews.freebsd.org/D14785
Implement getrandom(2) and getentropy(3)The general idea here is to provide userspace programs with well-definedsources of entropy, in a fashion that doesn't require opening a new filedescriptor
Implement getrandom(2) and getentropy(3)The general idea here is to provide userspace programs with well-definedsources of entropy, in a fashion that doesn't require opening a new filedescriptor (ulimits) or accessing paths (/dev/urandom may be restrictedby chroot or capsicum).getrandom(2) is the more general API, and comes from the Linux world.Since our urandom and random devices are identical, the GRND_RANDOM flagis ignored.getentropy(3) is added as a compatibility shim for the OpenBSD API.truss(1) support is included.Tests for both system calls are provided. Coverage is believed to be atleast as comprehensive as LTP getrandom(2) test coverage. Additionally,instructions for running the LTP tests directly against FreeBSD are providedin the "Test Plan" section of the Differential revision linked below. (Theypass, of course.)PR: 194204Reported by: David CARLIER <david.carlier AT hardenedbsd.org>Discussed with: cperciva, delphij, jhb, markjRelnotes: maybeDifferential Revision: https://reviews.freebsd.org/D14500
Add a new set of simple tests for makecontext().In contrast to the existing NetBSD setcontext_link test, these testsverify that passing from 1 to 6 arguments through to the callback functionwork
Add a new set of simple tests for makecontext().In contrast to the existing NetBSD setcontext_link test, these testsverify that passing from 1 to 6 arguments through to the callback functionwork correctly which can be useful for testing ABIs which split argumentsbetween registers and the stack.Sponsored by: DARPA / AFRL
Optimize telldir(3)Currently each call to telldir() requires a malloc and adds an entry to alinked list which must be traversed on future telldir(), seekdir(),closedir(), and readdir() calls. App
Optimize telldir(3)Currently each call to telldir() requires a malloc and adds an entry to alinked list which must be traversed on future telldir(), seekdir(),closedir(), and readdir() calls. Applications that call telldir() for everydirectory entry incur O(n^2) behavior in readdir() and O(n) in telldir() andclosedir().This optimization eliminates the malloc() and linked list in most cases bypacking the relevant information into a single long. On 64-bit architecturesmsdosfs, NFS, tmpfs, UFS, and ZFS can all use the packed representation. On32-bit architectures msdosfs, NFS, and UFS can use the packedrepresentation, but ZFS and tmpfs can only use it for about the first 128files per directory. Memory savings is about 50 bytes per telldir(3) call.Speedup for telldir()-heavy directory traversals is about 20-30x for onemillion files per directory.Reviewed by: kib, mav, mckusickMFC after: 3 weeksSponsored by: Spectra Logic CorpDifferential Revision: https://reviews.freebsd.org/D13385
DIRDEPS_BUILD: Update dependencies.Sponsored by: Dell EMC Isilon
getmntinfo(3): Scale faster, and return soonergetmntinfo(3) is designed around a relatively static or slow growing set ofcurrent mounts. It tried to detect a race with somewhat concurrent mounta
getmntinfo(3): Scale faster, and return soonergetmntinfo(3) is designed around a relatively static or slow growing set ofcurrent mounts. It tried to detect a race with somewhat concurrent mountand re-call getfsstat(2) in that case, looping indefinitely. It alsoallocated space for a single extra mount as slop.In the case where the user has a large number of mounts and is adding themat a rapid pace, it fell over.This patch makes two functional changes:1. Allocate even more slop. Double whatever the last getfsstat(2) returned.2. Abort and return some known results after looping a few times (arbitrarily, 3). If the list is constantly changing, we can't guarantee we return a full result to the user at any point anyways.While here, add very basic functional tests for getmntinfo(3) to the libcsuite.PR: 221743Submitted by: Peter Eriksson <peter AT ifm.liu.se> (earlier version)Sponsored by: Dell EMC Isilon
fnmatch(3): Update testcase for r322368.
Fix cleanup in lib/libc/gen/setdomainname_testATF cleanup routines run in separate processes from the tests themselves, sothey can't share global variables.Also, setdomainname_test needs to be i
Fix cleanup in lib/libc/gen/setdomainname_testATF cleanup routines run in separate processes from the tests themselves, sothey can't share global variables.Also, setdomainname_test needs to be is_exclusive because the test casesaccess a global resource.PR: 219967Reviewed by: ngieMFC after: 3 weeksSponsored by: Spectra Logic CorpDifferential Revision: https://reviews.freebsd.org/D11188
Add tests for some cases in r318298.The first test triggers the out of bounds read of the 'left' array. Itonly fails when realpath.c is compiled with '-fsanitize=address'.The other test checks f
Add tests for some cases in r318298.The first test triggers the out of bounds read of the 'left' array. Itonly fails when realpath.c is compiled with '-fsanitize=address'.The other test checks for ENOENT when running into an emptysymlink. This matches NetBSD's realpath(3) semantics. Previously,empty symlinks were treated like ".".Submitted by: Jan Kokemц╪ller <[email protected]>PR: 219154MFC after: 2 weeks
libc glob: Avoid pathological exponential behaviorAdapt glob's match() routine to use a greedy algorithm that avoidsexponential runtime in byzantine inputs.While here, add a testcase for the byz
libc glob: Avoid pathological exponential behaviorAdapt glob's match() routine to use a greedy algorithm that avoidsexponential runtime in byzantine inputs.While here, add a testcase for the byzantine input.Prompted by: https://research.swtch.com/globAuthored by: Yves Orton <demerphq at gmail.com>Obtained from: Perl (33252c318625f3c6c89b816ee88481940e3e6f95)Sponsored by: Dell EMC Isilon
Upgrade NetBSD tests to 01.11.2017_23.20 snapshotThis contains some new testcases in /usr/tests/...:- .../lib/libc- .../lib/libthr- .../lib/msun- .../sys/kernTested on: amd64, i386MFC after
Upgrade NetBSD tests to 01.11.2017_23.20 snapshotThis contains some new testcases in /usr/tests/...:- .../lib/libc- .../lib/libthr- .../lib/msun- .../sys/kernTested on: amd64, i386MFC after: 1 month
Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installedafter r298107Summary of changes:- Replace all instances of FILES/TESTS with ${PACKAGE}FILES. This ensures that na
Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installedafter r298107Summary of changes:- Replace all instances of FILES/TESTS with ${PACKAGE}FILES. This ensures that namespacing is kept with FILES appropriately, and that this shouldn't need to be repeated if the namespace changes -- only the definition of PACKAGE needs to be changed- Allow PACKAGE to be overridden by callers instead of forcing it to always be `tests`. In the event we get to the point where things can be split up enough in the base system, it would make more sense to group the tests with the blocks they're a part of, e.g. byacc with byacc-tests, etc- Remove PACKAGE definitions where possible, i.e. where FILES wasn't used previously.- Remove unnecessary TESTSPACKAGE definitions; this has been elided into bsd.tests.mk- Remove unnecessary BINDIRs used previously with ${PACKAGE}FILES; ${PACKAGE}FILESDIR is now automatically defined in bsd.test.mk.- Fix installation of files under data/ subdirectories in lib/libc/tests/hash and lib/libc/tests/net/getaddrinfo- Remove unnecessary .include <bsd.own.mk>s (some opportunistic cleanup)Document the proposed changes in share/examples/tests/tests/... via examplesso it's clear that ${PACKAGES}FILES is the suggested way forward in terms ofreplacing FILES. share/mk/bsd.README didn't seem like the appropriate methodof communicating that info.MFC after: never probablyX-MFC with: r298107PR: 209114Relnotes: yesTested with: buildworld, installworld, checkworld; buildworld, packageworldSponsored by: EMC / Isilon Storage Division
DIRDEPS_BUILD: Connect MK_TESTS.Sponsored by: EMC / Isilon Storage Division
Avoid adding the '-release' suffix to non-debug kernel packages.Sponsored by: The FreeBSD Foundation
12