Commit Graph

21385 Commits

Author SHA1 Message Date
Rick Macklem
a0698341cd getdirentries.2: fix for NFS mounts
It was reported that getdirentries(2) was
returning dirents with d_off set to 0 for an NFS
mount.

This is believed to be correct behaviour at
this time (it may change for some NFS mounts
in the future), but is inconsistent with what the
getdirentries(2) man page says.

This patch fixes the man page.

This is a content change.

PR:	253428
Reviewed by:	asomers
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D28664
2021-02-14 18:16:58 -08:00
Konstantin Belousov
4956af2a8f usleep(3): replace 'process' with 'calling thread'
PR:	253395
Reported by:	zegang.luo@qq.com
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2021-02-11 05:52:55 +02:00
Dimitry Andric
d3338f3355 Fix incorrect hypotl(3) result with subnormal numbers
This adjusts the factor used to scale the subnormal numbers, so it
becomes the right value after adjusting its exponent. Thanks to Steve
Kargl for finding the most elegant fix.

Also enable the hypot tests, and add a test case for this bug.

PR:		253313
MFC after:	1 week
2021-02-10 23:28:43 +01:00
Alex Richardson
7676b388ad Always build the sanitizer runtimes when compiling with clang
This allows instrumenting e.g. test binaries even when compiling with an
external clang (e.g. CROSS_TOOLCHAIN=llvm11). I have some upcoming patches
that allow building the entire base system with ASan/UBSan/etc.
instrumentation and this is required in preparation for this.

Reviewed By:	dim, emaste
Differential Revision: https://reviews.freebsd.org/D28532
2021-02-10 15:25:14 +00:00
Michael Tuexen
f25266bee7 libsysdecode: fix decoding of TCP_NOPUSH and TCP_MD5SIG
TCP_FASTOPEN_MIN_COOKIE_LEN was incorrectly registered as a name of
a IPPROTO_TCP level socket option, which overwrote TCP_NOPUSH.
TCP_FASTOPEN_PSK_LEN was incorrectly registered as a name of an
IPPROTO_TCP level socket option, which overwrote TCP_MD5SIG.

MFC after:	3 days
Sponsored by:	Netflix, Inc.
2021-02-09 23:42:27 +01:00
Dimitry Andric
ac76bc1145 Fix lib/msun's ctrig_test/test_inf_inputs test case with clang >= 10
This sprinkles a few strategic volatiles in an attempt to defeat clang's
optimization interfering with the expected floating-point exception
flags.

Reported by:	lwhsu
PR:		244732
MFC after:	3 days
2021-02-09 22:07:05 +01:00
Alexander V. Chernikov
924d1c9a05 Revert "SO_RERROR indicates that receive buffer overflows should be handled as errors."
Wrong version of the change was pushed inadvertenly.

This reverts commit 4a01b854ca.
2021-02-08 22:32:32 +00:00
Alexander V. Chernikov
4a01b854ca SO_RERROR indicates that receive buffer overflows should be handled as errors.
Historically receive buffer overflows have been ignored and programs
could not tell if they missed messages or messages had been truncated
because of overflows. Since programs historically do not expect to get
receive overflow errors, this behavior is not the default.

This is really really important for programs that use route(4) to keep in sync
with the system. If we loose a message then we need to reload the full system
state, otherwise the behaviour from that point is undefined and can lead
to chasing bogus bug reports.
2021-02-08 21:42:20 +00:00
Steve Kargl
93fc678965 Fix incorrect powf(3) result with x near 1 and |y| much larger than 1
This adjusts the check to trigger overflow/underflow to a slightly lower
value.

Before: powf(9.999995e-01, -1.342177e+08) -> inf
After:  powf(9.999995e-01, -1.342177e+08) -> 1.858724e+31

MFC after:	1 week
2021-02-08 20:48:43 +01:00
Mateusz Guzik
3acea07c18 Restore the augmented strlen commentary
... lost in revert
2021-02-08 19:15:21 +00:00
Alex Richardson
c203bd70b5 Import atf 0.22 snapshot ca73d08c3fc1ecffc1f1c97458c31ab82c12bb01
This includes improvements to the atf-sh helper functions that
significantly reduce the number of spawned processes for each test
and therefore speeds up running the testsuite noticeably.
2021-02-04 15:03:05 +00:00
Mateusz Guzik
33f0540b13 Revert "Reimplement strlen"
This reverts commit 710e45c4b8.

It breaks for some corner cases on big endian ppc64.
Given the stage of the release process it is best to revert for now.

Reported by:	jhibbits
2021-02-03 19:38:10 +00:00
Alex Richardson
9b131f1e51 atf: Fix ATF_BUILD_* values when not using the bootstrap compiler
Currently, we encode the full path and compile flags for the build
compiler in libatf. However, these values are not correct when
cross-compiling: For example, when I build on macOS, CC is set to the
host path /usr/local/Cellar/llvm/11.0.0_1/bin/clang-11. This path will
not exist on the target system.
Simplify this logic and use cc/cpp/c++ since those binaries will exist
on the target system unless the compiler was explicitly disabled.
I'm not convinced ATF needs to encode these values, but this is a
minimal fix for these tests when using a non-bootstrapped compiler.

Reviewed By:	ngie, brooks
Differential Revision: https://reviews.freebsd.org/D28414
2021-02-03 09:32:16 +00:00
John Baldwin
0b7f1af804 Bump shared library versions after ncurses bump in 13.
A few shared libraries in the base system link against ncurses.  An
upgrade from a 12.x host to 13 results in ABI breakage for existing
binaries since the newer versions of these libraries link against the
newer ncurses while the binary itself links against the older ncurses.
For example, dialog4ports built on 12.x sometimes crashes on 13 since
it depends on libdialog which links against ncurses internally.

MFC after:	3 days
Reviewed by:	kib, delphij
Differential Revision:	https://reviews.freebsd.org/D28448
2021-02-01 17:11:49 -08:00
Alex Richardson
5cf6f1c4bc Remove the MK_LIBCPLUSPLUS option
This option has been equivalent to any form of C++ support since libstdc++
was removed. Therefore, replace all MK_LIBCPLUSPLUS uses with MK_CXX.

Reviewed By:	emaste
Differential Revision: https://reviews.freebsd.org/D27974
2021-02-01 09:32:07 +00:00
Edward Tomasz Napierala
5299d64b2b libc: fix buffer overrun in getrpcport(3)
Reviewed By:	markj
Sponsored by:	NetApp, Inc.
Sponsored by:	Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D27332
2021-01-31 21:42:02 +00:00
Mateusz Guzik
f1be262ec1 amd64: move memcmp checks upfront
This is a tradeoff which saves jumps for smaller sizes while making
the 8-16 range slower (roughly in line with the other cases).

Tested with glibc test suite.

For example size 3 (most common with vfs namecache) (ops/s):
before:	407086026
after:	461391995

The regressed range of 8-16 (with 8 as example):
before:	540850489
after:	461671032
2021-01-31 16:07:20 +00:00
Mateusz Guzik
0db6aef407 amd64: add a note about simd to libc memset, memmove and memcmp 2021-01-31 16:07:19 +00:00
Mateusz Guzik
46f168bc66 Drop temporary compat in setproctitle 2021-01-31 16:07:19 +00:00
Mateusz Guzik
164c3b8184 amd64: add missing ALIGN_TEXT to loops in memset and memmove 2021-01-30 00:01:44 +00:00
Mateusz Guzik
710e45c4b8 Reimplement strlen
The previous code neglected to use primitives which can find the end
of the string without having to branch on every character.

While here augment the somewhat misleading commentary -- strlen as
implemented here leaves performance on the table, especially so for
userspace. Every arch should get a dedicated variant instead.

In the meantime this commit lessens the problem.

Tested with glibc test suite.

Naive test just calling strlen in a loop on Haswell (ops/s):

$(perl -e "print 'A' x 3"):
before:	211198039
after:	338626619

$(perl -e "print 'A' x 100"):
before:	83151997
after:	98285919
2021-01-29 23:48:26 +00:00
Alex Richardson
892a05ee3a Avoid double output in fenv_test
This tests fork()s, so if there is still data in the stdout buffer on fork
it will print it again in the child process. This was happening in the
CheriBSD CI and caused the test to complain about malformed TAP output.

Reviewed By:	ngie
Differential Revision: https://reviews.freebsd.org/D28397
2021-01-29 09:29:27 +00:00
Alex Richardson
4d2edf3af1 test_inf_inputs: Use atf_tc_expect_fail() instead of atf_tc_skip()
Reviewed By:	lwhsu
Differential Revision: https://reviews.freebsd.org/D28396
2021-01-29 09:28:40 +00:00
Alex Richardson
d4a6843bb1 Update comment missed in 83ff5d5d98
Reported by:	jrtc27
2021-01-29 09:19:27 +00:00
Alex Richardson
83ff5d5d98 Un-XFAIL two tests with Clang > 10
SVN r343917 fixed this for in-tree clang, but when building with a newer
out-of-tree clang the test was still marked as XFAIL.

Reviewed By:	dim
Differential Revision: https://reviews.freebsd.org/D28390
2021-01-28 17:24:24 +00:00
Andrew Turner
4e76e4c301 Remove obsolete code gated on _ARM_ARCH_*
This is all code only run on ARMv4 and ARMv5. Support for these have
been dropped from FreeBSD.

Differential Revision:	https://reviews.freebsd.org/D28314
2021-01-28 10:41:45 +00:00
Andrew Turner
4d2ff2330f Remove the old ARMv4 memcpy
This was only used when building for ARMv4 or some ARMv5 or when
_STANDALONE is defined. As ARMv4 and ARMv5 support has been removed,
and we only define _STANDALONE in the bootloader where we don't use
this version of memcpy we can remove it.

Differential Revision:	https://reviews.freebsd.org/D28313
2021-01-28 10:39:38 +00:00
Andrew Turner
e09c8c9ad9 Remove leftover big-endian arm support
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D28312
2021-01-28 10:33:40 +00:00
Jessica Clarke
48397f6c7d libllvmminimal: Add missing Support/ABIBreak.cpp
When building natively on RISC-V, linking the bootstrap clang-tblgen
fails with:

  ld: error: undefined symbol: llvm::EnableABIBreakingChecks
  >>> referenced by PrettyStackTrace.cpp
  >>>               PrettyStackTrace.o:(.sdata+0x0) in archive
  /usr/obj/usr/src/freebsd-src/riscv.riscv64/tmp/obj-tools/lib/clang/libllvmminimal/libllvmminimal.a
  >>> referenced by Signals.cpp
  >>>               Signals.o:(.sdata+0x8) in archive
  /usr/obj/usr/src/freebsd-src/riscv.riscv64/tmp/obj-tools/lib/clang/libllvmminimal/libllvmminimal.a
  >>> referenced by Timer.cpp
  >>>               Timer.o:(.sdata+0x28) in archive
  /usr/obj/usr/src/freebsd-src/riscv.riscv64/tmp/obj-tools/lib/clang/libllvmminimal/libllvmminimal.a

This is likely due to Error.h's inclusion of abi-breaking.h. It's
unclear why this only affects RISC-V, but perhaps relates to its more
eager use of .sdata due to the ABI's support for linker relaxations.
Regardless, this is theoretically an issue for all architectures.

Reported by:	Dennis Clarke <dclarke@blastwave.org>
Reviewed by:	dim
Tested by:	mhorne
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D28367
2021-01-27 19:19:00 +00:00
Olivier Cochard
f1c010d9f9 tests: Skip cap_fileargs if build without capsicum capabilities
Approved by:    oshogbo
Sponsored by:   Netflix
Differential Revision: https://reviews.freebsd.org/D2834
2021-01-26 22:19:36 +01:00
Alex Richardson
3454fa118c Don't include libarchive fuzz tests by default
These tests are basic fuzz tests that permute input to trigger crashes
rather than regression or unit tests. Additionally, some of them take a
rather long time to run and should probably be run on a dedicated fuzzing
job instead. Moreover, these simple tests use rand() instead of a real
fuzzing tool that generates interesting inputs (e.g. LLVM libFuzzer) so are
unlikely to find anything interesting when run in CI.

This allows removing one BROKEN_TESTS case due to timeouts and speeds up
running tests on emulated platforms such as QEMU.

Reviewed By:	lwhsu, mm
Differential Revision: https://reviews.freebsd.org/D27153
2021-01-25 15:09:26 +00:00
Mateusz Guzik
b22fdf45ff libc: try to skip memcpy in _gettemp 2021-01-24 11:06:36 +00:00
Mateusz Guzik
6fe328ace8 libc: remove open-coded strlen in _gettemp 2021-01-24 11:06:36 +00:00
Mateusz Guzik
97a463120b libc: skip spurious stat in _gettemp
It was only done to catch ENOTDIR, but the kernel already returns the
error where appropriate.
2021-01-24 11:06:36 +00:00
Kyle Evans
123ae3045d build: remove LIBPTHREAD/LIBTHR build options
WITHOUT_LIBTHR has been broken for a little over five years now, since the
xz 5.2.0 update introduced a hard liblzma dependency on libthr, and building
a useful system without threading support is becoming increasingly more
difficult.

Additionally, in the five plus years that it's been broken more reverse
dependencies have cropped up in libzstd, libsqlite3, and libcrypto (among
others) that make it more and more difficult to reconcile the effort needed
to fix these options.

Remove the broken options.

PR:		252760
Reviewed by:	brooks, emaste, kib
Differential Revision:	https://reviews.freebsd.org/D28263
2021-01-22 12:33:27 -06:00
Glen Barber
f9a66922c9 fix incorrect LLD_VERSION_STRING from previous commit
Reported by:	Oliver Pinter
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-01-21 19:49:30 -05:00
Glen Barber
a53ce3fc49 Bump CURRENT to 14.0
This one goes to 14.

Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-01-21 19:10:07 -05:00
Mark Johnston
1a05d9519d libcasper/cap_grp tests: Reset the group database handle
Some tests verify that the capgrp capability does not permit calls to
setgrent(3), but all tests need to ensure that they reset the
capability's group database handle, otherwise the local process and
casper process will be out of sync.

The cap_pwd tests already handle this.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 month
2021-01-21 14:30:19 -05:00
Mark Johnston
48a1868634 libc/nss: Ensure that setgroupent(3) actually works as advertised
Because the "files" and "compat" implementations failed to set the
"stayopen", keyed lookups would close the database handle, contrary to
the purpose of setgroupent(3).  setpassent(3)'s implementation does not
have this bug.

PR:		165527
Submitted by:	Andrey Simonenko
MFC after:	1 month
2021-01-21 14:30:19 -05:00
Mark Johnston
6e411d8b14 libc/nss tests: Add regression tests for commit 55444c823e1f
PR:		252094
Sponsored by:	The FreeBSD Foundation
MFC after:	1 month
2021-01-21 14:30:19 -05:00
Mark Johnston
5619d49e07 libc/nss: Restore iterator state when doing passwd/group lookups
The getpwent(3) and getgrent(3) implementations maintain some internal
iterator state.  Interleaved calls to functions which do passwd/group
lookups using a key, such as getpwnam(3), would in some cases clobber
this state, causing a subsequent getpwent() or getgrent() call to
restart iteration from the beginning of the database or to terminate
early.  This is particularly troublesome in programming environments
where execution of green threads is interleaved within a single OS
thread.

Take care to restore any iterator state following a keyed lookup.  The
"files" provider for the passwd database was already handling this
correctly, but "compat" was not, and both providers had this problem
when accessing the group database.

PR:		252094
Submitted by:	Viktor Dukhovni <ietf-dane@dukhovni.org>
MFC after:	1 month
2021-01-21 14:30:19 -05:00
Mark Johnston
7abc10098b libc/nss tests: Fix getpw and getgr single-pass tests
Some NSS regression tests for getgrent(3) and getpwent(3) were not
testing anything because the test incorrectly requested creation of a
database snapshot.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 month
2021-01-21 14:30:19 -05:00
Mark Johnston
ed14c69d56 libc/nss tests: Style
Sponsored by:	The FreeBSD Foundation
MFC after:	1 month
2021-01-21 14:30:18 -05:00
Konstantin Belousov
523d94dbea x86: switch vdso TSC timecounter to RDTSCP on AMD Zen CPUs
Reported by:	many
Tested by:	gallatin, mikael, rhurlin
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2021-01-21 14:55:31 +02:00
Alex Richardson
cef1942711 libc: Fix null pointer arithmetic warning in mergesort
This file has other questionable code and "optimizations" (such as copying
one int at a time) that are probably no longer useful, so it might make
sense to replace it with a different implementation at some point.

Reviewed By:	jhb
Differential Revision: https://reviews.freebsd.org/D28134
2021-01-20 09:56:01 +00:00
Alex Richardson
c1a3d7f206 Remove remaining uses of ${COMPILER_FEATURES:Mc++11}
All supported compilers have C++11 support so these checks can be replaced
with MK_CXX guards.
See also https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=252759

PR:		252759
Reviewed By:	emaste
Differential Revision: https://reviews.freebsd.org/D28234
2021-01-19 21:37:36 +00:00
Alex Richardson
0348c8fcfa getopt: Fix conversion from string-literal to non-const char *
Define a non-const static char EMSG[] = "" to avoid having to add
__DECONST() to all uses of EMSG. Also make current_dash a const char *
to fix this warning.
2021-01-19 21:23:25 +00:00
Mateusz Guzik
fe258f23ef Save on getpid in setproctitle by supporting -1 as curproc. 2021-01-16 09:36:54 +01:00
Dimitry Andric
39b7445e15 Merge llvm-project llvmorg-11.0.1-0-g43ff75f2c3f (aka 11.0.1 release)
There were no functional changes after 11.0.1 rc2, so only the version
strings changed.

MFC after:      4 weeks
X-MFC-With:     r364284
2021-01-14 21:46:44 +01:00
Mark Johnston
e3d06599bc libifconfig: Add a symbol map
This is a no-op for now since libifconfig is only built as a static lib.

Reviewed by:	freqlabs, kp, adrian
Differential Revision:	https://reviews.freebsd.org/D28119
2021-01-14 11:41:28 -05:00
Kyle Evans
0495ed398c contrib/lua: update to 5.4.2
Merge commit '0ea45b9cd43ce1247eb3eee9bfd5cee3d19068e7' into main
2021-01-13 23:56:18 -06:00
Mariusz Zaborski
d2ceee38ca casper: convert macros to inline functions
In libcasper, the first argument to the function is a structure that
represents a connection to Casper. On systems without Casper, macros
are used to interpose the Casper functions to standard libc ones.
This may cause errors/warnings that the variable is not used.
With the inline function, there is no such problem.

I omitted this file in: 8c121177f0
2021-01-12 19:40:45 +01:00
Konstantin Belousov
85d028223b libthr malloc: support recursion on thr_malloc_umtx.
One possible way the recursion can happen is during fork: suppose
that fork is called from early code that did not triggered
jemalloc(3) initialization yet. Then we lock thr_malloc lock, and
call malloc_prefork() that might require initialization of jemalloc
pthread_mutexes, calling into libthr malloc. It is safe to allow
recursion for this occurence.

PR:	252579
Reported by:	Vasily Postnicov <shamaz.mazum@gmail.com>
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2021-01-12 12:45:44 +02:00
Alan Somers
ff1a307801 lio_listio: validate aio_lio_opcode
Previously, we would accept any kind of LIO_* opcode, including ones
that were intended for in-kernel use only like LIO_SYNC (which is not
defined in userland).  The situation became more serious with
022ca2fc7f.  After that revision, setting
aio_lio_opcode to LIO_WRITEV or LIO_READV would trigger an assertion.

Note that POSIX does not specify what should happen if aio_lio_opcode is
invalid.

MFC-with:	022ca2fc7f
Reviewed by:	jhb, tmunro, 0mp
Differential Revision:	<https://reviews.freebsd.org/D28078
2021-01-11 19:53:01 -07:00
Konstantin Belousov
21f749da82 libthr: wrap pdfork(2), same as fork(2).
Without wrapping, rtld services and malloc(3) are not guaranteed
to operate correctly in the forked child.

Reviewed by:	markj
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D28088
2021-01-11 22:59:52 +02:00
Mariusz Zaborski
dcdad29947 fileargs: add support for realpath 2021-01-10 12:44:06 +01:00
Konstantin Belousov
81b3a0a341 libc: implement rtld_get_stack_prot() for real
which makes stack prot correct for non-main threads created by binaries
with statically linked libthr.

Cache result, but do not engage into the full double-checked locking,
since calculation of the return value is idempotent.

PR:	252549
Reported and reviewed by:	emaste
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D28075
2021-01-10 08:25:43 +02:00
Konstantin Belousov
cd240c9cf1 x86 vdso gettc: Add RDTSCP support
Detect and use RDTSCP if available, instead of fence+RDTSC.  For AMD Zens+,
use LFENCE+RDTSC instead of RDTSCP (or MFENCE;RDTSC previously).

Reviewed by:	gallatin, markj
Tested by:	pho
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D27986
2021-01-10 04:42:34 +02:00
Konstantin Belousov
5bf4bafd13 x86 vdso gettc: eliminate duplicated code in ifunc selectors.
Create array of rdtsc selectors and provide helper that calculate the
index into the selectors array.

Reviewed by:	gallatin, markj
MFC after:      1 week
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D27986
2021-01-10 04:42:34 +02:00
Konstantin Belousov
de898cb960 x86 vdso gettc: reorganize ifunctions.
Instead of providing ifuncs for each kind of fence, define ifuncs
that combine fence and invocation of RDTSC.  This refactoring makes
introduction of RDTSCP use possible.

Reviewed by:	gallatin, markj
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D27986
2021-01-10 04:42:34 +02:00
Konstantin Belousov
5844bd058a jobc: rework detection of orphaned groups.
Instead of trying to maintain pg_jobc counter on each process group
update (and sometimes before), just calculate the counter when needed.
Still, for the benefit of the signal delivery code, explicitly mark
orphaned groups as such with the new process group flag.

This way we prevent bugs in the corner cases where updates to the counter
were missed due to complicated configuration of p_pptr/p_opptr/real_parent
(debugger).

Since we need to iterate over all children of the process on exit, this
change mostly affects the process group entry and leave, where we need
to iterate all process group members to detect orpaned status.

(For MFC, keep pg_jobc around but unused).

Reported by:	jhb
Reviewed by:	jilles
Tested by:	pho
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D27871
2021-01-10 04:41:20 +02:00
Mariusz Zaborski
faaf43b2a7 fileargs: add tests 2021-01-09 21:56:09 +01:00
Kyle Evans
04a3ba363d libregex: re-enable make check
The tests are generally expected to pass, uncomment the annotation that
lets `make check` work. Note that `make check` currently requires kyua
from ports or an appropriate symlink into /usr/local/bin.
2021-01-08 13:58:35 -06:00
Miod Vallat
d36b5dbe28 libc: regex: rework unsafe pointer arithmetic
regcomp.c uses the "start + count < end" idiom to check that there are
"count" bytes available in an array of char "start" and "end" both point to.

This is fine, unless "start + count" goes beyond the last element of the
array. In this case, pedantic interpretation of the C standard makes the
comparison of such a pointer against "end" undefined, and optimizers from
hell will happily remove as much code as possible because of this.

An example of this occurs in regcomp.c's bothcases(), which defines
bracket[3], sets "next" to "bracket" and "end" to "bracket + 2". Then it
invokes p_bracket(), which starts with "if (p->next + 5 < p->end)"...

Because bothcases() and p_bracket() are static functions in regcomp.c, there
is a real risk of miscompilation if aggressive inlining happens.

The following diff rewrites the "start + count < end" constructs into "end -
start > count". Assuming "end" and "start" are always pointing in the array
(such as "bracket[3]" above), "end - start" is well-defined and can be
compared without trouble.

As a bonus, MORE2() implies MORE() therefore SEETWO() can be simplified a
bit.

PR:		252403
2021-01-08 13:58:35 -06:00
Gleb Smirnoff
7edc1bd9dc When be_activate() turns on a new boot environment, it always deactivates
the current one first. And if it fails to do so, it abandons activation.
However, with the new bootonce feature, there is a legitimate case when
a pool doesn't have "bootfs" property set. Check for this case before
calling be_deactivate().

Reviewed by:	kevans
2021-01-08 09:23:16 -08:00
Thomas Munro
801ac943ea aio_fsync(2): Support O_DSYNC.
aio_fsync(O_DSYNC, ...) is the asynchronous version of fdatasync(2).

Reviewed by: kib, asomers, jhb
Differential Review: https://reviews.freebsd.org/D25071
2021-01-08 13:15:56 +13:00
Thomas Munro
a5e284038e open(2): Add O_DSYNC flag.
POSIX O_DSYNC means that writes include an implicit fdatasync(2), just
as O_SYNC implies fsync(2).

VOP_WRITE() functions that understand the new IO_DATASYNC flag can act
accordingly, but we'll still pass down IO_SYNC so that file systems that
don't understand it will continue to provide the stronger O_SYNC
behaviour.

Flag also applies to fcntl(2).

Reviewed by: kib, delphij
Differential Revision: https://reviews.freebsd.org/D25090
2021-01-08 13:15:56 +13:00
Alex Richardson
7fa2f2a62f Rename NO_WERROR -> MK_WERROR=no
As suggested in D27598. This also supports MK_WERROR.clang=no and
MK_WERROR.gcc=no to support the existing NO_WERROR.<compiler> uses.

Reviewed By:	brooks
Differential Revision: https://reviews.freebsd.org/D27601
2021-01-07 09:31:03 +00:00
Baptiste Daroussin
821aa63a09 ncurses: only keep the version with widechar support
Only keep the widechar version of ncurses as libncursesw.so.9

Keep the old name to avoid breaking the ABI compatibility (the non
widechar version libncurses.so.9 is not binary compatible with
libncursesw.so.9) since all ports and base are already only linking
against the widechar version we can simply remove libncurses.so.9

Since the .9 version only lived in the dev branch and never ended in a
release, it is simply removed and not added to any binary compat
package.

Add symlinks to keep build time compatibility for anyone linking against
-lncurses
2021-01-05 14:01:32 +01:00
Mariusz Zaborski
459511895e cap_sysctl: expose structures and variables
Expose structures and variables that may be used on systems
build without Casper support.
2021-01-04 20:56:07 +01:00
Mariusz Zaborski
8c121177f0 casper: convert macros to inline functions
In libcasper, the first argument to the function is a structure that
represents a connection to Casper. On systems without Casper, macros
are used to interpose the Casper functions to standard libc ones.
This may cause errors/warnings that the variable is not used.
With the inline function, there is no such problem.
2021-01-04 20:55:35 +01:00
Mariusz Zaborski
3810732829 lib9p: fix building on systems without capser
PR:		252353
2021-01-04 20:48:48 +01:00
Emmanuel Vadot
066a8c691e pkgbase: Install atf and kyua in the tests package
While here make sure that all tests dirs are taggued correctly.

Reviewed by:	bapt, emaste
Differential Revision:	https://reviews.freebsd.org/D27714
2021-01-04 16:20:47 +01:00
Emmanuel Vadot
b0995124cd pkgbase: Install libxo test files in the tests package
Reviewed by:	bapt, emaste
Differential Revision:	https://reviews.freebsd.org/D27713
2021-01-04 16:20:26 +01:00
Emmanuel Vadot
c92017ce5b pkgbase: Put libalias in the natd package
natd is the main user of the libalias* modules, put them together.

Reviewed by:	bapt, emaste
Differential Revision:	https://reviews.freebsd.org/D27710
2021-01-04 16:19:08 +01:00
Emmanuel Vadot
2d486ba15f pkgbase: Move bectl to the runtime package
runtime contain what is needed to boot in single user and repair a
system, bectl could be handy to have in this situation.

Differential Revision:	https://reviews.freebsd.org/D27708
2021-01-04 16:17:12 +01:00
Conrad Meyer
98689d0ffb libprivatezstd: Restrict symbol visibility similar to upstream
We have to relax three symbols to dynamically link zstd(1), but the rest
are the same.
2021-01-03 11:26:46 -08:00
Mariusz Zaborski
34535dace9 cap_net: CAPNET_CONNECT and CAPNET_CONNECTDNS are not mutually exclusive
Fix the for the CAPNET_CONNECT and CAPNET_CONNECTDNS.
Add test to ensure that this is possible.
2021-01-03 17:10:35 +01:00
Mariusz Zaborski
b7876aec95 cap_net: allow to use the service without setting the limits
Add test to ensure that this is possible.
2021-01-03 17:09:20 +01:00
Mariusz Zaborski
4084669d18 capser: add cap_net to the list of services 2021-01-03 16:55:35 +01:00
Dimitry Andric
eaeb601bd6 Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
release/11.x llvmorg-11.0.1-rc2-0-g43ff75f2c3f (aka 11.0.1 rc2).

MFC after:	4 weeks
X-MFC-With:	r364284
2021-01-03 13:54:24 +01:00
Alan Somers
022ca2fc7f Add aio_writev and aio_readv
POSIX AIO is great, but it lacks vectored I/O functions. This commit
fixes that shortcoming by adding aio_writev and aio_readv. They aren't
part of the standard, but they're an obvious extension. They work just
like their synchronous equivalents pwritev and preadv.

It isn't yet possible to use vectored aiocbs with lio_listio, but that
could be added in the future.

Reviewed by:    jhb, kib, bcr
Relnotes:       yes
Differential Revision: https://reviews.freebsd.org/D27743
2021-01-02 19:57:58 -07:00
Rick Macklem
d189a74dfd copy_file_range(2): add recommendation to use large "len"
PR#252358 reported a serious performance problem w.r.t.
cp(1) when copying large non-sparse files.
This problem appears to have been caused by cp(1)
calling copy_file_range(2) with a small "len" argument.

This patch adds a recommendation to use a large "len"
value where possible, for performance reasons.

Reviewed by:	asomers
Differential Revision:	https://reviews.freebsd.org/D27935
2021-01-02 17:21:21 -08:00
Konstantin Belousov
4e0c81c5fa tcgetwinsize(3): provide man page
The current POSIX.1-202x draft (1.1) was used as source material.

Submitted by:	Soumendra Ganguly <soumendraganguly@gmail.com>
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D27787
2021-01-02 04:43:32 +02:00
Kyle Evans
1fc421287d libc: tests: add some tests for cpuset(2)
The cpuset(2) tests should be run as root (require.user properly set) with
>= 3 cpus for maximum coverage. All tests that want to modify the cpuset
don't assume any particular cpu layout (i.e. the first cpu may not be 0, the
last may not be first + count) and the following scenarios are tested:

1.) newset: basic execute cpuset() to grab a new cpuset, make sure the
    assigned cpuset then has a different ID.
2.) transient: create a new cpuset then assign the process its original
    cpuset, ensuring that the one we created is now gone.
3.) deadlk: test assigning an anonymous mask, then resetting the process
    base affinity with 1-cpu overlap w.r.t. the anonymous mask and with
    0-cpu overlap w.r.t. the anonymous mask.
4.) jail_attach_newbase: process attaches to a jail with its own
    cpuset+mask (e.g. cpuset -c -l 1,2 jail -c path=/ command=/bin/sh)
5.) jail_attach_newbase_plain: process attaches to a jail with its own
    cpuset (e.g. cpuset -c jail -c path=/ command=/bin/sh)
6.) jail_attach_prevbase: process attaches to a jail with the containing
    jail's root cpuset (e.g. jail -c path=/ command=/bin/sh)
7.) jail_attach_plain: process attaches to a jail with the containing jail's
    root cpuset+mask.
8.) badparent: creates a new cpuset and modifies the anonymous thread mask,
    then setid's back to the original and checks that cpuset_getid() returns
    the expected set.

Differential Revision:	https://reviews.freebsd.org/D27307
2020-12-31 12:31:54 -06:00
Kyle Evans
9e1281eaba libc: tests: hook CPUSET(9) test up to the build
Add shims to map NetBSD's API to CPUSET(9). Obviously the invalid input
parts of these tests are relatively useless since we're just testing the
shims that aren't used elsewhere, there's still some amount of value in
the parts testing valid inputs.

Differential Revision:	https://reviews.freebsd.org/D27307
2020-12-31 12:26:01 -06:00
Edward Tomasz Napierala
3e404b8c53 libcam(3): make cam_getccb(3) zero the whole ccb, not just the header
Leaving zeroing to the clients leads to error-prone pointer
tricks (zeroing needs to preserve the CCB header), and this
code is not performance-critical, so there's really no reason
to not do it.

Reviewed By:	imp, rpokala (manpages)
Sponsored by:	NetApp, Inc.
Sponsored by:	Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D27333
2020-12-29 14:26:06 +00:00
Konstantin Belousov
58b2ed4672 eventfd.2: Add the mail address of the submitter into copyright.
Requested by:	rgrimes
MFC after:	13 days
2020-12-28 21:03:16 +02:00
Ryan Libby
a723bb667e libcompiler_rt: stop building with stack smashing protection
libcompiler_rt implements certain functions that clang and gcc emit
calls to as part of their codegen (e.g. for extended width math).  Build
it without stack smashing protection (SSP, -fstack-protector) in order
to support building binaries without SSP, especially the dynamic linker.
Besides, SSP is probably not very valuable in this library.

Reviewed by:	arichardson, dim, kib
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D27786
2020-12-28 00:44:25 -08:00
Konstantin Belousov
67af9aba6b Decode and report native eventfd descriptors from libprocstat and procstat.
Submitted by:   greg@unrelenting.technology
Reviewed by:    markj (previous version)
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D26668
2020-12-27 12:57:27 +02:00
Konstantin Belousov
6d075fd9a5 Document eventfd().
Submitted by:   greg@unrelenting.technology
Reviewed by:    bcr, markj (previous version)
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D26668
2020-12-27 12:57:26 +02:00
Konstantin Belousov
0ef405eee9 kqueue(2): Use .Fo instead .Ft
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2020-12-27 12:57:26 +02:00
Konstantin Belousov
44c5db52e2 Add eventfd(3) wrappers to libc.
eventfd_read/write one-liners are from musl libc.

Submitted by:   greg@unrelenting.technology
Reviewed by:    markj (previous version)
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D26668
2020-12-27 12:57:26 +02:00
Konstantin Belousov
7d7fad7bd9 Add tcgetwinsize(3) and tcsetwinsize(3) to termios
These functions get/set tty winsize respectively, and are trivial wrappers
around corresponding termio ioctls.

The functions are expected to be a part of POSIX.1 issue 8:
https://www.austingroupbugs.net/view.php?id=1151#c3856.
They are currently available in NetBSD and in musl libc.

PR:	251868
Submitted by:	Soumendra Ganguly <soumendraganguly@gmail.com>
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D27650
2020-12-25 20:43:09 +02:00
Michal Meloun
aa76f0c397 PMC: remove now orphaned PMC for INTEL XScale processors.
Support for XScale architecture has been deleted in FreeBSD 13.
2020-12-25 15:21:53 +01:00
Guangyuan Yang
a1d7836752 mmap(2): Update .Dd missed in the last commit
PR:		252097
MFC after:	1 week
2020-12-24 14:14:56 +00:00
Guangyuan Yang
81720dbab2 mmap(2): Fix a typo
PR:             252097
MFC after:      1 week
Reported by:    Nick Frampton <nick.frampton@akips.com>
2020-12-24 14:08:34 +00:00
Gordon Bergling
f6d234d870 libc: Fix most issues reported by mandoc
- varios "new sentence, new line" warnings
- varios "sections out of conventional order" warnings
- varios "unusual Xr order" warnings
- varios "missing section argument" warnings
- varios "no blank before trailing delimiter" warnings
- varios "normalizing date format" warnings

MFC after:	1 month
2020-12-19 14:54:28 +00:00
Jessica Clarke
ccb86b40c1 strerror.3: Fix whitespace issue introduced in r368714
MFC with:	368714
2020-12-18 22:10:17 +00:00
Mateusz Piotrowski
87394cdd01 strerror.3: Add an example for perror()
This is a nice and quick reference.

Reviewed by:	jilles, yuripv
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D27623
2020-12-17 12:41:47 +00:00