Commit Graph

21481 Commits

Author SHA1 Message Date
Gordon Bergling
3d265fce43 Fix a few mandoc issues
- skipping paragraph macro: Pp after Sh
- sections out of conventional order: Sh EXAMPLES
- whitespace at end of input line
- normalizing date format
2020-10-09 19:12:44 +00:00
Bjoern A. Zeeb
1e375f3aa7 80211: non-functional changes
Sort a few VHT160 and 80+80 lines, update some comments, and remove
a superfluous ','.

No functional changes intended.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2020-10-07 21:56:58 +00:00
Mateusz Guzik
f165a1df9a libkvm: catch up with pre-subtracated per-cpu addresses
Only concerns amd64.

Reported by:	imp
2020-10-06 02:57:37 +00:00
Jakub Wojciech Klama
100353cfbf Add virtio-9p (aka VirtFS) filesystem sharing to bhyve.
VirtFS allows sharing an arbitrary directory tree between bhyve virtual
machine and the host. Current implementation has a fairly complete support
for 9P2000.L protocol, except for the extended attribute support. It has
been verified to work with the qemu-kvm hypervisor.

Reviewed by:	rgrimes, emaste, jhb, trasz
Approved by:	trasz (mentor)
MFC after:	1 month
Relnotes:	yes
Sponsored by:	Conclusive Engineering (development), vStack.com (funding)
Differential Revision:	https://reviews.freebsd.org/D10335
2020-10-03 19:05:13 +00:00
Mark Johnston
afd95785c0 newlocale(3): Fix a memory leak.
newlocale() optionally takes a "base" locale, from which components not
specified in the mask are inherited.  POSIX says that newlocale() may
modify "base" and return it, or free "base" and return a newly allocated
locale.  We were not doing either, so applications which use newlocale()
to modify an existing base locale end up leaking memory on FreeBSD.

This diff fixes the leak by releasing a reference to the base locale
before returning.  This is less efficient than modifying "base"
directly, but is simpler for an initial bug fix.  Also, update the man
page to clarify behaviour with respect to "base".

PR:		249416
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D26522
2020-10-02 18:35:55 +00:00
Ed Maste
da6e5efe92 libmd: add dependency workaround for r366344
r366344 fixed and reenabled the assembly optimized skein implementation,
but skein_block objects were not being rebuilt in no-clean builds. This
resulted in failing no-clean builds. SKEIN_USE_ASM controls which
routines come from C vs assembly, and with no explicit dependency
r366344's change to SKEIN_USE_ASM did not cause skein_block.{o,pico}
to be rebuilt.

Add a dependency on this Makefile for the skein_block objects. This
dependency is broader in scope than absolutely required (that is, the
skein_block objects will now be rebuilt on any change to this Makefile).
There are ways this could be addressed, but it is probably not worth the
additional effort or testing time to pursue them.

PR:		248221
Reported by:	kevans, Jeremy Faulkner
Discussed with:	kevans
Sponsored by:	The FreeBSD Foundation
2020-10-02 14:00:52 +00:00
Ed Maste
36972ee3e0 libmd: fix assembly optimized skein implementation
The assembly implementation incorrectly used logical AND instead of
bitwise AND. Fix, and re-enable in libmd.

Submitted by:	Yang Zhong <yzhong@freebsdfoundation.org>
Reviewed by:	cem (earlier)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D26614
2020-10-01 21:05:50 +00:00
Kyle Evans
320ef1bef0 auxv: partially revert r366207, cast buflen to unsigned int as needed
The warning generated pre-r366207 is actually a sign comparison warning:

error: comparison of integers of different signs: 'unsigned long' and 'int'
                        if (strlcpy(buf, execpath, buflen) >= buflen)

Revert parts that affected other lines and just cast this to unsigned int.

The buflen < 0 -> EINVAL has been kept despite no longer serving any
purposes w.r.t. sign-extension because I do believe it's the right thing to
do: "The provided buffer was not the right size for the requested item."

The original warning is confirmed to still be gone with an:
env WARNS=6 make WITHOUT_TESTS=yes.

Reviewed by:	asomers, kib
X-MFC-With:	r366207
Differential Revision:	https://reviews.freebsd.org/D26631
2020-10-01 19:56:38 +00:00
Dimitry Andric
8833aad7be Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
release/11.x llvmorg-11.0.0-rc5-0-g60a25202a7d.

MFC after:	4 weeks
X-MFC-With:	r364284
2020-10-01 19:06:07 +00:00
Enji Cooper
c9d175ea90 Eliminate duplicate afterinstallconfigs target
Define separate dependent targets which `afterinstallconfigs` relies on, in
order to modify `${DESTDIR}/etc/master.passwd` and
`${DESTDIR}/etc/nsswitch.conf`.

Mark these targets .PHONY, since they manipulate configurations on the fly and
the generation logic isn't 100% defined in terms of the source files/logic,
and is variable, based on MK_foo flags.

MFC after:	2 weeks
Reviewed by:	bapt, brd
Differential Revision:	https://reviews.freebsd.org/D20330
2020-10-01 16:37:49 +00:00
Kyle Evans
7cc42f6d25 Do a sweep and remove most WARNS=6 settings
Repeating the default WARNS here makes it slightly more difficult to
experiment with default WARNS changes, e.g. if we did something absolutely
bananas and introduced a WARNS=7 and wanted to try lifting the default to
that.

Drop most of them; there is one in the blake2 kernel module, but I suspect
it should be dropped -- the default WARNS in the rest of the build doesn't
currently apply to kernel modules, and I haven't put too much thought into
whether it makes sense to make it so.
2020-10-01 01:10:51 +00:00
Warner Losh
61c4a6f317 Updates to chroot(2) docs
1. Note what settings give historic behavior
2. Recommend jail under security considerations.
2020-09-29 18:13:54 +00:00
Alan Somers
d14f60e9ba Misc compiler warning fixes in lib/libc
Reviewed by:	kevans, imp
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D26534
2020-09-27 22:26:41 +00:00
Alan Somers
90ec6a3035 lib/libc/tests/iconv: raise WARNS to 6
MFC after:	2 weeks
2020-09-24 21:42:44 +00:00
Alan Somers
9f036e84fb lib/libc/tests/sys: raise WARNS to 6
MFC after:	2 weeks
2020-09-24 21:39:09 +00:00
Brandon Bergren
bceb5a2c8d [PowerPC64LE] Pass our byte order to the sqlite3 build.
Due to the sqlite3 endian detection code preferring to check platform defines
instead of checking endian defines, it is necessary to manually set
the endianness on PowerPC64LE.

Unlike other bi-endian platforms, PowerPC64LE relies entirely on the
generic endianness macros like __BYTE_ORDER__ and has no platform-specific
define to denote little endian.

Add -DSQLITE_BYTEORDER=1234 to the CFLAGS when building libsqlite3 on
powerpc64le.

Fixes runtime operation of sqlite on PowerPC64LE.

Sponsored by:	Tag1 Consulting, Inc.
2020-09-23 02:17:44 +00:00
Brandon Bergren
f4eb39ba6b [PowerPC64LE] libkvm powerpc64le support.
* Add missing _kvm16toh() function.
* Teach libkvm about powerpc64le.

Sponsored by:	Tag1 Consulting, Inc.
2020-09-23 02:11:24 +00:00
Brandon Bergren
b257310103 [PowerPC64LE] Fix gdtoa configurations on LE.
gdtoa wins the award for "most outdated endianness naming convention"
with its IEEE_8087 vs IEEE_MC68k defines. I had a good chuckle.

Update softfloat and arith.h to adjust to BE or LE automatically
based on the low level preprocessor defines.

Fixes printf/scanf on PowerPC64LE, although there is still a problem
lurking regarding Signalling NaNs...

Sponsored by:	Tag1 Consulting, Inc.
2020-09-23 02:05:44 +00:00
Brandon Bergren
24faccc241 [PowerPC64LE] Use a shared LIBC_ARCH for powerpc64le.
Given that we have converted to ELFv2 for BE already, endianness is the only
difference between the two ARCHs.

As such, there is no need to differentiate LIBC_ARCH between the two.

Combining them like this lets us avoid needing to have two copies of several
bits for no good reason.

Sponsored by:	Tag1 Consulting, Inc.
2020-09-23 00:21:51 +00:00
Konstantin Belousov
1f305be431 Document {O,AT}_RESOLVE_BENEATH and new O_BENEATH behavior for relative paths.
PR:	248335
Reviewed by:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D25886
2020-09-22 22:54:54 +00:00
Vincenzo Maffione
92c5d82c86 libnetmap: fix cast from uint64_t to void*
We use uintptr_t as an intermediate cast to avoid compiler
warnings on 32 bit architectures.

Reported by:	adrian
MFC after:	3 days
2020-09-22 20:20:43 +00:00
D Scott Phillips
00e6614750 Sparsify the vm_page_dump bitmap
On Ampere Altra systems, the sparse population of RAM within the
physical address space causes the vm_page_dump bitmap to be much
larger than necessary, increasing the size from ~8 Mib to > 2 Gib
(and overflowing `int` for the size).

Changing the page dump bitmap also changes the minidump file
format, so changes are also necessary in libkvm.

Reviewed by:	jhb
Approved by:	scottl (implicit)
MFC after:	1 week
Sponsored by:	Ampere Computing, Inc.
Differential Revision:	https://reviews.freebsd.org/D26131
2020-09-21 22:21:59 +00:00
Toomas Soome
e307eb94ae loader: zfs should support bootonce an nextboot
bootonce feature is temporary, one time boot, activated by
"bectl activate -t BE", "bectl activate -T BE" will reset the bootonce flag.

By default, the bootonce setting is reset on attempt to boot and the next
boot will use previously active BE.

By setting zfs_bootonce_activate="YES" in rc.conf, the bootonce BE will
be set permanently active.

bootonce dataset name is recorded in boot pool labels, bootenv area.

in case of nextboot, the nextboot_enable boolean variable is recorded in
freebsd:nvstore nvlist, also stored in boot pool label bootenv area.
On boot, the loader will process /boot/nextboot.conf if nextboot_enable
is "YES", and will set nextboot_enable to "NO", preventing /boot/nextboot.conf
processing on next boot.

bootonce and nextboot features are usable in both UEFI and BIOS boot.

To use bootonce/nextboot features, the boot loader needs to be updated on disk;
if loader.efi is stored on ESP, then ESP needs to be updated and
for BIOS boot, stage2 (zfsboot or gptzfsboot) needs to be updated
(gpart or other tools).

At this time, only lua loader is updated.

Sponsored by:	Netflix, Klara Inc.
Differential Revision:	https://reviews.freebsd.org/D25512
2020-09-21 09:01:10 +00:00
Stefan Eßer
fcce470c2b Apply an opimization for the kernels used by cexp(x) and cexpf(x) submitted
by Steve Kargl:

- Use sincos[f] instead of a call to cos[f] and a call to sin[f].

- While here, alphabetize declaration.

Submitted by:   sgk at troutmask.apl.washington.edu (Steve Kargl)
2020-09-20 05:32:53 +00:00
Stefan Eßer
a67cc94327 Apply fix for ld80 and ld128 submitted by Steve Kargl:
- Micro-optimization: use sincosl(x) instead of a call to cosl(x) and
  a call to sinl(x).  Argument reduction is done once not twice.

- Use a long double constant instead of an invalid double constant.

- Spell scale2 correctly

He could not test ld128, so that patch is untested.

Submitted by:	sgk at troutmask.apl.washington.edu (Steve Kargl)
2020-09-20 05:28:31 +00:00
Kirk McKusick
85ee267a3e Update the libufs cgget() and cgput() interfaces to have a similar
API to the sbget() and sbput() interfaces. Specifically they take
a file descriptor pointer rather than the struct uufsd *disk pointer
used by the libufs cgread() and cgwrite() interfaces. Update fsck_ffs
to use these revised interfaces.

No functional changes intended.

Sponsored by: Netflix
2020-09-19 22:48:30 +00:00
Alan Somers
9ad1d357e0 fix integer underflow in getgrnam_r and getpwnam_r
Sometimes nscd(8) will return a 1-byte buffer for a nonexistent entry. This
triggered an integer underflow in grp_unmarshal_func, causing getgrnam_r to
return ERANGE instead of 0.

Fix the user's buffer size check, and add a correct check for a too-small
nscd buffer.

PR:		248932
Event:		September 2020 Bugathon
Reviewed by:	markj
MFC after:	2 weeks
Sponsored by:	Axcient
Differential Revision: https://reviews.freebsd.org/D26204
2020-09-19 19:08:27 +00:00
Kyle Evans
fe815331bb build: provide a default WARNS for all in-tree builds
The current default is provided in various Makefile.inc in some top-level
directories and covers a good portion of the tree, but doesn't cover parts
of the build a little deeper (e.g. libcasper).

Provide a default in src.sys.mk and set WARNS to it in bsd.sys.mk if that
variable is defined. This lets us relatively cleanly provide a default WARNS
no matter where you're building in the src tree without breaking things
outside of the tree.

Crunchgen has been updated as a bootstrap tool to work on this change
because it needs r365605 at a minimum to succeed. The cleanup necessary to
successfully walk over this change on WITHOUT_CLEAN builds has been added.

There is a supplemental project to this to list all of the warnings that are
encountered when the environment has WARNS=6 NO_WERROR=yes:
https://warns.kevans.dev -- this project will hopefully eventually go away
in favor of CI doing a much better job than it.

Reviewed by:	emaste, brooks, ngie (all earlier version)
Reviewed by:	emaste, arichardson (depend-cleanup.sh change)
Differential Revision:	https://reviews.freebsd.org/D26455
2020-09-18 17:17:46 +00:00
Alex Richardson
c5ef56ea61 Remove unnecessary include "../Makefile.inc"
This is already pulled in by bsd.init.mk.

Reported By:	kevans
2020-09-18 14:05:31 +00:00
Mark Johnston
3d1098617b Fix error checking in shm_create_largepage().
Reviewed by:	alc, kib
Reported by:	Coverity
MFC with:	r365524
Differential Revision:	https://reviews.freebsd.org/D26464
2020-09-18 12:30:15 +00:00
Alex Richardson
72f97a2d09 libarchive: fix mismatch between library and test configuration
I was investigating libarchive test failures on CheriBSD and it turns out
we get a reproducible SIGBUS for test_archive_m5, etc. Debugging this shows
that libarchive and the tests disagree when it comes to the definition of
archive_md5_ctx: libarchive assumes it's the OpenSSL type whereas the test
use the libmd type. The latter is not necessarily aligned enough to store
a pointer (16 bytes for CHERI RISC-V), so we were crashing when storing
EVP_MD_CTX* to an 8-byte-aligned archive_md5_ctx.

To avoid problems like this in the future, factor out the common compiler
flags into a Makefile.inc and include that from the tests Makefile.

Reviewed By:	lwhsu
Differential Revision: https://reviews.freebsd.org/D26469
2020-09-18 11:22:34 +00:00
Eric van Gyzen
acde2586c9 Fix additional memory leak in process_mapfile
Additional Coverity detected memory leak fix.

Submitted by:	bret_ketchum@dell.com
Reported by:	Coverity
Reviewed by:	cem, emaste
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D26462
2020-09-17 18:24:51 +00:00
Dimitry Andric
16d6b3b3da Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
release/11.x llvmorg-11.0.0-rc2-91-g6e042866c30.

MFC after:	6 weeks
X-MFC-With:	r364284
2020-09-16 16:58:29 +00:00
Andrew Turner
2a6803de1c Use MACHINE_CPUARCH when checking for arm64
Use MACHINE_CPUARCH with arm64 (aarch64) when we build code that could run
on any 64-bit Arm instruction set. This will simplify checks in downstream
consumers targeting prototype instruction sets.

The only place we check for MACHINE_ARCH == aarch64 is when building the
device tree blobs. As these are targeting current generation ISAs.

Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D26370
2020-09-14 16:12:28 +00:00
Edward Tomasz Napierala
2ccf8a827c Skip armv7 bectl tests on CI; they deadlock (""KSTACK_PAGES is 2").
PR:		249229
Sponsored by:	DARPA
2020-09-14 10:35:39 +00:00
Kyle Evans
ecebb3cc1d Only set WARNS if not defined
This would allow interested parties to do experimental runs with an
environment set appropriately to raise all the warnings throughout the
build; e.g. env WARNS=6 NO_WERROR=yes buildworld.

Not currently touching the numerous instances in ^/tools.

MFC after:	1 week
2020-09-11 13:28:37 +00:00
Kyle Evans
8b8cf4ece6 memfd_create: simplify HUGETLB support a little bit
This also fixes a minor issue that was missed in the initial review; the
layout of the MFD_HUGE_* flags is actually not 1:1 bit:flag -- it instead
borrowed the Linux convention of how this is laid out since it was
originally implemented on Linux, the top 6 bits represent the shift required
for the requested page size.

This allows us to remove the flag <-> pgsize mapping table and simplify the
logic just prior to validation of the requested page size.

While we're here, fix two small nits:

- HUGETLB memfd shouldn't exhibit the SHM_GROW_ON_WRITE behavior. We can
  only grow largepage shm by appropriately aligned (i.e. requested pagesize)
  sizes, so it can't work in the typical/sane fashion. Furthermore, Linux
  does the same, so let's be compatible.

- We don't allow MFD_HUGETLB without specifying a pagesize, so no need to
  check for that later.

Reviewed by:	kib (slightly earlier version)
2020-09-11 02:02:15 +00:00
Kyle Evans
9bf2b80ca6 memfd_create: fix return values
Literally returning EINVAL from a function designed to return an fd makes
for interesting scenarios.

I cannot assign enough pointy hats to cover this one.
2020-09-10 21:25:16 +00:00
Kyle Evans
944174e7bf Fix memfd_create tests after r365524
r365524 did accidentally invert this check that sets SHM_LARGEPAGE, leading
non-hugetlb memfd as unconfigured largepage shm and thus test failures when
we try to ftruncate or write to them.

PR:		249236
Discussed with:	kib
2020-09-10 17:23:30 +00:00
Dimitry Andric
18ed63b8f1 Follow-up r364753 by only using arm's stdatomic.c implementation, as it
already covers the functions in compiler-rt's atomic.c, leading to
conflicts when linking.

PR:		230888
MFC after:	3 days
X-MFC-With:	r364753
2020-09-10 16:47:12 +00:00
Alex Richardson
e17ebfd3b7 Remove -I flag for include path that doesn't exist
Found this while trying to get macOS bootstrap to work again after OpenZFS merge.

Reviewed By:	#zfs, freqlabs
Differential Revision: https://reviews.freebsd.org/D26192
2020-09-10 15:37:07 +00:00
Konstantin Belousov
3ef55e8f25 Add shm_create_largepage(3) helper for creation and configuration of
largepage shm objects.

And since we can, add memfd_create(MFD_HUGETLB) support, hopefully
close enough to the Linux feature.

Reviewed by:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D24652
2020-09-09 22:20:36 +00:00
Konstantin Belousov
1352798db3 Fix compilation of libsysdecode after r365522, should have been part of it.
Reviewed by:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D24652
2020-09-09 22:18:44 +00:00
Dimitry Andric
c90cb43503 Follow-up r364753 by enabling compiler-rt's atomic implementation only
for clang, as it uses clang specific builtins, and does not compile
correctly with gcc. Note that gcc packages usually come with their own
libatomic, providing these primitives.

PR:		230888
MFC after:	3 days
X-MFC-With:	r364753
2020-09-09 20:48:57 +00:00
Kyle Evans
69112cca60 getlogin_r: fix the type of len
getlogin_r is specified by POSIX to to take a size_t len, not int. Fix our
version to do the same, bump the symbol version due to ABI change and
provide compat.

This was reported to break compilation of Ruby 2.8.

Some discussion about the necessity of the ABI compat did take place in the
review. While many 64-bit platforms would likely be passing it in a 64-bit
register and zero-extended and thus, not notice ABI breakage, some do
sign-extend (e.g. mips).

PR:		247102
Submitted by:	Bertram Scharpf <software@bertram-scharpf.de> (original)
Submitted by:	cem (ABI compat)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D26335
2020-09-09 18:07:13 +00:00
Kyle Evans
0e907c045b libc tests: dynthr_mod: fix some WARNS issues
This is being addressed as part of a side-patch I'm working on that builds
all the things with WARNS=6, instead of relying on it being supplied in just
shallow parts of the build with higher-level Makefile.inc.

Provide a prototype for mod_main and annotate the thread function argument
as unused.

MFC after:	1 week
2020-09-09 02:45:47 +00:00
Kyle Evans
5593499d4a libc/resolv: attempt to fix the test under WARNS=6
In a side-change that I'm working on to start defaulting src builds to
WARNS=6 where WARNS isn't otherwise specified, GCC6 (and clang, to a lesser
extent) pointed out a number of issues with the resolv tests:

- Global method variable that gets shadowed in run_tests()
- Signed/unsigned comparison between i in run_tests() and hosts->sl_cur

The shadowed variable looks like it might actually be bogus as written, as
we pass it to RUN_TESTS -> run_tests, but other parts use the global method
instead. This change is mainly geared towards correcting that by removing
the global and plumbing the method through from run_tests -> run into the
new thread.

For the signed/unsigned comparison, there's no compelling reason to not just
switch i/nthreads/nhosts to size_t.

The review also included a change to the load() function that was better
addressed by jhb in r365302.

Reviewed by:	ngie, pstef
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D24844
2020-09-09 02:42:21 +00:00
Brandon Bergren
328b5f2570 [PowerPC] Implement VDSO timebase access on powerpc*
Implement the remaining pieces needed to allow userland timestamp reading.

Rewritten based on an intial essay into the problem by Justin Hibbits.
(Copyright changed to my own on his request.)

Tested on ppc64 (POWER9 Talos II), powerpcspe (e500v2 RB800), and
powerpc (g4 PowerBook).

Reviewed by:	jhibbits (in irc)
Sponsored by:	Tag1 Consulting, Inc.
Differential Revision:	https://reviews.freebsd.org/D26347
2020-09-08 03:00:31 +00:00
Dimitry Andric
86b019c29a Follow-up r365371 by removing sentences which indicate the state of the
MK_MALLOC_PRODUCTION option on -CURRENT.

Also, for the sake of backwards compatibility, support the old way of
enabling 'production malloc', e.g. by adding a define in make.conf(5).

MFC after:	1 week
X-MFC-With:	r365371
2020-09-06 09:08:06 +00:00
Dimitry Andric
7d4374f65f Turn MALLOC_PRODUCTION into a regular src.conf(5) option
For historical reasons, defining MALLOC_PRODUCTION in /etc/make.conf has
been used to turn off potentially expensive debug checks and statistics
gathering in the implementation of malloc(3).

It seems more consistent to turn this into a regular src.conf(5) option,
e.g. WITH_MALLOC_PRODUCTION / WITHOUT_MALLOC_PRODUCTION. This can then
be toggled similar to any other source build option, and turned on or
off by default for e.g. stable branches.

Reviewed by:	imp, #manpages
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D26337
2020-09-05 23:30:17 +00:00
Matt Macy
eac7052fde ZFS: MFV 2.0-rc1-gfd20a8
- fixes jail delegation
- fixes raw kstat unsupported complaints
- exposes dbgmsg, dbuf, and checksum benchmark stats
- restore rename -u support
2020-09-04 22:25:14 +00:00
Matt Macy
adfd5c1bd9 Another missed move 2020-09-04 21:55:35 +00:00
Matt Macy
431004027d Update vendor openzfs to fd20a8 2020-09-04 21:31:58 +00:00
Dimitry Andric
a2a9ef4beb Add a few more files to libllvm, which are required when doing sanitized
builds, for example with -fsanitize=undefined.

MFC after:	6 weeks
X-MFC-With:	r364284
2020-09-03 18:27:13 +00:00
John Baldwin
2afeaad315 Various fixes to the load() function.
- Use getline() instead of fgetln().  This ensures the returned string
  is always null-terminated without losing the last character if the
  last line in a file doesn't have a newline.  Also, while fgetln says
  the returned buffer can be modified, that doesn't actually seem safe
  as the current implementation means you are modifying stdio's
  internal buffer.

- Remove a spurious if before an ATF_REQUIRE that was clearly supposed
  to be non-optional.

- Remove a pointless compare of 'ptr' against '\0' (really NULL) that
  duplicated the middle condition in the for().

- Once a comment is found, skip the rest of the line, not just the
  current word.

Reviewed by:	kevans
Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D26278
2020-09-03 14:50:15 +00:00
Stephen J. Kiernan
2d012dff57 Avoid issues with STAGING by using LIBUCL_DIR for the source directory
variable name instead of LIBUCL (which would otherwise end up with the
staging directory used instead of the wanted source directory.)

Reviewed by:	sjg
Obtained from:	Juniper Networks, Inc.
2020-09-03 03:48:42 +00:00
John Baldwin
4d135bbd7f libifconfig now depends on libm due to usage of log10().
ld.bfd in particular requires -lm to come after libifconfig on the
command line when linking rescue.

Reviewed by:	freqlabs, adrian
Differential Revision:	https://reviews.freebsd.org/D26258
2020-09-02 22:10:08 +00:00
John Baldwin
875e04d716 Pass a valid mode with O_CREATE to open(2).
CheriABI is pickier about the arguments to open(2) and crashes with a
fault if a mode isn't passed to an open() when O_CREATE is specified.

Reported by:	CHERI
Reviewed by:	brooks
Obtained from:	CheriBSD
MFC after:	2 weeks
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D26281
2020-09-02 21:17:54 +00:00
John Baldwin
97bdc65f27 Don't assume objects in program sections have a size of a pointer.
The size of the object at 'addr' is unknown and might be smaller than
the size of a pointer (e.g. some x86 instructions are smaller than a
pointer).  Instead, just check that the address is in the bounds of
the program header.

Reported by:	CHERI (indirectly)
Reviewed by:	kib, brooks
Obtained from:	CheriBSD
MFC after:	1 week
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D26279
2020-09-02 20:43:08 +00:00
John Baldwin
1a4531bc98 Compute the correct size of the string to move forward.
Previously this was counting the amount of spare room at the start of
the buffer that the string needed to move forward and passing that as
the number of bytes to copy to memmove rather than the length of the
string to be copied.

In the strfmon test in the test suite this caused the memmove to
overflow the allocated buffer by one byte which CHERI caught.

Reported by:	CHERI
Reviewed by:	kevans
Obtained from:	CheriBSD
MFC after:	1 week
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D26280
2020-09-02 20:04:26 +00:00
Li-Wen Hsu
0932ee9fa0 Temporarily skip tests panic i386 kernel in CI
lib.libbe.be_create.libbe_create
sbin.bectl.bectl_test.bectl_create

PR:		249055
Sponsored by:	The FreeBSD Foundation
2020-09-02 19:18:27 +00:00
Mark Johnston
847ab36bf2 Include the psind in data returned by mincore(2).
Currently we use a single bit to indicate whether the virtual page is
part of a superpage.  To support a forthcoming implementation of
non-transparent 1GB superpages, it is useful to provide more detailed
information about large page sizes.

The change converts MINCORE_SUPER into a mask for MINCORE_PSIND(psind)
values, indicating a mapping of size psind, where psind is an index into
the pagesizes array returned by getpagesizes(3), which in turn comes
from the hw.pagesizes sysctl.  MINCORE_PSIND(1) is equal to the old
value of MINCORE_SUPER.

For now, two bits are used to record the page size, permitting values
of MAXPAGESIZES up to 4.

Reviewed by:	alc, kib
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D26238
2020-09-02 18:16:43 +00:00
John Baldwin
ff38047b0c Fix a buffer overrun.
getln() returns 'len' valid characters.  line[len] is out of bounds.

Reported by:	CHERI
Reviewed by:	brooks
Obtained from:	CheriBSD
MFC after:	2 weeks
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D26197
2020-09-01 16:20:42 +00:00
Vincenzo Maffione
4c067f3842 lib: libnetmap: add missing copyright headers
MFC after:	2 weeks
2020-09-01 06:06:32 +00:00
John Baldwin
d10af81d2d Fix the build of scandir_b with GCC.
Use explicit typedefs for block thunk structures as in r264143.

Reviewed by:	kib, adrian
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D26256
2020-08-31 21:55:25 +00:00
Eric van Gyzen
4644463cac libpmc: Fix memory leak in process_mapfile
Coverity detected memory leak fix.

Submitted by:	bret_ketchum@dell.com
Reported by:	Coverity
Reviewed by:	cem
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D26230
2020-08-31 16:07:40 +00:00
Vincenzo Maffione
5c4f8d801c lib: add libnetmap
This changeset introduces the new libnetmap library for writing
netmap applications.
Before libnetmap, applications could either use the kernel API
directly (e.g. NIOCREGIF/NIOCCTRL) or the simple header-only-library
netmap_user.h (e.g. nm_open(), nm_close(), nm_mmap() etc.)

The new library offers more functionalities than netmap_user.h:
  - Support for complex netmap options, such as external memory
    allocators or per-buffer offsets. This opens the way to future
    extensions.
  - More flexibility in the netmap port bind options, such as
    non-numeric names for pipes, or the ability to specify the netmap
    allocator that must be used for a given port.
  - Automatic tracking of the netmap memory regions in use across the
    open ports.

At the moment there is no man page, but the libnetmap.h header file
has in-depth documentation.

Reviewed by:	hrs
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D26171
2020-08-28 20:03:54 +00:00
Eric van Gyzen
a2e194654f memstat_kvm_uma: fix reading of uma_zone_domain structures
Coverity flagged the scaling by sizeof(uzd).  That is the type
of the pointer, so the scaling was already done by pointer arithmetic.
However, this was also passing a stack frame pointer to kvm_read,
so it was doubly wrong.

Move ZDOM_GET into the !_KERNEL section and use it in libmemstat.

Reported by:	Coverity
Reviewed by:	markj
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D26213
2020-08-28 19:50:40 +00:00
Matt Macy
93ddd0259d update vendor openzfs to a00c61 (2.0-rc1) 2020-08-28 18:41:28 +00:00
Alex Richardson
18de62a94a Move libsqlite3 to the top of the SUBDIR list
In parallel builds, this should allow sqlite to start building earlier and
increase parallelism when building lib/. Looking at htop output during
buildworld/tinderbox, there are long phases where only one CPU is active
optimizing the massive sqlite3.c file since the build of libsqlite3 is
started quite late.

Reviewed By:	emaste
Differential Revision: https://reviews.freebsd.org/D26169
2020-08-26 09:19:49 +00:00
Dimitry Andric
cc0b883028 After r364423, which ensures the callbacks that dl_iterate_phdr(3)
performs are protected by an exclusive lock, even for statically linked
programs, it is safe to re-enable libunwind's FrameHeaderCache, which I
temporarily disabled in r364263.

Meanwhile upstream has also used the _LIBUNWIND_USE_FRAME_HEADER_CACHE
for this purpose, so the only thing needed is to add this as a
compile-time command line flag.

While here, reformat the CFLAGS lines a little bit.

MFC after:	6 weeks
X-MFC-With:	r364284, r364423
2020-08-25 20:07:11 +00:00
Dimitry Andric
0709bb1f41 After r364753, there should be no need to suppress -Watomic-alignment
warnings anymore for compiler-rt's atomic.c. This occurred because the
IS_LOCK_FREE_8 macro was not correctly defined to 0 for mips, and this
caused the compiler to emit a runtime call to __atomic_is_lock_free(),
and that triggers the warning.

MFC after:	2 weeks
X-MFC-With:	r364753
2020-08-25 19:57:11 +00:00
Kyle Evans
5e6a7bc6c1 libbe: lift the WARNS post-OpenZFS merge
sys/ccompile.h no longer uses #pragma ident, so we no longer need to worry
about unknown pragmas.

I fixed one WARNS issue in r363409 by annotating be_is_auto_snapshot_name's
lbh parameter __unused, then upstreamed the following changes to OpenZFS
that rode in with the merge:
- zfs_path_to_zhandle now takes a const char *path rather than a char *path,
  since it won't be mutating the string it receives and I had no reason to
  believe it will need to in the future. [OpenZFS PR #10605]
- Annotated some unused parameters on definitions inlined into headers as
  such. [OpenZFS PR #10606]
2020-08-25 18:16:40 +00:00
Alex Richardson
0c54932d50 Fix -Wundef warnings when building liblua
We need to define the LUA_FLOAT_INT64 macro even if we don't use it (copied
from stand/luaconf.h). While touching luaconf.h.dist also sync it with the
the 5.3.5 release version (matches the one in lib/liblua).

Reviewed By:	kevans
Differential Revision: https://reviews.freebsd.org/D25977
2020-08-25 13:30:34 +00:00
Alex Richardson
7ec1ec4fdb Add missing FreeBSD functions to -legacy when building on macOS/Linux
In most cases this simply builds the file from lib/libc for missing
functions (e.g. strlcpy on Linux etc.). In cases where this is not possible
I've added an implementation to tools/build/cross-build.

The fgetln.c/fgetwln.c/closefrom.c compatibility code was obtained from
https://gitlab.freedesktop.org/libbsd/libbsd, but I'm not sure it makes
sense to import it into to contrib just for these three bootstrap files.

Reviewed By:	brooks
Differential Revision: https://reviews.freebsd.org/D25978
2020-08-25 13:23:31 +00:00
Dimitry Andric
46c8c5540f Add atomic and bswap functions to libcompiler_rt
There have been several mentions on our mailing lists about missing
atomic functions in our system libraries (e.g. __atomic_load_8 and
friends), and recently I saw __bswapdi2 and __bswapsi2 mentioned too.

To address this, add implementations for the functions from compiler-rt
to the system compiler support libraries, e.g. libcompiler_rt.a and and
libgcc_s.so.

This also needs a small fixup in compiler-rt's atomic.c, to ensure that
32-bit mips can build correctly.

Bump __FreeBSD_version to make it easier for port maintainers to detect
when these functions were added.

MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D26159
2020-08-25 06:49:10 +00:00
Matt Macy
9e5787d228 Merge OpenZFS support in to HEAD.
The primary benefit is maintaining a completely shared
code base with the community allowing FreeBSD to receive
new features sooner and with less effort.

I would advise against doing 'zpool upgrade'
or creating indispensable pools using new
features until this change has had a month+
to soak.

Work on merging FreeBSD support in to what was
at the time "ZFS on Linux" began in August 2018.
I first publicly proposed transitioning FreeBSD
to (new) OpenZFS on December 18th, 2018. FreeBSD
support in OpenZFS was finally completed in December
2019. A CFT for downstreaming OpenZFS support in
to FreeBSD was first issued on July 8th. All issues
that were reported have been addressed or, for
a couple of less critical matters there are
pull requests in progress with OpenZFS. iXsystems
has tested and dogfooded extensively internally.
The TrueNAS 12 release is based on OpenZFS with
some additional features that have not yet made
it upstream.

Improvements include:
  project quotas, encrypted datasets,
  allocation classes, vectorized raidz,
  vectorized checksums, various command line
  improvements, zstd compression.

Thanks to those who have helped along the way:
Ryan Moeller, Allan Jude, Zack Welch, and many
others.

Sponsored by:	iXsystems, Inc.
Differential Revision:	https://reviews.freebsd.org/D25872
2020-08-25 02:21:27 +00:00
Matt Macy
3b0ce0e28d Vendor import of openzfs master @ 184df27eef
Sponsored by:	iX Systems, Inc.
2020-08-24 22:48:19 +00:00
Dimitry Andric
75b4d546cd Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
release/11.x llvmorg-11.0.0-rc2-0-g414f32a9e86.

MFC after:	6 weeks
X-MFC-With:	r364284
2020-08-24 17:43:23 +00:00
Alex Richardson
0b862b0399 Avoid adding duplicates to SRCS/OBJS/SOBJS/POBJS
This is a change in preparation for stopping to use lorder.sh (D26044) and
instead assume that we have a linker newer than ~1990. Without lorder.sh
duplicates end up being passed to the linker when building .so files and this
can result in duplicate symbol definition errors.

There is one minor change: libcompiler_rt.a will no longer provide
gcc_personality_v0 and instead we now only have it in libgcc_eh.a/libgcc_s.so.
This matches GCC's behaviour.

Reviewed By:	emaste, cem
Differential Revision: https://reviews.freebsd.org/D26042
2020-08-24 09:20:33 +00:00
Mateusz Guzik
992bcb37c2 libc: hide alphasort_thunk behind I_AM_SCANDIR_B
Should unbreak gcc build as reported by tinderbox:
lib/libc/gen/scandir.c:59:12: warning: 'alphasort_thunk' declared 'static' but never defined [-Wunused-function]
2020-08-23 11:06:59 +00:00
Dimitry Andric
1c1ab42925 Add a missed source file for LLVM's BPF target. This target is not
enabled by default, so I forgot about it, apologies for the breakage.

Reported by:	hrs
MFC after:	6 weeks
X-MFC-With:	r364284
2020-08-22 15:31:56 +00:00
Dimitry Andric
c37f312d3b Add a few new source files to libc++, in particular the implementation
part of std::random_shuffle. These were split off at some point by
upstream, but I forgot to add them to our Makefile.

This should allow some ports which use std::random_shuffle to correctly
link again.

Reported by:	thierry
PR:		248795
MFC after:	6 weeks
X-MFX-With:	r364284
2020-08-22 12:05:11 +00:00
Simon J. Gerraty
0929924b61 veloader: insist on verifying .4th .lua etc
When files are read from .rc or .4th, verify_file is asked to
guess the severity (VE_TRY,VE_WANT,VE_MUST)

Reviewed by:	stevek
MFC after:	1 week
Sponsored by:	Juniper Networks
2020-08-21 00:27:06 +00:00
Konstantin Belousov
22517af2c1 dl_iterate_phdr(3): provide exclusive locking for callback when statically linked.
Apparently llvm unwinder depends on the external locking for callback.

Reviewed by:	cem, emaste
Tested by:	emaste
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D26109
2020-08-20 15:19:09 +00:00
Rick Macklem
a8537fe404 Add MSG_TLSAPPDATA to lib/libsysdecode/mktables.
I have no idea what this does (and until now that it even existed), but
apparently it needs this entry changed for the MSG_TLSAPPDATA, since
it is kernel only.
2020-08-20 03:53:18 +00:00
Dimitry Andric
7eee172052 Fix the mips64 world build after r364284.
Linking the full version of clang 11 results in errors similar to:

lld: error: /usr/src/contrib/llvm-project/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:736:(.text._ZN5clang4ento22CreateAnalysisConsumerERNS_16CompilerInstanceE+0xE0): relocation R_MIPS_CALL16 out of range: 48920 is not in [-32768, 32767]; references operator new(unsigned long)

Add -mxgot to the compilation flags for llvm libraries to work around
this error. This may be too big of a hammer, but it can always be
refined later.

MFC after:	6 weeks
2020-08-19 17:05:30 +00:00
Konstantin Belousov
92ca23a4b8 scandir-compat11.c: Remove unused declaration for qsort_b().
Sponsored by:	The FreeBSD Foundation
MFC after:	0 days
2020-08-17 19:14:09 +00:00
Conrad Meyer
cb1480f8d4 gpart(8): Recognize apple-zfs and solaris-reserved partition ids
Introduce G_PART_ALIAS_SOLARIS_RESERVED, GPT_ENT_TYPE_SOLARIS_RESERVED et al.,
to make gpart show output more convenient on systems with illumos/openindiana
disks visible.

Submitted by:	Juraj Lutter <otis AT sk.FreeBSD.org>
Reviewed by:	bcr(manpages), delphij, myself
Differential Revision:	https://reviews.freebsd.org/D26012
2020-08-17 17:07:05 +00:00
Bjoern A. Zeeb
fd6eb8fec7 80211: consistently spell 80P80
The standard uses 80+80 and 80p80 but nowhere 80_80.
Switch the latter to 80P80 for all the macros and comments refering
to #defined flags which I could find.
The only place we leave as 80p80 is the ifconfig command line arguments
as we spell them all in lower case.
Ideally we would use 80+80 for any interactions with the user and
80P80 for anything internal but let us not confuse parsers and
hence avoid the '+' in either case.

Reviewed by:	adrian, gnn
MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC (d/b/a "Netgate")
Differential Revision:	https://reviews.freebsd.org/D26001
2020-08-17 12:52:57 +00:00
Xin LI
941791759c Don't explicitly specify c99 or gnu99 as the default is now gnu99.
MFC after:	2 weeks
2020-08-17 05:57:02 +00:00
Dimitry Andric
e81829d0e5 Merge ^/head r364264 through r364278. 2020-08-16 18:24:48 +00:00
Mariusz Zaborski
832dc76b63 libcasper: Introduce cap_net a network service for Casper.
Reviewed by:	emaste, markj (previous version), bcr (man page)
Differential Revision:	https://reviews.freebsd.org/D24688
2020-08-16 18:12:21 +00:00
Dimitry Andric
1106035d5b Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
release/11.x llvmorg-11.0.0-rc1-47-gff47911ddfc.
2020-08-15 12:29:55 +00:00
Dimitry Andric
de6fc2e39b Merge ^/head r364082 through r364250. 2020-08-15 11:49:31 +00:00
Kyle Evans
967fbfd9e2 Properly disable LUA_USE_DLOPEN for bootstrap flua
flua does have some specific bits that will include luaconf.h, but the
definition of LUA_USE_DLOPEN for those won't matter. This belongs in liblua
instead.

To expand on my previous commit, which was a little sparse with details,
it's not really safe to allow LUA_USE_DLOPEN with host lib paths being used.
The host system could have an entirely different lua version and this could
cause us to crash and burn.

If we want to revive this later, we need to make sure to define c module
paths inside OBJDIR that are compiled against whatever version we've
bootstrapped.

Pointy hat:	kevans
2020-08-14 02:40:17 +00:00
Kyle Evans
c2a2b4f3cf flua: don't allow dlopen, et al., for bootstrap flua
There are some logistics issues that need to be sorted out here before we
can actually allow this to work.
2020-08-14 02:22:19 +00:00
Bryan Drewery
2933cd3184 syslog(3): Send proper NILVALUE if gethostname(3) fails.
RFC5424 defines NILVALUE as '-'. Replace its usage with a macro and
separate out the fields to be more clear. fputs(3) is used in some
places to avoid hiding possible format string problems in a macro.

Reviewed by:	cem, vangyzen (earlier version)
Sponsored by:	Dell EMC
2020-08-14 00:18:18 +00:00
Ed Maste
3bd8419597 flua: support "require" for binary objects in the base system
Export symbols from flua, and enable dlopen.

Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D26059
2020-08-13 23:13:05 +00:00
Bryan Drewery
b2e98945d7 Add test to for FreeBSD-SA-19:20.bsnmp
Submitted by:	Darrick Lew <darrick.freebsd at gmail.com>
Reviewed by:	cem
Sponsored by:	Dell EMC
Differential Revision:	https://reviews.freebsd.org/D26037
2020-08-13 22:42:24 +00:00
Ed Maste
bceabe277e flua: initial support for "require" in the base system
Use /usr not /usr/local for base system components.

Use /usr/lib/flua and /usr/share/flua (not lua) for consistency and to
avoid the possibility that other software accidentally finds our base
system modules.

Also drop the version from the path, as flua represents an unspecified
lua version that corresponds to the FreeBSD version it comes with.

LUA_USE_DLOPEN is not yet enabled because some additional changes are
needed wrt symbol visibility.

Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D24605
2020-08-13 00:19:05 +00:00
Andrew Turner
da11e1f9ee Add support for Cortex-A76/Neoverse-N1 to hwpmc
This adds support for the Cortex-A76 and Neoverse-N1 PMU counters to pmc.

While here add more PMCR_IDCODE values and check the implementers code is
correct before setting the PMU type.

Reviewed by:	bz, emaste (looks reasonable to me)
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D25959
2020-08-12 10:17:17 +00:00
Konstantin Belousov
cc321ccd75 Export scandir_b from libc.
Apparently it was not exported, because scandir_b.c was not included
into libc SRCS.  Export it with the CURRENT-13 version.

Also, because it was not exported before ino64, clean up
scandir-compat11.c.

PR:	248572
Reported by:	Alex S <iwtcex@gmail.com>
Reviewed by:	emaste
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D26020
2020-08-10 21:41:49 +00:00
Dimitry Andric
8460d7540b Merge ^/head r364051 through r364081. 2020-08-10 16:58:05 +00:00
Dimitry Andric
a08d04f4e4 Follow-up to r358851 (llvm-project 10.0.0-rc3 import), where I added
subdirectories for compiler-rt's internal fuzzer, profile and xray
headers, but forgot to add installing those headers themselves.

MFC after:	3 days
2020-08-10 16:55:54 +00:00
Ryan Moeller
94cba8034b Move ifconfig SFP status functionality into libifconfig
libifconfig_sfp.h provides an API in libifconfig for querying SFP module
properties, operational status, and vendor strings, as well as descriptions
of the various fields, string conversions, and other useful helpers for
implementing user interfaces.

SFP module status is obtained by reading registers via an I2C interface.
Descriptions of these registers and the values therein have been collected
in a Lua table which is used to generate all the boilerplace C headers and
source files for accessing these values, their names, and descriptions.
The generated code is fully commented and readable.

This is the first use of libifconfig in ifconfig itself.  For now, the
scope remains very limited.  Over time, more of ifconfig will be replaced
with libifconfig.

Some minor changes to the formatting of ifconfig output have been made:
- Module memory hex dumps are indented one extra space as a result of using
hexdump(3) instead of a bespoke hex dump function.
- Media descriptions have an added two-character short-name in parenthesis.
- QSFP modules were incorrectly displaying TX bias current as power.  Now
  TX channels display bias current, and this change has been made for both
  SFP and QSFP modules for consistency.

A Lua binding for libifconfig including this functionality is implemented
but has not been included in this commit.  The plan is for it to be
committed after dynamic module loading has been enabled in flua.

Reviewed by:	kp, melifaro
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D25494
2020-08-09 16:27:28 +00:00
Dimitry Andric
e53daa1d64 Merge ^/head r363989 through r364034. 2020-08-07 18:14:41 +00:00
Dimitry Andric
9a282b3eb9 Re-add generated arm_neon.h header, which was accidentally dropped while
refactoring lib/clang/headers/Makefile in r363984.
2020-08-07 18:12:37 +00:00
Gordon Bergling
eef7327a68 setlocale(3): Add an EXAMPLES section and add LANG category
PR:		41824
Submitted by:	Slaven Rezic <eserte atvran dot herceg dot de>
Obtained from:	NetBSD
MFC after:	1 week
2020-08-07 17:25:56 +00:00
Gordon Bergling
90fb6afc55 mbsrtowcs(3): Clarify the RETURN VALUES section
PR:		215848
Submitted by:	Andrew Stevenson <andrew at ugh dot net dot au>
MFC after:	1 week
2020-08-07 16:56:43 +00:00
Gordon Bergling
1f325602e4 tmpnam(3): Also mention tmpfile in the ENVIRONMENT section
PR:		181785
Submitted by:	Kevin P. Neal <kpneal atpobox dot com>
MFC after:	1 week
2020-08-07 16:20:07 +00:00
Bjoern A. Zeeb
d4a5edc3e3 lib80211: fix indentation of comments for some netbands.
Whitespace only; no functional changes.

MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC (d/b/a "Netgate")
2020-08-07 12:47:00 +00:00
Dimitry Andric
20885331a9 Put clang/lib/Tooling/Core/Replacement.cpp under SRCS_MIN, since it is
required by both the static analyzer (MK_CLANG_FULL) and clang-format
(MK_CLANG_FORMAT). We could also invent yet another SRCS variant, but
that seems a bit overkill.
2020-08-06 20:55:18 +00:00
Dimitry Andric
e383ec74e5 Merge ^/head r363739 through r363986. 2020-08-06 19:34:55 +00:00
Dimitry Andric
228005931c Apply tentative fix for clang 11 warning in pam_exec(8):
lib/libpam/modules/pam_exec/pam_exec.c:222:56: error: format specifies type 'char *' but the argument has type 'const void *' [-Werror,-Wformat]
               if (asprintf(&envstr, "%s=%s", pam_item_env[i].name, item) < 0)
                                         ~~                         ^~~~
2020-08-06 19:31:52 +00:00
Dimitry Andric
48aaf27bca Update Makefiles under lib/clang and usr.bin/clang for 11.0.0 builds,
and also bump the version in the mtree files.
2020-08-06 19:30:00 +00:00
Dimitry Andric
0bbb5849a3 Regenerate lib/clang/liblldb/LLDBWrapLua.cpp with swig 4.0.2. 2020-08-06 19:28:00 +00:00
Dimitry Andric
5f24ef21be Update generated llvm-project related version headers, config.h files
and add a newly generated lldb Plugins.def file too.
2020-08-06 19:27:03 +00:00
Brandon Bergren
e039e3d1d2 [POWERPC] Fix ppc64 makecontext() parameter overflow handling.
On ELFv2, the overflow parameters in the stack frame are at a different offset
from sp than ELFv1. Adjust code to use the correct offset in all cases.

This had resulted in argv[8] and up being copied to the incorrect address
in the new context's initial stack frame.

This is not necessarily the only bug in this function, I need to do a full
review still and ensure the rest of the math is sane for ELFv2 stack frames.

Reported by:	pherde (Probably. My notes are a bit unclear.)
Reviewed by:	jhibbits (in irc)
Sponsored by:	Tag1 Consulting, Inc.
2020-08-06 17:49:19 +00:00
Mateusz Guzik
94e9ef85c5 pmcstat: implement showing offsets into symbols in top mode
The -I option (and hotkey) is reused for this. Skipping symbol resolution is
moved to the new -A option (and hotkey).

While arguably this violates POLA I think it's a change for the better.
ALso note the -I option was added in head.

Differential Revision:	https://reviews.freebsd.org/D21658
2020-08-05 19:05:49 +00:00
Eric van Gyzen
d7e515ff26 devinfo: add man page links
Add man page links for all functions in devinfo(3).

Reported by:	vim
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2020-08-04 21:09:36 +00:00
Eric van Gyzen
32592d86df devinfo: fix memory leak on error paths
Refactor to create devinfo_free_dev().  Call it to plug a memory leak
on two error paths in devinfo_init_devices().

Reported by:	Coverity
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2020-08-04 21:05:53 +00:00
John Baldwin
ec71044958 ld.bfd requires an explicit emulation for MIPS for ld -r.
Unlike lld, ld.bfd doesn't infer the emulation from the first object
file, but assumes its compiled in default for ld -r.

Differential Revision:	https://reviews.freebsd.org/D25728
2020-08-04 18:23:32 +00:00
Gordon Bergling
74f32f086b directory(3): Add an ERRORS section
- Add an ERRORS section for opendir(3) and closedir(3)
- Document also the errors of readdir(3), readdir_r(3) and telldir(3)
- Convert the code sample into an EXAMPLES section

PR:	75711

Submitted by:	abc <abc at ai1 dot anchorage dot mtaonline dot net>
Reviewed by:	0mp, bcr, jilles
Approved by:	0mp, bcr, jilles
Obtained from:	partial from OpenBSD
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D25892
2020-08-04 08:46:28 +00:00
Kyle Evans
eb578fec7f Ensure libregex is built in time for googletest
In lib/Makefile, we document the dependency with SUBDIR_DEPEND

For buildworld orchestration, just prebuild libregex if GOOGLETEST is
enabled. googletest will get built in a later pass.
2020-08-04 03:43:28 +00:00
Kyle Evans
b4af4f93c6 gtest: link against libregex for GNU extensions
gtest tests want to use \w ([[:alnum:]]) at the very least, which was
causing them to fail after r363679.

Start linking against libregex so that this shorthand is implemented.

PR:		248452
2020-08-04 02:18:24 +00:00
Kyle Evans
61898cde69 libregex: disable some of the unimplemented test cases for now
This should allow the tests to actually pass. Future work will uncomment the
unimplemented tests as they're implemented.
2020-08-04 02:16:43 +00:00
Kyle Evans
18a1e2e9b9 libregex: Implement a subset of the GNU extensions
The entire patch-set is not yet mature enough for commit, but this usable
subset is generally enough for googletest to be happy with and mostly map to
some existing concepts, so they're not as invasive.

The specific changes included here are:

- Branching in BREs with \|
- \w and \W for [[:alnum:]] and [^[:alnum:]] respectively
- \s and \S for [[:space:]] and [^[:space:]] respectively
- Additional quantifiers in BREs, \? and \+ (self-explanatory)

There's some #ifdef'd out work for allowing empty branches as a match-all.
This is a feature that's under assessment... future work will determine
how standard this behavior is and act accordingly.
2020-08-04 02:14:51 +00:00
Kyle Evans
ba8b64de05 regex(3): belatedly document REG_POSIX from r363734
My original patch included this documented, but it appears that I failed to
include the manpage update. Do so now.
2020-08-04 02:06:49 +00:00
Konstantin Belousov
6e0c8e1ae2 Add SOL_LOCAL symbolic constant for unix socket option level.
The constant seems to exists on MacOS X >= 10.8.

Requested by:	swills
Reviewed by:	allanjude, kevans
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D25933
2020-08-03 22:13:02 +00:00
Alex Richardson
9053c1a431 Allow building setmode.c on Linux/macOS
We bootstrap this file to allow compiling FreeBSD on Linux systems since
some boostrap tools use setmode(). Unfortunately, glibc's sys/stat.h
declares a non-static getumask() function (which is unimplemented!) and
that conflicts with the local getumask() function. To work around this
simply use a different name here.

Reviewed By:	brooks, emaste
Differential Revision: https://reviews.freebsd.org/D25929
2020-08-03 18:08:04 +00:00
John Baldwin
338b22234b Pass the full CFLAGS to cpp for MKlib_gen.sh.
GCC's cpp was exiting immediately when it failed to find requested
includes (<ncurses_cfg.h> and <ncurses_defs.h>).  clang-cpp emitted an
error for the missing header files but continued processing the file
(thus not honoring any macros defined in the missing headers).

Arguably, the awk script is buggy since it doesn't check the return
value of the command it executes.

Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D25731
2020-08-03 17:53:15 +00:00
Kristof Provost
7393b267c6 libc: Provide sub fp(s|g)etmask() implementations for RISC-V
RISC-V doesn't support floating-point exceptions.

RISC-V Instruction Set Manual: Volume I: User-Level ISA, 11.2 Floating-Point
Control and Status Register: "As allowed by the standard, we do not support
traps on floating-point exceptions in the base ISA, but instead require
explicit checks of the flags in software. We considered adding branches
controlled directly by the contents of the floating-point accrued exception
flags, but ultimately chose to omit these instructions to keep the ISA simple."

We still need these functions, because some applications (notably Perl) call
them, but we cannot provide a meaningful implementation.

Sponsored by:	Axiado
Differential Revision:	https://reviews.freebsd.org/D25740
2020-08-03 12:48:51 +00:00
Kyle Evans
adeebf4cd4 regex(3): Interpret many escaped ordinary characters as EESCAPE
In IEEE 1003.1-2008 [1] and earlier revisions, BRE/ERE grammar allows for
any character to be escaped, but "ORD_CHAR preceded by an unescaped
<backslash> character [gives undefined results]".

Historically, we've interpreted an escaped ordinary character as the
ordinary character itself. This becomes problematic when some extensions
give special meanings to an otherwise ordinary character
(e.g. GNU's \b, \s, \w), meaning we may have two different valid
interpretations of the same sequence.

To make this easier to deal with and given that the standard calls this
undefined, we should throw an error (EESCAPE) if we run into this scenario
to ease transition into a state where some escaped ordinaries are blessed
with a special meaning -- it will either error out or have extended
behavior, rather than have two entirely different versions of undefined
behavior that leave the consumer of regex(3) guessing as to what behavior
will be used or leaving them with false impressions.

This change bumps the symbol version of regcomp to FBSD_1.6 and provides the
old escape semantics for legacy applications, just in case one has an older
application that would immediately turn into a pumpkin because of an
extraneous escape that's embedded or otherwise critical to its operation.

This is the final piece needed before enhancing libregex with GNU extensions
and flipping the switch on bsdgrep.

[1] http://pubs.opengroup.org/onlinepubs/9699919799.2016edition/

PR:		229925 (exp-run, courtesy of antoine)
Differential Revision:	https://reviews.freebsd.org/D10510
2020-07-29 23:21:56 +00:00
Ryan Moeller
24e337bec5 libpmc: Use known pmc_cpuid buffer size
Use the existing PMC_CPUID_LEN to size pmc_cpuid in the kernel and various
buffers for reading it in libpmc.  This avoids some extra syscalls and
malloc/frees.

While in here, use strlcpy to copy a user-provided cpuid string instead of
memcpy, to make sure we terminate the buffer.

Reviewed by:	mav
MFC after:	1 week
Sponsored by:	iXsystems, Inc.
Differential Revision:	https://reviews.freebsd.org/D25679
2020-07-28 02:56:26 +00:00
Ed Maste
0d2c19d05b libmd: temporarily disable optimized assembly skein1024 implementation
It is apparently broken when assembled by contemporary GNU as as well as
Clang IAS (which is used in the default configuration).

PR:		248221
Reported by:	pizzamig
Sponsored by:	The FreeBSD Foundation
2020-07-23 18:55:47 +00:00
Gordon Bergling
9af25ea3bb geli(8): Add missing commands in the EXAMPLES section
- Add a missing 'geli attach' command
- Fix the passphrase prompt for a 'geli attach' command

Reported by:	Fabian Keil <freebsd-listen at fabiankeil dot de>
Reviewed by:	bcr (mentor)
Approved by:	bcr (mentor)
Differential Revision:	https://reviews.freebsd.org/D25761
2020-07-22 13:00:56 +00:00
Kyle Evans
9d6d8bf8c7 libbe: annotate lbh as __unused in be_is_auto_snapshot_name
lbh is included for consistency with other functions and in case
future work needs to use it, but it is currently unused. Mark it,
and a post-OpenZFS-import world will be able to raise WARNS of
libbe to the default (pending some minor changes to openzfs libzfs).

MFC after:	3 days
2020-07-22 02:09:10 +00:00
Dimitry Andric
716df522b8 Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
10.0.1 final (aka llvmorg-10.0.1-0-gef32c611aa2).

There were no changes since rc2, except in the upstream regression
tests, which we do not ship.

Relnotes:	yes
MFC after:	immediately (no material changes except tag)
2020-07-21 17:34:05 +00:00
Alan Somers
e3f1731aec [skip ci] document close_range(2) as async-signal-safe
Reviewed by:	bcr (manpages)
MFC after:	2 weeks
Sponsored by:	Axcient
Differential Revision:	https://reviews.freebsd.org/D25513
2020-07-21 16:46:40 +00:00
Gordon Bergling
fcc9702f05 geli(8): Add an example on how to use geli(8) with a file as encrypted storage
Reviewed by:	bcr (mentor)
Approved by:	bcr (mentor)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D25741
2020-07-20 13:24:50 +00:00
Simon J. Gerraty
f2be828f97 Revert that! 2020-07-19 23:56:19 +00:00
Simon J. Gerraty
e17f5b1d30 Oops missed Makefile.config 2020-07-19 23:54:00 +00:00
John Baldwin
0bfad43298 Include ABI note tag in shared libraries.
Split the ELF feature note into a separate file that is linked into
*crt1.o the same as crtbrand.S was before.  crtbrand.o is now linked
into crti.o on all platforms in addition to *crt1.o.

Reviewed by:	kib
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D25304
2020-07-16 21:58:43 +00:00
Gregory Neil Shapiro
5b0945b570 Merge sendmail 8.16.1 to HEAD: See contrib/sendmail/RELEASE_NOTES for details
Includes build infrastructure & config updates required for changes in 8.16.1

MFC after:	5 days
2020-07-15 18:28:54 +00:00
Alex Richardson
7425ce4b54 Remove warning that is no longer accurate after r361853
We now build the skein assembly with clangs integrated assembler.

Reviewed By:	emaste
Differential Revision: https://reviews.freebsd.org/D25664
2020-07-15 17:24:34 +00:00
Brooks Davis
7a61fe3a30 Don't imply that all action values can be OR'd.
This is neither POSIX compliant nor what the implementation does.
This could be allowed by changing the value of TCSAFLUSH from 2 to 3,
but that doesn't seem worthwhile after 25+ years.

Reviewed by:	imp
MFC after:	1 week
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D25659
2020-07-15 17:05:37 +00:00
Alex Richardson
a9ea004745 Avoid rebuilding libpmc in every incremental rebuild
Generate libpmc_events.c in a temporary file first and only overwrite it
if the files are actually different.
This avoids compiling and relinking the different variants of libpmc on
every incremental build.

Reviewed By:	jhb
Differential Revision: https://reviews.freebsd.org/D24784
2020-07-15 12:07:47 +00:00
Mateusz Guzik
f1221c59d7 libprocstat: fix kvm filedesc access after introduction of fdescenttbl 2020-07-15 10:13:23 +00:00
Alexander Motin
1791cad0a9 Add stepping to the kern.hwpmc.cpuid string on x86.
It follows the equivalent Linux change to be able to differentiate
skylakex and cascadelakex, sharing the same model but not stepping.

This fixes skylakex handling broken by r363144.

MFC after:	6 days
2020-07-14 18:11:05 +00:00
Li-Wen Hsu
1f4e879031 Revert r351416 to let lib.libc.gen.getmntinfo_test.getmntinfo_test get more test
This is supposed to be fixed by r363068

PR:		240049
Sponsored by:	The FreeBSD Foundation
2020-07-13 18:19:02 +00:00
Alexander Motin
48daf25193 Update AMD Zen1 and add Zen2 events mapping.
MFC after:	2 weeks
2020-07-13 16:23:02 +00:00
Gordon Bergling
e7677232d6 lseek(2): Document the seek behavior better and update the POSIX compliance
In certain situations lseek(2) will return successful although if no seek
was performed. This can happen when operating on devices that don't support
seeking (older tape drives) or when operating on changeable media devices
(such as DVD or Blu-ray devices) without a medium inserted.

Document this within the man page and update the POSIX compliance while here.

PR:		162765
Submitted by:	arundel@
Reported by:	arundel@
Reviewed by:	bcr (mentor)
Approved by:	bcr (mentor)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D25646
2020-07-13 15:52:57 +00:00
Gordon Bergling
e4d47f45eb gethostname(3): Correct the reference of the undefined value HOST_NAME_MAX
PR:		143472
Submitted by:	bcran@
Reported by:	Jeremy Huddleston <jeremyhu at apple dot com>
Reviewed by:	bcr (mentor)
Approved by:	bcr (mentor)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D25647
2020-07-13 15:17:29 +00:00
Alexander Motin
eab56f7f65 Minor textual fixes.
MFC after:	1 week
2020-07-13 14:25:25 +00:00
Allan Jude
0e3972bc19 procctl(2): consistently refer to the last agrument as 'data'
Some older references called it 'arg'

Also fix a syntax error that was underlining an entire sentence.

PR:		247386
Reported by:	Paul Floyd <paulf@free.fr>, PauAmma (research)
MFC after:	2 weeks
Sponsored by:	Klara Inc.
2020-07-11 18:04:09 +00:00
Kyle Evans
423a033ba7 memfd_create: turn on SHM_GROW_ON_WRITE
memfd_create fds will no longer require an ftruncate(2) to set the size;
they'll grow (to the extent that it's possible) upon write(2)-like syscalls.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D25502
2020-07-10 00:45:16 +00:00
Mark Johnston
fe59cb6ba2 Apply the logic from r363051 to semctl(2) and __sem_base field.
Reported by:	Jeffball <jeffball@grimm-co.com>
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D25600
2020-07-09 18:34:54 +00:00
Mark Johnston
f4f16af1d3 Avoid copying out kernel pointers from msgctl(IPC_STAT).
While this behaviour is harmless, it is really just an artifact of the
fact that the msgctl(2) implementation uses a user-visible structure as
part of the internal implementation, so it is not deliberate and these
pointers are not useful to userspace.  Thus, NULL them out before
copying out, and remove references to them from the manual page.

Reported by:	Jeffball <jeffball@grimm-co.com>
Reviewed by:	emaste, kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D25600
2020-07-09 17:26:49 +00:00
Alfredo Dal'Ava Junior
537976d190 test: add libkvm read test
This test checks if value received from kvm_read is sane, based on
value returned by sysctl interface.

This should catch regression on bug fixed by r359160

Reviewed by:	jhb
Approved by:	jhibbits (mentor)
MFC after:	1 week
Sponsored by:	Eldorado Research Institute (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D23783
2020-07-08 18:58:44 +00:00
John Baldwin
bd25b3408e Invoke objcopy on the right object when building Scrt1.o on i386.
This was a copy-paste bug in r362902.  While here, switch to using
${.TARGET}.

Reported by:	Kjell Tore Ullavik <ktullavik@gmail.com>
Reviewed by:	kib
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D25585
2020-07-07 18:19:05 +00:00
Mitchell Horne
10aabc8b83 libefivar: define MDE_CPU_RISCV64
The necessary definitions from EDK2 are present, so this allows the
library to be built on RISC-V.
2020-07-06 17:47:29 +00:00
Mateusz Piotrowski
bd93bdc9b6 Clean up cam.3
- Add a missing Pp [1]
- Remove uses of Tn
- Use "Xr open 2" when appropriate

PR:		247783 [1]
Submitted by:	PauAmma <pauamma@gundo.com> [1]
MFC after:	3 days
2020-07-06 09:53:00 +00:00
John Baldwin
b0ee263dbd Consolidate duplicated logic in csu Makefiles to lib/csu/Makefile.inc.
Reviewed by:	kib
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D25537
2020-07-03 00:09:41 +00:00
Ryan Moeller
e5539fb618 libifconfig: Add function to get bridge status
The new function operates similarly to ifconfig_lagg_get_lagg_status and
likewise is accompanied by a function to free the bridge status data structure.

I have included in this patch the relocation of some strings describing STP
parameters and the PV2ID macro from ifconfig into net/if_bridgevar.h as they
are useful for consumers of libifconfig.

Reviewed by:	kp, melifaro, mmacy
Approved by:	mmacy (mentor)
MFC after:	1 week
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D25460
2020-07-01 02:32:41 +00:00
Mitchell Horne
bbfbc439f2 Fix printf(3) output of long doubles on RISC-V
When the RISC-V port was initially committed to FreeBSD, GCC would
generate 64-bit long doubles, and the definitions in _fpmath.h reflected
that. This was changed to 128-bit in GCC later that year [1], but the
definitions were never updated, despite the documented workaround. This
causes printf(3) and friends to interpret only the low 64-bits of a long
double in ldtoa, thereby printing incorrect values.

Update the definitions now that both clang and GCC generate 128-bit long
doubles.

[1] 54b21fc5ae

PR:		242067
Reported by:	Dennis Clarke <dclarke@blastwave.org>
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D25420
2020-06-29 19:30:35 +00:00
John Baldwin
dc319d05ae Stop using STATIC_CFLAGS.
This was added in r293648 to pass -mlong-calls for crt1.o and gcrt1.o.
The use of -mlong-calls was removed in r358851 for LLVM 10.0, leaving
STATIC_CFLAGS empty.

Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D25305
2020-06-29 17:19:08 +00:00
Dimitry Andric
62cfcf62f6 Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
llvmorg-10.0.1-rc2-0-g77d76b71d7d.

Also add a few more llvm utilities under WITH_CLANG_EXTRAS:

* llvm-dwp, a utility for merging DWARF 5 Split DWARF .dwo files into
  .dwp (DWARF package files)
* llvm-size, a size(1) replacement
* llvm-strings, a strings(1) replacement

MFC after:	3 weeks
2020-06-28 07:43:43 +00:00
Joerg Wunsch
72adb2c07f Explain how to learn about possible recognized locale names
Posix says that the interpretation of the locale string is
"implementation-defined", so we ought to document what is
actually recognized.

Also add a cross reference to locale(1).

PR:		247553
MFC after:	1 week
2020-06-27 20:55:47 +00:00
Mateusz Piotrowski
f4b792fa67 Fix trailing-comma-related typos in the tree when the Xr macro is used
MFC after:	1 week
2020-06-27 11:13:45 +00:00
Matt Macy
4928d02766 Fix libnv build post rename
Submitted by:	Neel Chauhan
Differential Revision:	https://reviews.freebsd.org/D25481
2020-06-27 02:17:04 +00:00
Warner Losh
f045cfb816 Chroot actually appeared in 7th Edition Unix.
Chroot appeared during the development of 7th edition Unix. The FreeBSD jail
documents, incorrectly, that Bill Joy added this to 4.2BSD on 18 March
1982. That was when Bill Joy converted from a statically coded system call glue
to dynamically generated assembler. Chroot was present in 32V, 3BSD, 4.0BSD, 4.1BSD
and 4.1cBSD well in advance of this. Kirk McKusick agrees with this analysis.

See also:
	V7: https://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/libc/sys/chroot.s
	32V: https://minnie.tuhs.org/cgi-bin/utree.pl?file=32V/usr/src/libc/sys/chroot.s
	3BSD: https://minnie.tuhs.org/cgi-bin/utree.pl?file=3BSD/usr/src/libc/sys/chroot.s
	4BSD: https://minnie.tuhs.org/cgi-bin/utree.pl?file=4BSD/usr/src/libc/sys/chroot.s
	4.1cBSD: https://minnie.tuhs.org/cgi-bin/utree.pl?file=4.1cBSD/usr/src/libc/sys/chroot.s

The 6th and earlier editions do not have this system call, nor do they have
anything named chroot in the trees available from TUHS.

Reviewed by: allanjude@
Differential Revision: https://reviews.freebsd.org/D25475
2020-06-26 22:05:23 +00:00
John Baldwin
85a2ea3f57 Only include object files from .ALLSRC when linking crt1 objects.
Reported by:	np, peterj
Reviewed by:	kib, emaste
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D25469
2020-06-26 19:46:30 +00:00
David Bright
9b934d4360 Add CAP_EVENT to pidfiles.
CAP_EVENT was omitted on pidfiles (in
pidfile_open()). There seems no reason why a process that creates
and writes a pidfile cannot monitor events on that file. This mod adds
the capability.

Reviewed by:	cem@
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D25363
2020-06-25 21:34:43 +00:00
Dimitry Andric
ea143d1be6 Fix copy/paste mistake in kvm_getswapinfo(3)
It seems this manpage was copied from kvm_getloadavg(3), but the
DIAGNOSTICS section was not updated completely. Update the section with
correct information about a return value of -1.

MFC after:	3 days
2020-06-25 20:04:35 +00:00
Pawel Biernacki
eb8a06388c man page of select(2) should mention pselect(2)
Reviewed by:	bcr (manpages), kib, trasz
Approved by:	kib (mentor)
MFC after:	7 days
Sponsored by:	Mysterious Code Ltd.
Differential Revision:	https://reviews.freebsd.org/D25169
2020-06-25 12:31:05 +00:00
Dimitry Andric
0946e70a3b Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
llvmorg-10.0.0-129-gd24d5c8e308. Getting closer to 10.0.1-rc2.

MFC after:	3 weeks
2020-06-25 08:15:10 +00:00
John Baldwin
99db5849f7 Always compile the brand and ignore init ELF notes standalone.
Reviewed by:	kib
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D25374
2020-06-24 17:54:24 +00:00
Conrad Meyer
0a9ab9f549 Add WITH_CLANG_FORMAT option
clang-format is enabled conditional on either WITH_CLANG_EXTRAS or
WITH_CLANG_FORMAT.  Some sources in libclang are build conditional on
either rule, and obviously the clang-format binary itself depends on the
rule.

clang-format could still use a manual page.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D25427
2020-06-24 17:03:42 +00:00
Mitchell Horne
2d143336de Enable long double tests on RISC-V
Some of the NetBSD contributed tests are gated behind the
__HAVE_LONG_DOUBLE flag. This flag seems to be defined only for
platforms whose long double is larger than their double. I could not
find this explicitly documented anywhere, but it is implied by the
definitions in NetBSD's sys/arch/${arch}/include/math.h headers, and the
following assertion from the UBSAN code:

  #ifdef __HAVE_LONG_DOUBLE
      long double LD;
      ASSERT(sizeof(LD) > sizeof(uint64_t));
  #endif

RISC-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:	ngie
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D25419
2020-06-24 13:11:19 +00:00
Kirk McKusick
d7fcdf5d48 Correctly describe the return values for the libufs library sbget()
and sbput() functions that respectively read and write the superblock.

PR:           247425
Sponsored by: Netflix
2020-06-23 21:37:12 +00:00
Kirk McKusick
92c839a156 The libufs library needs to track and free the new fs_si structure
in addition to the fs_csp structure that it references.

PR:           247425
Sponsored by: Netflix
2020-06-23 21:28:26 +00:00
Kirk McKusick
7ac5cc13b5 Align comments in struct uufsd structure. No semantic change.
Sponsored by: Netflix
2020-06-23 21:17:13 +00:00
Ryan Moeller
5f018c9147 libdevdctl: Force full match of "timestamp" field name
OpenZFS generates events with a "zio_timestamp" field, which gets mistaken for
"timestamp" by libdevdctl due to imprecise string matching.  Then later it is
assumed a "timestamp" field exists when it doesn't and an exception is thrown.

Add a space to the search string so we match exactly "timestamp" rather than
anything with that as a suffix.

Approved by:	mav (mentor)
MFC after:	3 days
Sponsored by:	iXsystems, Inc.
2020-06-23 16:29:59 +00:00
Piotr Pawel Stefaniak
2abf05c4c6 strtok(3): make it easier to find the RETURN VALUES section
MFC after:	1 week
2020-06-22 11:03:36 +00:00
Baptiste Daroussin
5b990a9463 Revert r362466
Such change should not have happen without prior discussion and review.

With hat:	transitioning core
2020-06-22 07:46:24 +00:00
Michael Tuexen
f82d3b3988 Add include missing from my last commit. 2020-06-21 23:47:27 +00:00
Michael Tuexen
c5d9e5c99e Cleanup the defintion of struct sctp_getaddresses. This stucture
is used by the IPPROTO_SCTP level socket options SCTP_GET_PEER_ADDRESSES
and SCTP_GET_LOCAL_ADDRESSES, which are used by libc to implement
sctp_getladdrs() and sctp_getpaddrs().
These changes allow an old libc to work on a newer kernel.
2020-06-21 23:12:56 +00:00
Hans Petter Selasky
7747001b12 Improve wording to be more precise and clear.
No functional change intended.

s/Master Boot/Main Boot/ (also called MBR)

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2020-06-21 13:34:08 +00:00
Xin LI
65422c964a liblzma: Make liblzma use libmd implementation of SHA256.
MFC after:	2 weeks
PR:		200142
2020-06-20 21:32:07 +00:00
Michael Tuexen
ed82c2edd6 Use a struct sockaddr_in pr struct sockaddr_in6 as the option value
for the IPPROTO_SCTP level socket options SCTP_BINDX_ADD_ADDR and
SCTP_BINDX_REM_ADDR. These socket option are intended for internal
use only to implement sctp_bindx().
This is one user of struct sctp_getaddresses less.
struct sctp_getaddresses is strange and will be changed shortly.
2020-06-20 21:06:02 +00:00
Dimitry Andric
e837bb5cfb Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
llvmorg-10.0.0-97-g6f71678ecd2 (not quite 10.0.1 rc2, as more fixes are
still pending).

MFC after:	3 weeks
2020-06-20 20:06:52 +00:00
Piotr Pawel Stefaniak
830efe5539 Make vipw error message less cryptic
Unable to find an editor, vipw would give this error:
# env EDITOR=fnord vipw
vipw: pw_edit(): No such file or directory

vigr or crontab do better:
# env EDITOR=fnord crontab -e
crontab: no crontab for root - using an empty one
crontab: fnord: No such file or directory
crontab: "fnord" exited with status 1

After this change, vipw behaves more like vigr or crontab:
# env EDITOR=fnord vipw
vipw: fnord: No such file or directory
vipw: "fnord" exited with status 1

Reviewed by:	rpokala, emaste
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D25369
2020-06-20 06:20:00 +00:00
Piotr Pawel Stefaniak
39c64ed6d1 libutil: remove extraneous ": " from error messages
Each of the err() family of functions already takes care of that.
2020-06-20 06:10:42 +00:00
Mateusz Piotrowski
3b3e9cfb1b Fix a typo in cpuset_getdomain.2
PR:		247385
Reported by:	Paul Floyd <paulf free.fr>
MFC after:	1 week
2020-06-18 19:03:20 +00:00
Michael Tuexen
df2fca7ba8 Whitespace changes, not functional change intended.
MFC after:		1 week
2020-06-18 16:22:09 +00:00
Gordon Bergling
b7d33ccd65 fgetln(3): Add a Caveats Section
Reviewed by:	yuripv, bcr (mentor)
Approved by:	bcr (mentror)
Obtained from:	OpenBSD
MFC after:	7 days
Differential Revision:	https://reviews.freebsd.org/D24916
2020-06-18 13:13:04 +00:00
Xin LI
e743706d58 Fix installation of magic file.
Reported by:	lwhsu
MFC after:	2 weeks
X-MFC-with:	r362258
2020-06-17 15:57:59 +00:00
Andrew Turner
b6aadd183a Update opencsd to 0.14.2
Sponsored by:	Innovate UK
2020-06-17 10:42:20 +00:00
Xin LI
2726a70148 MFV r362254: file 5.39.
MFC after:	2 weeks
2020-06-17 07:41:28 +00:00
Marc Fonvieille
a9c7e6bd61 Fix pointer name to match the name used in the function prototype
above (and in termios.c).

Discussed with:	Rodney W. Grimes <rgrimes@FreeBSD.org>
2020-06-16 17:05:38 +00:00
Gordon Bergling
421f325efc libcasper(3): Document HISTORY within the manpages
Reviewed by:	bcr (mentor)
Approved by:	bcr (mentor)
MFC after:		7 days
Differential Revision:	https://reviews.freebsd.org/D24695
2020-06-16 16:48:52 +00:00
John Baldwin
99282790b7 Remove the sed hack for ABI tag notes.
The ELF notes compiled in C were placed in a section with the wrong type
(SHT_PROGBITS instead of SHT_NOTE).  Previously, sed was used on the
generated assembly to rewrite the section type.  Instead, write the notes
in assembly which permits setting the correct section type directly.

While here, move inline assembly entry points out of C and into assembly
for aarch64, arm, and riscv.

Reviewed by:	kib
Tested on:	amd64 (cirrus-ci), riscv64
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D25211
2020-06-15 19:38:48 +00:00
Gordon Bergling
e0f7c06de2 libc manpages: various improvements from NetBSD
- Add STANDARDS and HISTORY sections within the appropriate manpages
- Mention two USENIX papers within kqueue(2) and strlcpy(3)

Reviewed by:	bcr (mentor)
Approved by:	bcr (mentor)
Obtained from:	NetBSD
MFC after:	7 days
Differential Revision: https://reviews.freebsd.org/D24650
2020-06-14 05:59:30 +00:00
Gordon Bergling
bc89b58def libutil: Document function HISTORY within the manpages
Reviewed by:	bcr (mentor)
Approved by:	bcr (mentor)
MFC after:	7 days
Differential Revision:	https://reviews.freebsd.org/D24795
2020-06-14 05:35:02 +00:00
Konstantin Belousov
6cf8fba381 procctl(2): document PROC_KPTI
Reviewed by:	bcr
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D25258
2020-06-13 18:19:42 +00:00
Konstantin Belousov
7e54fea1d1 procctl(2): consistently refer to the data pointer as 'data'.
Reviewed by:	bcr
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D25258
2020-06-13 18:18:34 +00:00
Simon J. Gerraty
3e6e3de0aa verify_pcr_export: bump kenv_mvallen if needed
The loader.ve.hashed list can easily exceed KENV_MVALLEN.
If so, bump kenv_mvallen to a multiple of KENV_MVALLEN to
accommodate the value.

Reviewed by:	stevek
MFC after:	1 week
2020-06-12 21:55:30 +00:00
Kyle Evans
ebff66b3c3 posix_spawn: fix for some custom allocator setups
libc cannot assume that aligned_alloc and free come from jemalloc, or that
any application providing its own malloc and free is actually providing
aligned_alloc.

Switch back to malloc and just make sure we're passing a properly aligned
stack into rfork_thread, as an application perhaps can't reasonably replace
just malloc or just free without headaches.

This unbreaks ksh93 after r361996, which provides malloc/free but no
aligned_alloc.

Reported by:	freqlabs
Diagnosed by:	Andrew Gierth <andrew_tao173.riddles.org.uk>
X-MFC-With:	r361996
2020-06-12 18:13:32 +00:00
Konstantin Belousov
2ef84b7da9 Add pthread_getname_np() and pthread_setname_np() aliases for
pthread_get_name_np() and pthread_set_name_np().

This re-applies r361770 after compatibility fixes.

Reviewed by:	antoine, jkim, markj
Tested by:	antoine (exp-run)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D25117
2020-06-10 22:13:24 +00:00
Kyle Evans
1849fbb0b1 Add missing shell script from r361995
Pointy hat:	kevans
Reported by:	rpokala
X-MFC-With:	r361995
2020-06-10 03:04:36 +00:00
Kyle Evans
f0fbdf1f4f execvPe: obviate the need for potentially large stack allocations
Some environments in which execvPe may be called have a limited amount of
stack available. Currently, it avoidably allocates a segment on the stack
large enough to hold PATH so that it may be mutated and use strsep() for
easy parsing. This logic is now rewritten to just operate on the immutable
string passed in and do the necessary math to extract individual paths,
since it will be copying out those segments to another buffer anyways and
piecing them together with the name for a full path.

Additional size is also needed for the stack in posix_spawnp(), because it
may need to push all of argv to the stack and rebuild the command with sh in
front of it. We'll make sure it's properly aligned for the new thread, but
future work should likely make rfork_thread a little easier to use by
ensuring proper alignment.

Some trivial cleanup has been done with a couple of error writes, moving
strings into char arrays for use with the less fragile sizeof().

Reported by:	Andrew Gierth <andrew_tao173.riddles.org.uk>
Reviewed by:	jilles, kib, Andrew Gierth
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D25038
2020-06-10 01:32:13 +00:00
Kyle Evans
301cb491ea execvp: fix up the ENOEXEC fallback
If execve fails with ENOEXEC, execvp is expected to rebuild the command
with /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 get
terminated.  We must allocate no less than three * sizeof(char *) so we can
properly terminate at all times. For the non-NULL argv standard case, we
count all the non-NULL elements and actually skip the first argument, so we
end up capturing the NULL terminator in our bcopy().

The second detail is that the spec is actually worded such that we should
have been preserving argv[0] as passed to execvp:

"[...] executed command shall be as if the process invoked the sh utility
using execl() as follows:

execl(<shell path>, arg0, file, arg1, ..., (char *)0);

where <shell path> is an unspecified pathname for the sh utility, file is
the process image file, and for execvp(), where arg0, arg1, and so on
correspond 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 touching
it. 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" for
argv[] in this specific instance.

Some light tests are added to try and detect some components of handling the
ENOEXEC fallback; posix_spawnp_enoexec_fallback_null_argv0 is likely not
100% reliable, but it at least won't raise false-alarms and it did result in
useful 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 Gierth
MFC after:	1 week
2020-06-10 01:30:37 +00:00
Kyle Evans
04391da364 libusb: improve compatibility
Specifically, add LIBUSB_CLASS_PHYSICAL and the libusb_has_capability API.
Descriptions and functionality for these derived from the
documentation at [0].  The current set of capabilities are all supported by
libusb.

These were detected as missing after updating net/freerdp to 2.1.1, which
attempted to use both.

[0] http://libusb.sourceforge.net/api-1.0/group__libusb__misc.html

Reviewed by:	hselasky
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D25194
2020-06-09 17:17:43 +00:00
Ed Maste
24ed6f550a Rename skein_block_asm.s to .S and assemble using Clang IAS
Comparing the object files produced by GNU as 2.17.50 and Clang IAS
shows many immaterial changes in strtab etc., and one material change
in .text:

   1bac:  4c 8b 4f 18             mov    0x18(%rdi),%r9
   1bb0:  eb 0e                   jmp    1bc0 <Skein1024_block_loop>
-  1bb2:  66 66 2e 0f 1f 84 00    data16 nopw %cs:0x0(%rax,%rax,1)
-  1bb9:  00 00 00 00
-  1bbd:  0f 1f 00                nopl   (%rax)
+  1bb2:  66 2e 0f 1f 84 00 00    nopw   %cs:0x0(%rax,%rax,1)
+  1bb9:  00 00 00
+  1bbc:  0f 1f 40 00             nopl   0x0(%rax)

 0000000000001bc0 <Skein1024_block_loop>:
 Skein1024_block_loop():
   1bc0:  4c 8b 47 10             mov    0x10(%rdi),%r8
   1bc4:  4c 03 85 c0 00 00 00    add    0xc0(%rbp),%r8

That is, GNU as and Clang's integrated assembler use different multi-
byte NOPs for alignment (GNU as emits an 11 byte NOP + a 3 byte NOP,
while Clang IAS emits a 10 byte NOP + a 4 byte NOP).

Dependency cleanup hacks are not required, because we do not create
.depend files from GNU as.

Reviewed by:	allanjude, arichardson, cem, tsoome
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D8434
2020-06-06 00:35:41 +00:00
Ed Maste
f2b8688664 Also pass SKEIN_USE_ASM to the assembler, via AFLAGS 2020-06-05 18:56:43 +00:00
Mark Johnston
13776bf736 librtld_db: Handle anonymous mappings below the first file mapping.
r360979 erroneously assumed that the lowest mapping in an address space
would be a file mapping, but of course this is not true in general.

Reported and tested by:	Frederic Chardon <chardon.frederic@gmail.com>
MFC after:	3 days
2020-06-05 18:44:14 +00:00
Ed Maste
310e81aede Apply C SKEIN_LOOP setting only to skein_block.c
Otherwise if assembling skein_block_asm.s with Clang's integrated assembler
we can pass conflicting SKEIN_LOOP settings (via CFLAGS and ACFLAGS).
2020-06-05 17:00:38 +00:00
Alex Richardson
3fe733f375 csu: Avoid additional nops in the MIPS INIT_CALL_SEQ macro
Since we had a .set reorder, the nop after the "jal" was being placed after
the delay slot, resulting in two nops.
While changing this code also guard the .set noreorder with .set push/pop
and use $zero as the cpsetup save register since we don't need to save $gp.

Reviewed By:	jhb
Differential Revision: https://reviews.freebsd.org/D25025
2020-06-05 08:46:55 +00:00
Alex Richardson
652f26f9c5 Avoid using non-portable dd status=none flag
Copying the approach chosen in r309412. This fixes building the libc tests
on 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 script
that 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:	brooks
Differential Revision: https://reviews.freebsd.org/D24785
2020-06-05 08:46:50 +00:00
Hans Petter Selasky
eff8154913 USB HID descriptors may push/pop the current state to allow
description of items residing in a so-called union. FreeBSD currently
only supports 4 such pop levels.

If the push level is not restored within the processing of the same
HID item, an invalid memory location may be used for subsequent HID
item processing.

Verify that the push level is always valid when processing HID items.

Reported by:	Andy Nguyen (Google)
MFC after:	3 days
Sponsored by:	Mellanox Technologies
2020-06-05 07:57:16 +00:00
John Baldwin
00a4311adc Refer to AES-CBC as "aes-cbc" rather than "rijndael-cbc" for IPsec.
At this point, AES is the more common name for Rijndael128.  setkey(8)
will still accept the old name, and old constants remain for
compatiblity.

Reviewed by:	cem, bcr (manpages)
MFC after:	2 weeks
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D24964
2020-06-04 22:58:37 +00:00
Kyle Evans
63619b6dba vfs: add restrictions to read(2) of a directory [2/2]
This commit adds the priv(9) that waters down the sysctl to make it only
allow read(2) of a dirfd by the system root. Jailed root is not allowed, but
jail policy and superuser policy will abstain from allowing/denying it so
that a MAC module can fully control the policy.

Such a MAC module has been written, and can be found at:
https://people.freebsd.org/~kevans/mac_read_dir-0.1.0.tar.gz

It is expected that the MAC module won't be needed by many, as most only
need to do such diagnostics that require this behavior as system root
anyways. Interested parties are welcome to grab the MAC module above and
create a port or locally integrate it, and with enough support it could see
introduction to base. As noted in mac_read_dir.c, it is released under the
BSD 2 clause license and allows the restrictions to be lifted for only
jailed root or for all unprivileged users.

PR:		246412
Reviewed by:	mckusick, kib, emaste, jilles, cy, phk, imp (all previous)
Reviewed by:	rgrimes (latest version)
Differential Revision:	https://reviews.freebsd.org/D24596
2020-06-04 18:17:25 +00:00
Kyle Evans
dcef4f65ae vfs: add restrictions to read(2) of a directory [1/2]
Historically, we've allowed read() of a directory and some filesystems will
accommodate (e.g. ufs/ffs, msdosfs). From the history department staffed by
Warner: <<EOF

pdp-7 unix seemed to allow reading directories, but they were weird, special
things there so I'm unsure (my pdp-7 assembler sucks).

1st Edition's sources are lost, mostly. The kernel allows it. The
reconstructed sources from 2nd or 3rd edition read it though.

V6 to V7 changed the filesystem format, and should have been a warning, but
reading directories weren't materially changed.

4.1b BSD introduced readdir because of UFS. UFS broke all directory reading
programs in 1983. ls, du, find, etc all had to be rewritten. readdir() and
friends were introduced here.

SysVr3 picked up readdir() in 1987 for the AT&T fork of Unix. SysVr4 updated
all the directory reading programs in 1988 because different filesystem
types were introduced.

In the 90s, these interfaces became completely ubiquitous as PDP-11s running
V7 faded from view and all the folks that initially started on V7 upgraded
to SysV. Linux never supported this (though I've not done the software
archeology to check) because it has always had a pathological diversity of
filesystems.
EOF

Disallowing read(2) on a directory has the side-effect of masking
application bugs from relying on other implementation's behavior
(e.g. Linux) of rejecting these with EISDIR across the board, but allowing
it has been a vector for at least one stack disclosure bug in the past[0].

By POSIX, this is implementation-defined whether read() handles directories
or not. Popular implementations have chosen to reject them, and this seems
sensible: the data you're reading from a directory is not structured in some
unified way across filesystem implementations like with readdir(2), so it is
impossible for applications to portably rely on this.

With this patch, we will reject most read(2) of a dirfd with EISDIR. Users
that know what they're doing can conscientiously set
bsd.security.allow_read_dir=1 to allow read(2) of directories, as it has
proven useful for debugging or recovery. A future commit will further limit
the sysctl to allow only the system root to read(2) directories, to make it
at least relatively safe to leave on for longer periods of time.

While we're adding logic pertaining to directory vnodes to vn_io_fault, an
additional assertion has also been added to ensure that we're not reaching
vn_io_fault with any write request on a directory vnode. Such request would
be a logical error in the kernel, and must be debugged rather than allowing
it to potentially silently error out.

Commented out shell aliases have been placed in root's chsrc/shrc to promote
awareness that grep may become noisy after this change, depending on your
usage.

A tentative MFC plan has been put together to try and make it as trivial as
possible to identify issues and collect reports; note that this will be
strongly re-evaluated. Tentatively, I will MFC this knob with the default as
it is in HEAD to improve our odds of actually getting reports. The future
priv(9) to further restrict the sysctl WILL NOT BE MERGED BACK, so the knob
will be a faithful reversion on stable/12. We will go into the merge
acknowledging that the sysctl default may be flipped back to restore
historical behavior at *any* point if it's warranted.

[0] https://www.freebsd.org/security/advisories/FreeBSD-SA-19:10.ufs.asc

PR:		246412
Reviewed by:	mckusick, kib, emaste, jilles, cy, phk, imp (all previous)
Reviewed by:	rgrimes (latest version)
MFC after:	1 month (note the MFC plan mentioned above)
Relnotes:	absolutely, but will amend previous RELNOTES entry
Differential Revision:	https://reviews.freebsd.org/D24596
2020-06-04 18:09:55 +00:00
Konstantin Belousov
064c283d65 Revert r361770 "Add pthread_getname_np() and pthread_setname_np() aliases" for now.
It is not compatible enough with Linux.

Requested by:	antoine, jkim
Sponsored by:	The FreeBSD Foundation
2020-06-04 09:06:03 +00:00
Konstantin Belousov
9bed49fea4 Add pthread_getname_np() and pthread_setname_np() aliases
for pthread_get_name_np() and pthread_set_name_np(), to be
compatible with Linux.

PR:	238404
Proposed and reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D25117
2020-06-03 20:54:36 +00:00
Ed Maste
3f65edb369 mmap.2: correct prot argument terminology
One of the error descriptions referred to permissions; in context the
meaning was probably clear, but the prot values are properly called
protections.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2020-06-03 20:42:52 +00:00
John Baldwin
ae84ff9c47 Document SO_NO_OFFLOADS and SO_NO_DDP.
Reviewed by:	bcr, np
MFC after:	1 week
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D25043
2020-06-03 18:59:31 +00:00
Mark Johnston
c78e42e207 cap_fileargs: Fix a descriptor leak in the service process.
The service handler for fileargs_open() tries to pre-open multiple files
and pass descriptors for each back to the sandboxed process in a single
message.  This is to amortize the cost of round-trips between the two
processes.

The service process adds a "cache" nvlist to the reply to "open",
containing file descriptors for pre-opened files.  However, when adding
that nvlist to the reply, it was making a copy, effectively leaking the
cached descriptors.

While here, fix spelling in a local variable name.

PR:		241226
Reviewed by:	oshogbo
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D25095
2020-06-01 15:32:13 +00:00
Tijl Coosemans
3eee8f1cbb Fix installation of libxo encoder modules.
Because the install location was hardcoded in the Makefile as
/usr/lib/libxo/encoder, the lib32 version was installed over the native
version.  Replace /usr/lib with ${LIBDIR}.

Also define SHLIB_NAME instead of LIB + FILES.  This prevents building a
static library.

MFC after:	2 weeks
2020-05-31 17:20:17 +00:00
Ed Maste
c5ea81f7a6 rename in-tree libevent v1 to libevent1
r316063 installed pf's embedded libevent as a private lib, with headers
in /usr/include/private/event.  Unfortunately we also have a copy of
libevent v2 included in ntp, which needed to be updated for compatibility
with OpenSSL 1.1.

As unadorned 'libevent' generally refers to libevent v2, be explicit that
this one is libevent v1.

Reviewed by:	vangyzen (earlier)
Differential Revision:	https://reviews.freebsd.org/D17275
2020-05-28 22:05:50 +00:00
Rick Macklem
6f05ed08c2 Add an entry to Symbol.map for the rpctls_syscall added by r361599.
Reviewed by:	brooks
Differential Revision:	https://reviews.freebsd.org/D24949
2020-05-28 21:26:26 +00:00
Eric van Gyzen
1add7d0f8d libifconfig: remove redundant NULL check
Submitted by:	Puneeth_kumar.Jothaiah@emc.com
Reported by:	Coverity
Sponsored by:	Dell EMC Isilon
2020-05-27 18:26:10 +00:00
Andriy Gapon
56e8cb87c6 libprocstat: try to fix fallout from r361363
The revision caused libprocstat to have two undefined symbols:
- __start_set_pcpu
- __stop_set_pcpu
probably because of __GLOBL() used in sys/pcpu.h under _KERNEL.
The symbols are not accessed by anything and the linker in base does not
complain about them, but some ports are failing to build.
Hack around the problem by providing definitions for those symbols.

Probably there is a better solution, but I could not think of it yet.

Reported by:	zeising
MFC after:	3 days
X-MFC with:	r361363
Sponsored by:	Panzura
2020-05-24 14:54:21 +00:00
Conrad Meyer
37f1f2684f Update to Zstandard 1.4.5
As usual, the full release notes are found on Github:

  https://github.com/facebook/zstd/releases/tag/v1.4.5

Notable changes include:

* Improved decompress performance on amd64 and arm (5-10%
  and 15-50%, respectively).
* '--patch-from' zstd(1) CLI option, which provides something like a very fast
  version of bspatch(1) with slightly worse compression.  See release notes.

In this update, I dropped the 3-year old -O0 workaround for an LLVM ARM bug;
the bug was fixed in LLVM SVN in 2017, but we didn't remove this workaround
from our tree until now.

MFC after:	I won't, but feel free
Relnotes:	yes
2020-05-23 21:23:46 +00:00
Conrad Meyer
bc64b5ce19 Import Zstd 1.4.5 2020-05-23 20:37:33 +00:00
Dimitry Andric
d65cd7a57b Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
llvmorg-10.0.1-rc1-0-gf79cd71e145 (aka 10.0.1 rc1).

MFC after:	3 weeks
2020-05-23 10:32:18 +00:00
Konstantin Belousov
c8ad15b6ff Implement Solaris-like link_map l_refname member.
The implementation is based on the public documentation, in particular
dlinfo(3) from Solaris.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2020-05-22 17:52:09 +00:00
Andriy Gapon
8a719b0cee libprocstat: fix ZFS support
First of all, znode_phys_t hasn't been used for storing file attributes
for a long time now.  Modern ZFS versions use a System Attribute table
with a flexible layout.  But more importantly all the required
information is available in znode_t itself.

It's not easy to include zfs_znode.h in userland without breaking code
because the most interesting parts of the header are kernel-only. And
hardcoding field offsets is too fragile.  So, I created a new
compilation unit that includes zfs_znode.h using some mild kludges to
get it and its dependencies to compile in userland.  The compilation
unit exports interesting field offsets and does not have any other code.

PR:		194117
Reviewed by:	markj
MFC after:	2 weeks
Sponsored by:	Panzura
Differential Revision: https://reviews.freebsd.org/D24941
2020-05-22 11:20:23 +00:00
Konstantin Belousov
d0ca9a7fe4 Restore the binary compatibility for link_map l_addr.
Keep link_map l_addr binary layout compatible, rename l_addr to l_base
where rtld returns map base.  Provide relocbase in newly added l_addr.

This effectively reverts the patch to the initial version of D24918.

Reported by: antoine (portmgr)
Reviewed by:	jhb, markj
Tested by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D24946
2020-05-21 22:24:23 +00:00
Cy Schubert
091e9e469b MFV r361322:
Update unbound 1.9.6 --> 1.10.1.

Bug Fixes:
 - CVE-2020-12662 Unbound can be tricked into amplifying an incoming
   query into a large number of queries directed to a target.
 - CVE-2020-12663 Malformed answers from upstream name servers can be
   used to make Unbound unresponsive.

Reported by:	emaste
MFC after:	3 days
Relnotes:	yes
Security:	CVE-2020-12662, CVE-2020-12663
2020-05-21 21:00:46 +00:00
Andriy Gapon
e165a15b5f libprocstat: fix reading of file descriptor table via kvm
This seems to have been broken since r247602 (from year 2013!).
Can be easily tested with
  fstat -N /boot/kernel/kernel -M /var/crash/vmcore.last

MFC after:	1 week
Sponsored by:	Panzura
2020-05-21 13:46:30 +00:00
Ryan Moeller
245bfd34da Deduplicate fsid comparisons
Comparing fsid_t objects requires internal knowledge of the fsid structure
and yet this is duplicated across a number of places in the code.

Simplify by creating a fsidcmp function (macro).

Reviewed by:	mjg, rmacklem
Approved by:	mav (mentor)
MFC after:	1 week
Sponsored by:	iXsystems, Inc.
Differential Revision:	https://reviews.freebsd.org/D24749
2020-05-21 01:55:35 +00:00
Konstantin Belousov
2c6d9dc0bb Change the samantic of struct link_map l_addr member.
It previously returned the object map base address, while all other
ELF operating systems return load offset, i.e. the difference between
map base and the link base.

Explain the meaning of the field in the man page.

Stop filling the mips-only l_offs member, which is apparently unused.

PR:	246561
Requested by:	Damjan Jovanovic <damjan.jov@gmail.com>
Reviewed by:	emaste, jhb, cem (previous version)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D24918
2020-05-20 22:08:26 +00:00
Martin Matuska
de6fa6b43b MFV r361280:
Update libarchive to 3.4.3

Relevant vendor changes:
  PR #1352: support negative zstd compression levels
  PR #1359: improve zstd version checking
  PR #1348: support RHT.security.selinux from GNU tar
  PR #1357: support for archives compressed with pzstd
  PR #1367: fix issues in acl tests
  PR #1372: child handling cleanup
  PR #1378: fix memory leak from passphrase callback
2020-05-20 20:58:48 +00:00
Benedict Reuschling
d50ff7de21 Fix a typo: argments -> arguments
PR:		243294
Submitted by:	Igor Ostapenko
MFC after:	5 days
2020-05-19 11:05:27 +00:00
Kyle Evans
880ff10ba9 procctl(2): correct a minor cut-n-pasto
This is clearly describing PROC_PROTMAX_FORCE_DISABLE, rather than
PROC_ASL_FORCE_DISABLE.

Submitted by:	sigsys@gmail.com
2020-05-16 04:52:29 +00:00
Ed Maste
65a1d63665 libalias: retire cuseeme support
The CU-SeeMe videoconferencing client and associated protocol is at this
point a historical artifact; there is no need to retain support for this
protocol today.

Reviewed by:	philip, markj, allanjude
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D24790
2020-05-16 02:29:10 +00:00
Conrad Meyer
8a68ae80f6 vmm(4), bhyve(8): Expose kernel-emulated special devices to userspace
Expose the special kernel LAPIC, IOAPIC, and HPET devices to userspace
for use in, e.g., fallback instruction emulation (when userspace has a
newer instruction decode/emulation layer than the kernel vmm(4)).

Plumb the ioctl through libvmmapi and register the memory ranges in
bhyve(8).

Reviewed by:	grehan
Differential Revision:	https://reviews.freebsd.org/D24525
2020-05-15 15:54:22 +00:00
Benedict Reuschling
44318fb2f9 Fix SYNPOSIS section to point to the proper include directive.
netgraph(3) points to #include <netgraph/netgraph.h>, which is kernel only.
The man page refers to the user-space part of the netgraph module, which is
located in <netgraph.h>.

Submitted by:	lutz_donnerhacke.de
Approved by:	bcr
Differential Revision:	https://reviews.freebsd.org/D23814
2020-05-15 12:04:39 +00:00
Konstantin Belousov
1659238a0c Implement RTLD_DEEPBIND.
PR:	246462
Tested by:	Martin Birgmeier <d8zNeCFG@aon.at>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D24841
2020-05-15 11:58:01 +00:00
Konstantin Belousov
dcc6ef1644 Add memalign(3), mostly for glibc compatibility.
Reviewed by:	emaste, imp (previous version)
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D24307
2020-05-14 21:12:08 +00:00
Brandon Bergren
3dbb9df36b [PowerPC] Fix wrong instructions in _savegpr_X.
We were accidentally using stfd instead of stw in our SAVEGPR macro.

This has almost certainly been causing crashes when compiling with -Os.

Reviewed by:	jhibbits (in irc)
MFC after:	3 days
Sponsored by:	Tag1 Consulting, Inc.
2020-05-14 04:00:35 +00:00
Mark Johnston
cf55371827 Re-enable proc_test:symbol_lookup after r360979.
PR:		244732
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2020-05-12 17:05:55 +00:00
Mark Johnston
13c2d789fb librtld_db: Fix shlib mapping offsets.
kve_offset gives the offset into the backing file, which is not what we
want since different segments may map the same page.  Use the base of
the mapping to determine the offset exported by librtld_db instead.

PR:		244732
Reported by:	Jenkins, Nicolò Mazzucato <nicomazz97@gmail.com>
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2020-05-12 17:00:47 +00:00
Eric van Gyzen
fac6dee9eb Remove tests for obsolete compilers in the build system
Assume gcc is at least 6.4, the oldest xtoolchain in the ports tree.
Assume clang is at least 6, which was in 11.2-RELEASE.  Drop conditions
for older compilers.

Reviewed by:	imp (earlier version), emaste, jhb
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D24802
2020-05-12 15:22:40 +00:00
Xin LI
16ade779ef Generate zlib.pc from source.
Reviewed by:		bapt
MFC after:		3 days
Differential Revision:	https://reviews.freebsd.org/D24806
2020-05-12 01:47:33 +00:00
Dimitry Andric
28845ae1ab Use -fno-asynchronous-unwind-tables to compile lib/csu
Summary:
In r209294 kib added -fno-asynchronous-unwind-tables to the compile
flags for the GNU C startup components. This was done to work around a
BFD ld assertion, "no .eh_frame_hdr table will be created", which is
produced because of the layout of the startup objects.

Add the same flag to lib/csu too, for the same reason. And similarly to
r209294, also add -fno-omit-frame-pointer.

This is primarily meant to quickly MFC to stable/11, so it can end up in
the 11.4 release, as a fix for https://bugs.freebsd.org/246322.

PR:		246322
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D24797
2020-05-11 19:36:38 +00:00
Benedict Reuschling
6a7016194d Add HISTORY sections to document when this
functionality first appeared in FreeBSD.

Submitted by:	Gordon Bergling gbergling_gmail.com
Approved by:	bcr
Differential Revision:	https://reviews.freebsd.org/D24677
2020-05-05 19:31:47 +00:00
Conrad Meyer
b34f8412c5 strdup.3: Slightly canonicalize OOM return/error status
Attempted to clean up the language around "this is a malloc'd object."  May be
passed as a parameter to free(3) is a bit obtuse.

Sponsored by:	Dell EMC Isilon
2020-05-05 17:57:04 +00:00
John Baldwin
483d953a86 Initial support for bhyve save and restore.
Save and restore (also known as suspend and resume) permits a snapshot
to be taken of a guest's state that can later be resumed.  In the
current implementation, bhyve(8) creates a UNIX domain socket that is
used by bhyvectl(8) to send a request to save a snapshot (and
optionally exit after the snapshot has been taken).  A snapshot
currently consists of two files: the first holds a copy of guest RAM,
and the second file holds other guest state such as vCPU register
values and device model state.

To resume a guest, bhyve(8) must be started with a matching pair of
command line arguments to instantiate the same set of device models as
well as a pointer to the saved snapshot.

While the current implementation is useful for several uses cases, it
has a few limitations.  The file format for saving the guest state is
tied to the ABI of internal bhyve structures and is not
self-describing (in that it does not communicate the set of device
models present in the system).  In addition, the state saved for some
device models closely matches the internal data structures which might
prove a challenge for compatibility of snapshot files across a range
of bhyve versions.  The file format also does not currently support
versioning of individual chunks of state.  As a result, the current
file format is not a fixed binary format and future revisions to save
and restore will break binary compatiblity of snapshot files.  The
goal is to move to a more flexible format that adds versioning,
etc. and at that point to commit to providing a reasonable level of
compatibility.  As a result, the current implementation is not enabled
by default.  It can be enabled via the WITH_BHYVE_SNAPSHOT=yes option
for userland builds, and the kernel option BHYVE_SHAPSHOT.

Submitted by:	Mihai Tiganus, Flavius Anton, Darius Mihai
Submitted by:	Elena Mihailescu, Mihai Carabas, Sergiu Weisz
Relnotes:	yes
Sponsored by:	University Politehnica of Bucharest
Sponsored by:	Matthew Grooms (student scholarships)
Sponsored by:	iXsystems
Differential Revision:	https://reviews.freebsd.org/D19495
2020-05-05 00:02:04 +00:00
John Baldwin
16aabb761c Remove support for IPsec algorithms deprecated in r348205 and r360202.
Examples of depecrated algorithms in manual pages and sample configs
are updated where relevant.  I removed the one example of combining
ESP and AH (vs using a cipher and auth in ESP) as RFC 8221 says this
combination is NOT RECOMMENDED.

Specifically, this removes support for the following ciphers:
- des-cbc
- 3des-cbc
- blowfish-cbc
- cast128-cbc
- des-deriv
- des-32iv
- camellia-cbc

This also removes support for the following authentication algorithms:
- hmac-md5
- keyed-md5
- keyed-sha1
- hmac-ripemd160

Reviewed by:	cem, gnn (older verisons)
Relnotes:	yes
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D24342
2020-05-02 00:06:58 +00:00
John Baldwin
371f3da616 Remove the SYMVER build option.
This option was added as a transition aide when symbol versioning was
first added.  It was enabled by default in 2007 and is supported even
by the old GPLv2 binutils.  Trying to disable it currently fails to
build in libc and at this point it isn't worth fixing the build.

Reported by:	Michael Dexter
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D24637
2020-04-30 22:08:40 +00:00
Ed Maste
be99f8868b liblua: ensure that "require" will fail in bootstrap flua
We do not want to support bootstrapping lua modules, so ensure that
require will fail by providing a nonexistent path.

Reviewed by:	kevans
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D24610
2020-04-29 13:41:32 +00:00
Mark Johnston
bea2668321 Document handling of connection-mode sockets by sendto(2).
sendto(2), sendmsg(2) and sendmmsg(2) return ENOTCONN if a destination
address is specified and the socket is not connected and the socket
protocol does not automatically connect ("implied connect").  Document
that.  Also document the fact that the destination address is ignored
for connection-mode sockets if the socket is already connected.

PR:		245817
Submitted by:	Erik Inge Bolsø <knan-bfo@modirum.com>
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D24530
2020-04-27 16:12:32 +00:00
Mark Johnston
569eb766c5 Fix handling of EV_EOF for named pipes.
Contrary to the kevent man page, EV_EOF on a fifo is not cleared by
EV_CLEAR.  Modify the read and write filters to clear EV_EOF when the
fifo's PIPE_EOF flag is clear, and update the man page to document the
new behaviour.

Modify the write filter to return the amount of buffer space available
even if no readers are present.  This matches the behaviour for sockets.

When reading from a pipe, only call pipeselwakeup() if some data was
actually read.  This prevents the continuous re-triggering of a
EVFILT_READ event on EOF when in edge-triggered mode.

PR:		203366, 224615
Submitted by:	Jan Kokemüller <jan.kokemueller@gmail.com>
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D24528
2020-04-27 15:59:19 +00:00
Conrad Meyer
1e72c52e23 libc: partially revert r326576
In r326576 ("use @@@ instead of @@ in __sym_default"), an earlier version of
the phabricator-discussed patch was inadvertently committed.  The commit
message claims that @@@ means that weak is not needed, but that was due to a
misunderstanding of the use of weak symbols in this context by the submitted
in the first draft of the patch; the description text was not updated to
match the discussion.  As discussed in phabricator, weak is needed for
symbol interposing because of the behavior of our rtld, and is widely used
elsewhere in libc.

This partial revert restores the approved version of the patch and permits
symbol interposing for openat.

Reported by:	Raymond Ramsden <rramsden AT isilon.com>
Reviewed by:	dim, emaste, kib (2017)
Discussed with:	kib (2020)
Differential Revision:	https://reviews.freebsd.org/D11653
2020-04-25 14:24:54 +00:00
Mateusz Piotrowski
5dcf0083fc Fix a typo
Reported by:	pstef
MFC after:	2 days
2020-04-24 22:04:14 +00:00
Alexander Motin
e4e0417440 Map family 0x5F (Denverton) to goldmont.
According to the 325462-071US document, they should be the same.

MFC after:	1 week
2020-04-24 16:05:35 +00:00
Eric van Gyzen
c5ad81420c Update jemalloc to version 5.2.1
Revert r354606 to restore r354605.

Apply one line from jemalloc commit d01b425e5d1e1 in hash_x86_128()
to fix the build with gcc, which only allows a fallthrough attribute
to appear before a case or default label.

Submitted by:	jasone in r354605
Discussed with:	jasone
Reviewed by:	bdrewery
MFC after:	never, due to gcc 4.2.1
Relnotes:	yes
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D24522
2020-04-23 23:57:43 +00:00
Kristof Provost
36dcd97de3 libc: Shortcut if_indextoname() if index == 0
If the index we're trying to convert is 0 we can avoid a potentially
expensive call to getifaddrs(). No interface has an ifindex of zero, so
we can handle this as an error: set the errno to ENXIO and return NULL.

Submitted by:	Nick Rogers
Reviewed by:	lutz at donnerhacke.de
MFC after:	2 weeks
Sponsored by:	RG Nets
Differential Revision:	https://reviews.freebsd.org/D24524
2020-04-23 21:16:51 +00:00
Kyle Evans
a269a14ff0 kqueue(2): de-vandalize the random sentence in the middle
A last minute change appears to have inadvertently vandalized unrelated
parts of the manpage with the date. =-(

Reported by:	rpokala
2020-04-22 04:05:02 +00:00
Kyle Evans
00b0f94c58 kqueue(2): add a note about EV_RECEIPT
In the below-referenced PR, a case is attached of a simple reproducer that
exhibits suboptimal behavior: EVFILT_READ and EVFILT_WRITE being set in the
same kevent(2) call will only honor the first one. This is, in-fact, how
it's supposed to work.

A read of the manpage leads me to believe we could be more clear about this;
right now there's a logical leap to make in the relevant statement: "When
passed as input, it forces EV_ERROR to always be returned." -- the logical
leap being that this indicates the caller should have allocated space for
the change to be returned with EV_ERROR indicated in the events, or
subsequent filters will get dropped on the floor.

Another possible workaround that accomplishes similar effect without needing
space for all events is just setting EV_RECEIPT on the final change being
passed in; if any errored before it, the kqueue would not be drained. If we
made it to the final change with EV_RECEIPT set, then we would return that
one with EV_ERROR and still not drain the kqueue. This would seem to not be
all that advisable.

PR:		229741
MFC after:	1 week
2020-04-22 03:45:52 +00:00
John Baldwin
24c2e17d2b Map negative types passed to vm_capability_type2name to NULL.
Submitted by:	vangyzen
2020-04-21 21:48:35 +00:00
John Baldwin
5e61abf740 Check the magic value in longjmp() before calling sigprocmask().
This avoids passing garbage to sigprocmask() if the jump buffer is
invalid.

Reviewed by:	mhorne
Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D24483
2020-04-21 17:40:23 +00:00
John Baldwin
d000623a21 Add description string for VM_CAP_BPT_EXIT.
While here, replace the array of mapping structures with an array of
string pointers where the index is the capability value.

Submitted by:	Rob Fairbanks <rob.fx907@gmail.com>
Reviewed by:	rgrimes
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D24289
2020-04-21 17:30:56 +00:00
Alan Somers
72a600a7a1 libauditd: make it a PRIVATELIB
According to the upstream man page (which we don't install), none of
libauditd's symbols are intended to be public. Also, I can't find any
evidence for a port that uses libauditd. Therefore, we should treat it like
other such libraries and use PRIVATELIB.

Reported by:	phk
Reviewed by:	cem, emaste
MFC after:	2 weeks
2020-04-19 02:20:39 +00:00
Alan Somers
1796400d62 libbsm: fix some MLINKS
Add missing MLINKS entries for a few functions. Remove some old typo
entries.

Reported by:	phk
Reviewed by:	cem
MFC after:	2 weeks
2020-04-19 02:18:40 +00:00
Alan Somers
133b8ab5bb cap_dns.3: fix some orphan .Xr links
Reported by:	phk
MFC after:	2 weeks
2020-04-18 20:13:43 +00:00
Brooks Davis
3076591b7a Attempt to use AT_PS_STRINGS to get the ps_strings pointer.
This saves a system call and avoids one of the (relatively rare) cases
of the kernel exporting pointers via sysctl.

As a temporary measure, keep the sysctl support to allow limited
compatability with old kernels.

Fail gracefully if ps_strings can't be found (should never happen).

Reviewed by:	kib
Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D24407
2020-04-15 20:28:20 +00:00
Brooks Davis
1e4a35add8 Support AT_PS_STRINGS in _elf_aux_info().
This will be used by setproctitle().

Reviewed by:	kib
Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D24407
2020-04-15 20:26:41 +00:00
Brooks Davis
6671366a55 Fix -Wvoid-pointer-to-enum-cast warnings.
This pattern is used in callbacks with void * data arguments and seems
both relatively uncommon and relatively harmless.  Silence the warning
by casting through uintptr_t.

This warning is on by default in Clang 11.

Reviewed by:	arichardson
Obtained from:	CheriBSD (partial)
MFC after:	1 week
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D24425
2020-04-15 18:15:58 +00:00
John Baldwin
e2b9919398 Remove support for geli(4) algorithms deprecated in r348206.
This removes support for reading and writing volumes using the
following algorithms:

- Triple DES
- Blowfish
- MD5 HMAC integrity

In addition, this commit adds an explicit whitelist of supported
algorithms to give a better error message when an invalid or
unsupported algorithm is used by an existing volume.

Reviewed by:	cem
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D24343
2020-04-15 00:14:50 +00:00
Kyle Evans
7851fb8ecb closefrom: clamp lowfd to >= 0; close_range's parameters are unsigned.
Pointy hat:	kevans
Reported by:	CI (lwhsu)
2020-04-14 23:24:24 +00:00
Kyle Evans
7d03e08112 Mark closefrom(2) COMPAT12, reimplement in libc to wrap close_range
Include a temporarily compatibility shim as well for kernels predating
close_range, since closefrom is used in some critical areas.

Reviewed by:	markj (previous version), kib
Differential Revision:	https://reviews.freebsd.org/D24399
2020-04-14 18:07:42 +00:00
Jonathan T. Looney
fb401f1bba Make sonewconn() overflow messages have per-socket rate-limits and values.
sonewconn() emits debug-level messages when a listen socket's queue
overflows. Currently, sonewconn() tracks overflows on a global basis. It
will only log one message every 60 seconds, regardless of how many sockets
experience overflows. And, when it next logs at the end of the 60 seconds,
it records a single message referencing a single PCB with the total number
of overflows across all sockets.

This commit changes to per-socket overflow tracking. The code will now
log one message every 60 seconds per socket. And, the code will provide
per-socket queue length and overflow counts. It also provides a way to
change the period between log messages using a sysctl.

Reviewed by:	jhb (previous version), bcr (manpages)
MFC after:	2 weeks
Sponsored by:	Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D24316
2020-04-14 15:38:18 +00:00
Kyle Evans
7c5e60c72e libc: remove shm_open(2)'s compat fallback
This had been introduced to ease any pain for using slightly older kernels
with a newer libc, e.g., for bisecting a kernel across the introduction of
shm_open2(2). 6 months has passed, retire the fallback and let shm_open()
unconditionally call shm_open2().

Stale includes are removed as well.
2020-04-13 15:59:15 +00:00
Xin LI
d25a143055 Sync with OpenBSD:
arc4random.c: In the incredibly unbelievable circumstance where
_rs_init() fails to allocate pages, don't call abort() because of
corefile data leakage concerns, but simply _exit().  The reasoning
is _rs_init() will only fail if someone finds a way to apply
specific pressure against this failure point, for the purpose of
leaking information into a core which they can read.  We don't
need a corefile in this instance to debug that.  So take this
"lever" away from whoever in the future wants to do that.

arc4random.3: reference random(4)

arc4random_uniform.c: include stdint.h over sys/types.h
2020-04-13 08:42:13 +00:00
Kyle Evans
472ced39ef Implement a close_range(2) syscall
close_range(min, max, flags) allows for a range of descriptors to be
closed. The Python folk have indicated that they would much prefer this
interface to closefrom(2), as the case may be that they/someone have special
fds dup'd to higher in the range and they can't necessarily closefrom(min)
because they don't want to hit the upper range, but relocating them to lower
isn't necessarily feasible.

sys_closefrom has been rewritten to use kern_close_range() using ~0U to
indicate closing to the end of the range. This was chosen rather than
requiring callers of kern_close_range() to hold FILEDESC_SLOCK across the
call to kern_close_range for simplicity.

The flags argument of close_range(2) is currently unused, so any flags set
is currently EINVAL. It was added to the interface in Linux so that future
flags could be added for, e.g., "halt on first error" and things of this
nature.

This patch is based on a syscall of the same design that is expected to be
merged into Linux.

Reviewed by:	kib, markj, vangyzen (all slightly earlier revisions)
Differential Revision:	https://reviews.freebsd.org/D21627
2020-04-12 21:23:19 +00:00
Alexander V. Chernikov
a666325282 Introduce nexthop objects and new routing KPI.
This is the foundational change for the routing subsytem rearchitecture.
 More details and goals are available in https://reviews.freebsd.org/D24141 .

This patch introduces concept of nexthop objects and new nexthop-based
 routing KPI.

Nexthops are objects, containing all necessary information for performing
 the packet output decision. Output interface, mtu, flags, gw address goes
 there. For most of the cases, these objects will serve the same role as
 the struct rtentry is currently serving.
Typically there will be low tens of such objects for the router even with
 multiple BGP full-views, as these objects will be shared between routing
 entries. This allows to store more information in the nexthop.

New KPI:

struct nhop_object *fib4_lookup(uint32_t fibnum, struct in_addr dst,
  uint32_t scopeid, uint32_t flags, uint32_t flowid);
struct nhop_object *fib6_lookup(uint32_t fibnum, const struct in6_addr *dst6,
  uint32_t scopeid, uint32_t flags, uint32_t flowid);

These 2 function are intended to replace all all flavours of
 <in_|in6_>rtalloc[1]<_ign><_fib>, mpath functions  and the previous
 fib[46]-generation functions.

Upon successful lookup, they return nexthop object which is guaranteed to
 exist within current NET_EPOCH. If longer lifetime is desired, one can
 specify NHR_REF as a flag and get a referenced version of the nexthop.
 Reference semantic closely resembles rtentry one, allowing sed-style conversion.

Additionally, another 2 functions are introduced to support uRPF functionality
 inside variety of our firewalls. Their primary goal is to hide the multipath
 implementation details inside the routing subsystem, greatly simplifying
 firewalls implementation:

int fib4_lookup_urpf(uint32_t fibnum, struct in_addr dst, uint32_t scopeid,
  uint32_t flags, const struct ifnet *src_if);
int fib6_lookup_urpf(uint32_t fibnum, const struct in6_addr *dst6, uint32_t scopeid,
  uint32_t flags, const struct ifnet *src_if);

All functions have a separate scopeid argument, paving way to eliminating IPv6 scope
 embedding and allowing to support IPv4 link-locals in the future.

Structure changes:
 * rtentry gets new 'rt_nhop' pointer, slightly growing the overall size.
 * rib_head gets new 'rnh_preadd' callback pointer, slightly growing overall sz.

Old KPI:
During the transition state old and new KPI will coexists. As there are another 4-5
 decent-sized conversion patches, it will probably take a couple of weeks.
To support both KPIs, fields not required by the new KPI (most of rtentry) has to be
 kept, resulting in the temporary size increase.
Once conversion is finished, rtentry will notably shrink.

More details:
* architectural overview: https://reviews.freebsd.org/D24141
* list of the next changes: https://reviews.freebsd.org/D24232

Reviewed by:	ae,glebius(initial version)
Differential Revision:	https://reviews.freebsd.org/D24232
2020-04-12 14:30:00 +00:00
Sergio Carlavilla Delgado
73129d4797 Add HISTORY section to getc(3)
PR:		240269
Submitted by:	Gordon Bergling
Differential Revision:	https://reviews.freebsd.org/D24295
2020-04-10 09:37:20 +00:00
Sergio Carlavilla Delgado
bbf6efd7b7 exit(3): Add HISTORY section
PR:		240259
Submitted by:	Gordon Bergling
Obtained from:	OpenBSD
Differential Revision:	https://reviews.freebsd.org/D24146
2020-04-10 09:27:18 +00:00
Sergio Carlavilla Delgado
3fea6e53c1 arc4random(3): Expand the SEE ALSO section
Submitted by:	Gordon Bergling
Approved by:	brueffer@
Obtained from:	NetBSD
Differential Revision:	https://reviews.freebsd.org/D23716
2020-04-10 09:12:41 +00:00
Konstantin Belousov
09bae0a023 libc: Fix possible overflow in binuptime().
This is an application of the kernel overflow fix from r357948 to
userspace, based on the algorithm developed by Bruce Evans. To keep
the ABI of the vds_timekeep stable, instead of adding the large_delta
member, MSB of both multipliers are added to quickly estimate the overflow.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
2020-04-09 23:22:35 +00:00
Simon J. Gerraty
723f904176 Improve interaction of vectx and tftp
On slow platforms, it helps to spread the hashing load
over time so that tftp does not timeout.

Also, some .4th files are too big to fit in cache of pkgfs,
so increase cache size and ensure fully populated.

Reviewed by:	stevek
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D24287
2020-04-07 16:56:34 +00:00
Conrad Meyer
b30c6ac9f9 libcasper(3): Export functions to C++
We must wrap C declarations in __BEGIN / __END_DECLS to avoid C++ name-mangling
of the declaration when including the C header; name-mangling causes the linker
to attempt to locate the wrong (C++ ABI) symbol name.

Reviewed by:	markj, oshogbo (earlier version both)
Differential Revision:	https://reviews.freebsd.org/D24323
2020-04-07 16:40:41 +00:00
Maxim Sobolev
a8b8edb25e Normalize deployment tools usage and definitions by putting into one place
instead of sprinkling them out over many disjoint files. This is a follow-up
to achieve the same goal in an incomplete rev.348521.

Approved by:	imp
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D20520
2020-04-07 02:46:22 +00:00
Conrad Meyer
2750f1b954 libcasper: Constify cap_sysctl_limit_mib() mib parameter
No functional change. Minor API change that is nicer for consumers. ABI is
identical; the routine never needed to modify the pointed to value.

Reviewed by:	emaste, markj
Differential Revision:	https://reviews.freebsd.org/D24319
2020-04-06 23:07:56 +00:00
Kyle Evans
147d7b567f llvm: add a build knob for enabling assertions
For head/, this will remain eternally default-on to maintain the status quo.
For stable/ branches, it should be flipped to default-off to maintain the
status quo.

There's value in being able to flip it one way or the other easily on head
or stable branches, whether you want to gain some performance back on head/
(for machines there's little chance you'll actually hit an assertion) or
potentially diagnose a problem with the version of llvm on an older branch.

Currently, stable branches get the CFLAGS+= -ndebug line uncommented; going
forward, they will instead have the default of LLVM_ASSERTIONS flipped.

Reviewed by:	dim, emaste, re (gjb)
MFC after:	1 week
MFC note:	flip the default of LLVM_ASSERTIONS
Differential Revision:	https://reviews.freebsd.org/D24264
2020-04-06 01:27:17 +00:00
Sergio Carlavilla Delgado
d2034aedc1 Fix typo 2020-04-04 07:43:47 +00:00
Matt Macy
92b14858b4 Update x86 counters
MFC after:	1 week
2020-04-03 22:36:22 +00:00
Ed Maste
6e46e45f97 ANSIfy and KNF function arg definitions in libmd/md4.c
Reported by:	bde, in 2017
2020-04-03 20:56:43 +00:00
Ed Maste
652a974885 lldb: build and enable lua script bindings
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D24266
2020-04-03 16:54:13 +00:00
Ed Maste
31c5c437cc lldb: commit generated LLDBWrapLua.cpp 2020-04-03 15:55:58 +00:00
Ed Maste
f0d060f91b lldb: add rule to generate LLDBWrapLua.cpp
Building lldb's lua/python bindings requires swig, but we do not want to
include it in the FreeBSD base system (as a build tool) because it has
non-trivial dependencies.  As a workaround, add a make rule to generate
LLDBWrapLua.cpp, and we will commit the generated file.

Requires the swig30 package.

Reviewed by:	brooks
Discussed with:	dim
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D24265
2020-04-03 15:52:44 +00:00
Warner Losh
5310132318 Note some functions that appeared in First Edition Unix
These functions first appeared in the First Edition of Unix (or earlier in the
pdp-7 version). Just claim 1st Edition for all this. The pdp-7 code is too
fragmented at this point to extend history that far back.
2020-04-01 22:50:41 +00:00
John Baldwin
59838c1a19 Retire procfs-based process debugging.
Modern debuggers and process tracers use ptrace() rather than procfs
for debugging.  ptrace() has a supserset of functionality available
via procfs and new debugging features are only added to ptrace().
While the two debugging services share some fields in struct proc,
they each use dedicated fields and separate code.  This results in
extra complexity to support a feature that hasn't been enabled in the
default install for several years.

PR:		244939 (exp-run)
Reviewed by:	kib, mjg (earlier version)
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D23837
2020-04-01 19:22:09 +00:00
Hartmut Brandt
0bf56da32d Merge release 1.14 of bsnmp. 2020-04-01 15:25:16 +00:00
Mateusz Piotrowski
89064ec6ef Use proper mdoc(7) macros for literal text and do not use Tn
Tn is deprecated and upsets linters.

MFC after:	3 days
2020-04-01 09:01:35 +00:00
Simon J. Gerraty
5ea556d98c Do not claim libbearssl et al are INTERNALLIB
If INTERNALLIB is defined we need PIE and bsd.incs.mk is
not included.

PR:		245189
Reviewed by:	emaste
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org//D24233
2020-04-01 05:45:12 +00:00
Hartmut Brandt
d5efa260d9 Import version 1.14 of bsnmp. This mainly consists of bug fixes
in the ASN.1 functions and comes with a test suite for these
functions.
2020-03-31 17:50:32 +00:00
John Baldwin
da8c654e99 Trim some duplicate EIO descriptions.
While here, drop an extra conjunction from the list of error
conditions for the remaining EIO description in symlink(2).

Discussed with:	mckusick (trimming duplicates)
MFC after:	2 weeks
2020-03-30 21:48:47 +00:00
John Baldwin
e42b096439 Document EINTEGRITY errors for many system calls.
EINTEGRITY was previously documented as a UFS-specific error for
mount(2).  This documents EINTEGRITY as a filesystem-independent error
that may be reported by the backing store of a filesystem.

While here, document EIO as a filesystem-independent error for both
mount(2) and posix_fadvise(2).  EIO was previously only documented for
UFS for mount(2).

Reviewed by:	mckusick
Suggested by:	mckusick
MFC after:	2 weeks
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D24168
2020-03-30 21:44:00 +00:00
Ed Maste
af6751f413 libc: unconditionalize _NLIST_DO_ELF
Suggested by:	brooks, imp
2020-03-30 21:25:00 +00:00
Ed Maste
86cfa7e70b nlist: retire long-obsolete aout support
Reviewed by:	brooks, kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D24229
2020-03-30 20:15:19 +00:00
Alfredo Dal'Ava Junior
f1343c7f67 msun: swap words order instead of bits order on BIG ENDIAN
The "for" loop on big endian was inverting all the bits instead of
just the words

Issue reported by TestSuite (msun lib nan_test case)

Submitted by:	Renato Riolino <renato.riolino@eldorado.org.br>
Submitted by:	Fernando Valle <fernando.valle@eldorado.org.br>
Reviewed by:	pfg, alfredo
Approved by:	jhibbits (mentor)
Sponsored by:	Eldorado Research Institute (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D23926
2020-03-26 18:50:54 +00:00
Dimitry Andric
aec4c088fd Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
llvmorg-10.0.0-0-gd32170dbd5b (aka 10.0.0 release).

PR:		244251
MFC after:	6 weeks
X-MFC-With:	358851
2020-03-26 17:46:32 +00:00
Brooks Davis
daa006f84b Install expected kyua docs.
The "kyua about" command assumes these files exist causing tests
supplied devel/kyua to fail.

Fix a bug defining the default KYUA_DOCDIR so the installed files can be
found.

Reported by:	jenkins tests
Reviewed by:	lwhsu
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D24187
2020-03-26 17:34:17 +00:00
Sergio Carlavilla Delgado
8e76d7909d Add HISTORY sections to log(3) man page
PR:		240265
Submitted by:	gbergling@gmail.com
Approved by:	bcr@(mentor), imp@
MFC after:	1 day
Differential Revision:	https://reviews.freebsd.org/D24148
2020-03-26 11:24:43 +00:00
Simon J. Gerraty
53f151f906 Fix pkgfs stat so it satisfies libsecureboot
We need a valid st_dev, st_ino and st_mtime
to correctly track which files have been verified
and to update our notion of time.

ve_utc_set(): ignore utc if it would jump our current time
by more than VE_UTC_MAX_JUMP (20 years).

Allow testing of install command via userboot.
Need to fix its stat implementation too.

bhyveload also needs stat fixed - due to change to userboot.h

Call ve_error_get() from vectx_close() when hash is wrong.

Track the names of files we have hashed into pcr

For the purposes of measured boot, it is important
to be able to reproduce the hash reflected in
loader.ve.pcr
so loader.ve.hashed provides a list of names in the order they
were added.

Reviewed by:	imp
MFC after:	1 week
Sponsored by:	Juniper Networks
Differential Revision:	https://reviews.freebsd.org//D24027
2020-03-25 19:12:19 +00:00
Emmanuel Vadot
483955de74 libpmc: Always add the full include path for libpmcstat
Previously it was only added for aarch64, amd64 and i386
2020-03-25 02:28:47 +00:00
Emmanuel Vadot
ee55186dfd pmc: Add include path for libpmcstat as it is an internallib
Reviewed by:	bapt
Differential Revision:	https://reviews.freebsd.org/D24173
2020-03-25 01:32:16 +00:00
Emmanuel Vadot
e055e3367e wlandebug: Add include path for libifconfig as it is a internallib
Reviewed by:	bapt
Differential Revision:	https://reviews.freebsd.org/D24172
2020-03-25 01:31:26 +00:00
Warner Losh
56c995d658 exec{l,v}{e,p} arrived in 7th Edition research Unix to support the Bourne Shell
which introduced environment variables. Document that here. Verified by
consulting the TUHS archive.
2020-03-24 19:33:21 +00:00
Emmanuel Vadot
9d7c39d873 pkgbase: Move telnetd and ftpd pam file to the utilities package
Both programs are in this package so put the pam.d file in there too.

Reported by:	emaste
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D24161
2020-03-24 01:08:06 +00:00
Brooks Davis
e2d6edeb99 Improve LIBADD/_DP_* for kyua libraries.
This fixes build with ld.bfd as the linker (e.g. on powerpc).

This corrects a bug in D24103.

Sponsored by:	DARPA
2020-03-23 21:21:38 +00:00
Brooks Davis
b0d29bc47d Import the kyua test framework.
Having kyua in the base system will simplify automated testing in CI and
eliminates bootstrapping issues on new platforms.

The build of kyua is controlled by WITH(OUT)_TESTS_SUPPORT.

Reviewed by:	emaste
Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D24103
2020-03-23 19:01:23 +00:00
Brooks Davis
c697fb7f7c Add liblutok a lightweight C++ API for lua.
It is added an INTERNALLIB and not installed.  It will be used by kyua.

This is a preparatory commit for D24103.

Reviewed by:	emaste
Obtained from:	CheriBSD
Sponsored by:	DARPA
2020-03-23 18:26:23 +00:00
Edward Tomasz Napierala
868983b032 Add STANDARDS and HISTORY to getcontext(3), makecontext(3), and ucontext(3).
Obtained from:	NetBSD
MFC after:	2 weeks
Sponsored by:	DARPA
2020-03-23 17:38:20 +00:00
Warner Losh
00c101b17d Document when execl and execp entered unix.
For this, things are complicated. The first mention in the manual was in the 4th
edition manual (as an add on to exec(II)).  The 2nd and 3rd editions didn't have
these in the manual (either as a separate page, or as an add-on to exec(II)). We
don't have good 1st, 2nd or 3rd edition distributions to look in. However,
there's a tape labeled 'last1120c' that we do have. This tape contains the last
version of the V2 edition of the C compiler on it (just after C got struct). On
this tape there was a libc.sa archive that contains source for execl and
execp. This source is sufficiently different from the V5 sources (which are the
next ones we have sources for) and have a slightly different calling convention
than later sources, suggesting that the early date for the last1120c tape is
correct (in that era, the epoch changed every year, leading to a one or two year
ambiguity on when the files could have been modified) and it should be though of
as V2. Since this was also a time of compiler development, and the calling
convetions are known to be under evolution, and since the rest of the sources in
libc.sa are consistent, that's further evidence that V2 is likely. Finally, 2nd
edition was the last version to fully support the 11/20 because it lacked many
basic features and bell labs moved off it to the 11/45 as soon as they could
afford to buy one, around this time era. The unix manuals make it sound like V3
might have supported the 11/20, but the same intro could also be read to mean it
didn't, at all, and that V3 was the first rewrite for the 11/45 ahead of the
rewrite in C that came with V4.

Taken together, the evidence leans most heavily to V2 (90% IMHO), and slightly
to V3 (8%) or possibly V4 (2%). I've not put all this in the man page, but have
left it here in case someone notices in the future that V4 is the first manual
page for it.
2020-03-23 16:02:01 +00:00
Sergio Carlavilla Delgado
fd2ea83940 fix typo in exec man page
PR:		240258
Submitted by:	gbergling@gmail.com
Reported by:	kib@
Approved by:	bcr@(mentor, implicit)
MFC after:	2 days
Differential Revision:	https://reviews.freebsd.org/D24145
2020-03-22 20:10:05 +00:00
Sergio Carlavilla Delgado
792f4f40b8 exec man page: Add HISTORY section
PR:		240258
Submitted by:	gbergling@gmail.com
Patch by:	gbergling@gmail.com
Approved by:	bcr@(mentor)
MFC after:	2 days
Differential Revision:	https://reviews.freebsd.org/D24145
2020-03-22 12:57:49 +00:00
Xin LI
a8675d927b MFV r359197: xz 5.2.5.
MFC after:	2 weeks
Relnotes:	yes
2020-03-22 01:27:38 +00:00
Ed Maste
42a62b0417 nlist(3): add elf(5) xref
Found while looking for a.out remnants; nlist should also xref the
binary format we currently use.
2020-03-21 15:51:05 +00:00
Mark Johnston
733983be9b Fix uselocale(3) to not leak a reference to the old locale.
In a single-threaded program pthread_getspecific() always returns NULL,
so the old locale would not end up being freed.

PR:		239520
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2020-03-20 20:02:53 +00:00
Warner Losh
3b7fd87cbf Remove sparc support from clang build infrastructure. Any remaining sparc files
will be mopped up in future imports.

Differential Revision: https://reviews.freebsd.org/D24128
2020-03-20 15:07:15 +00:00
Mateusz Piotrowski
9168ef5be3 Document geli(8) loader variables conventions
The geli(8) manual page has an example for preloading keyfiles during boot.
There is no detail though on how the lookup of these variables actually
works.

Let's document that the name of a device does not have to be a part
of the variable.

PR:		243261
Submitted by:	johannes@jo-t.de
Approved by:	bcr (mentor)
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D24114
2020-03-19 09:23:26 +00:00
Xin LI
4188ba1a3b Fix race condition in catopen(3).
The current code uses a rwlock to protect the cached list, which
in turn holds a list of catentry objects, and increments reference
count while holding only read lock.

Fix this by converting the reference counter to use atomic operations.

While I'm there, also perform some clean ups around memory operations.

PR:		202636
Reported by:	Henry Hu <henry.hu.sh@gmail.com>
Reviewed by:	markj
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D24095
2020-03-19 06:33:06 +00:00
Dimitry Andric
cd675bb60e Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
llvmorg-10.0.0-rc4-5-g52c365aa9ca.  The actual release should follow Real
Soon Now.

PR:             244251
MFC after:      6 weeks
2020-03-18 18:26:53 +00:00
John Baldwin
7a9cfa086a Fix the workaround to ignore the #warning for GCC.
clang and gcc use different warning flags for #warning preprocessor
directives.

Reported by:	Jenkins
MFC after:	1 week
2020-03-17 23:22:07 +00:00
John Baldwin
8d8a74e69e Mark procfs-based process debugging as deprecated for FreeBSD 13.
Attempting to use ioctls on /proc/<pid>/mem to control a process will
trigger warnings on the console.  The <sys/pioctl.h> include file will
also now emit a compile-time warning when used from userland.

Reviewed by:	emaste
MFC after:	1 week
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D23822
2020-03-17 18:44:03 +00:00
Brooks Davis
564b9ff2a7 Add an internal liblua and use it in flua.
The new liblua will be used in a forthcoming import of kyua.

Reviewed by:	kevans
Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D24090
2020-03-17 17:28:12 +00:00
Kyle Evans
19fe57fdb4 libssp: don't compile with -fstack-protector*
This similarly matches what we do in libc; compiling libssp with
-fstack-protector* is actively harmful.  For instance, if the canary ctor
ends up with a stack protector then it will trivially trigger a false
positive as the canary's being initialized.

This was noted by the reporter as irc/ircd-hybrid started crashing at start
after our libssp was MFC'd to stable/11, as its build will explicitly link
in libssp. On FreeBSD, this isn't necessary as SSP bits are included in
libc, but it should absolutely not trigger runtime breakage -- it does mean
that the canary will get initialized twice, but as this is happening early
on in application startup it should just be redundant work.

Reported by:	Tod McQuillin <devin@sevenlayer.studio>
MFC after:	3 days
2020-03-14 15:15:27 +00:00
Michael Tuexen
db4493f7b6 sendfile() does currently not support SCTP sockets.
Therefore, fail the call.

Reviewed by:		markj@
MFC after:		1 week
Differential Revision:	https://reviews.freebsd.org/D24059
2020-03-13 18:38:28 +00:00
Ryan Moeller
797711a84f libpmcstat: Try /boot/modules if module not found
Modules from ports/pkg are commonly installed to /boot/modules rather than to
the same directory the kernel resides in.  Look there if a module is not found
next to the kernel.

Submitted by:	mmacy
Reported by:	Nick Principe <nap@iXsystems.com>
Approved by:	mmacy (mentor)
MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2020-03-12 23:04:40 +00:00
Mateusz Piotrowski
18a9889f69 ftw.3: Follow style(9) in the example
Reported by:	oshogbo
Approved by:	bcr (mentor)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D24043
2020-03-12 18:28:23 +00:00
Brandon Bergren
db7f521db7 Fix r358688 -- Remember to actually save r3 before processing.
Crash was noticed by pkubaj building gcc9.

Apparently non dword-aligned char pointers are somewhat rare in the wild.

Reported by:	pkubaj
Sponsored by:	Tag1 Consulting, Inc.
2020-03-11 23:34:44 +00:00
Kirk McKusick
95ca762da8 When mounting a UFS filesystem, return EINTEGRITY rather than EIO
when a superblock check-hash error is detected. This change clarifies
a mount that failed due to media hardware failures (EIO) from a mount
that failed due to media errors (EINTEGRITY) that can be corrected by
running fsck(8).

Sponsored by: Netflix
2020-03-11 21:00:40 +00:00
Li-Wen Hsu
0fc06121ac Temporarily skip 2 failing tests after llvm10 import
PR:		244732
Sponsored by:	The FreeBSD Foundation
2020-03-11 12:43:54 +00:00
Warner Losh
9ac30e0b66 Remove unused cam ccb flags
These flags have been unused for some time. Some of them were in the
CAM2 specification, but CAM has moved on a bit from that. Some were
used in the old Pluto VideoSpace (and AirSpace) systems which had the
video playback I/O scheduler in userspace, but have been unused since
then.

Reviewed by: chuck, ken
Differential Revision:  https://reviews.freebsd.org/D24008
2020-03-10 23:58:41 +00:00
Dimitry Andric
4d4aa25694 Move another file in libllvm from sources required for world, to sources
required for bootstrap, as the PowerPC builds need this.

Reported by:	bdragon
PR:		244251
MFC after:	6 weeks
X-MFC-With:	358851
2020-03-10 20:25:36 +00:00
Dimitry Andric
0f1174c5e1 Add one additional file to libllvmminimal, to help the ppc64 bootstrap.
Reported by:	bdragon
PR:		244251
MFC after:	6 weeks
X-MFC-With:	358851
2020-03-10 20:01:52 +00:00
Dimitry Andric
fc23be915c Merge ^/head r358832 through r358848. 2020-03-10 17:49:09 +00:00
Hans Petter Selasky
f6428705d8 Fix for building libusb under Linux.
MFC after:	3 days
Sponsored by:	Mellanox Technologies
2020-03-10 15:59:20 +00:00
Dimitry Andric
16b9056593 Merge ^/head r358731 through r358831. 2020-03-10 07:04:05 +00:00
Dimitry Andric
da759cfa32 Remove -mlong-calls vhen building arm libraries and llvm.
Clang from 9.0.0 onwards already has the necessary relocation range
extenders, so this workaround is no longer needed (it produces longer
and slower code). Tested on real hardware, and in cross-compile
environment.

Submitted by:	mmel
2020-03-10 06:49:43 +00:00
Simon J. Gerraty
afc571b1a6 veloader use vectx API for kernel and modules
The vectx API, computes the hash for verifying a file as it is read.
This avoids the overhead of reading files twice - once to verify, then
again to load.

For doing an install via loader, avoiding the need to rewind
large files is critical.

This API is only used for modules, kernel and mdimage as these are the
biggest files read by the loader.
The reduction in boot time depends on how expensive the I/O is
on any given platform.  On a fast VM we see 6% improvement.

For install via loader the first file to be verified is likely to be the
kernel, so some of the prep work (finding manifest etc) done by
verify_file() needs to be factored so it can be reused for
vectx_open().

For missing or unrecognized fingerprint entries, we fail
in vectx_open() unless verifying is disabled.

Otherwise fingerprint check happens in vectx_close() and
since this API is only used for files which must be verified
(VE_MUST) we panic if we get an incorrect hash.

Reviewed by:	imp,tsoome
MFC after:	1 week
Sponsored by:	Juniper Networks
Differential Revision:	https://reviews.freebsd.org//D23827
2020-03-08 17:42:42 +00:00
Mateusz Guzik
d2222aa0e9 fd: use smr for managing struct pwd
This has a side effect of eliminating filedesc slock/sunlock during path
lookup, which in turn removes contention vs concurrent modifications to the fd
table.

Reviewed by:	markj, kib
Differential Revision:	https://reviews.freebsd.org/D23889
2020-03-08 00:23:36 +00:00
Dimitry Andric
f7ed37c525 Merge ^/head r358678 through r358711. 2020-03-06 17:11:29 +00:00
Justin Hibbits
dcfc676147 powerpc/memcpy: Don't predict the src and dst will be misaligned
Predicting misalignment will pessimize the expected common case.  Don't
predict true or false in thise case.
2020-03-06 03:46:48 +00:00
Justin Hibbits
021abafa5c Finish revert of r358672, missed in r358688.
Manual reverts never succeed correctly.

Reported by:	luporl
2020-03-06 02:30:04 +00:00
Justin Hibbits
00797360b5 powerpc/powerpc64: Enforce natural alignment in memcpy
Summary:
POWER architecture CPUs (Book-S) require natural alignment for
cache-inhibited storage accesses.  Since we can't know the caching model
for a page ahead of time, always enforce natural alignment in memcpy.
This fixes a SIGBUS in X with acceleration enabled on POWER9.

As part of this, revert r358672, it's no longer necessary with this fix.

Regression tested by alfredo.

Reviewed by: alfredo
Differential Revision: https://reviews.freebsd.org/D23969
2020-03-06 01:45:03 +00:00
Dimitry Andric
8c27c5541e Merge ^/vendor/llvm-project/release-10.x up to its last change (upstream
commit llvmorg-10.0.0-rc3-1-gc290cb61fdc), and bump versions.
2020-03-05 18:11:47 +00:00
Dimitry Andric
e43d33d286 Merge ^/head r358466 through r358677. 2020-03-05 17:55:36 +00:00
Ed Maste
0a052459e6 umtx_op.2: correct typo
PR:		244611
Submitted by:	John F. Carr <jfc@mit.edu>
MFC after:	3 days
2020-03-05 15:51:44 +00:00
Mateusz Piotrowski
d4d63c8986 ftw.3: Add examples
PR:		173448 [1]
Submitted by:	fernape@ (previous version) [1]
Reviewed by:	jilles
Approved by:	bcr (mentor)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D21750
2020-03-05 14:52:24 +00:00
Alfredo Dal'Ava Junior
2b37373c48 [PowerPC64] restrict memcpy/bcopy optimization to POWER ISA >=V2.07
VSX instructions were added in POWER ISA V2.06 (POWER7), but it
requires data to be word-aligned. Such requirement was removed in
ISA V2.07B (POWER8).

Since current memcpy/bcopy optimization relies on VSX instructions
handling misalignment transparently, and kernel doesn't currently
implement an alignment error handler, this optimzation should be
restrict to ISA V2.07 onwards.

SIGBUS on stxvd2x instruction was reproduced in POWER7+ CPU.

Reviewed by:	luporl, jhibbits, bdragon
Approved by:	jhibbits (mentor)
Differential Revision:	https://reviews.freebsd.org/D23958
2020-03-05 14:13:22 +00:00
Mateusz Piotrowski
a81c96922d thr_self.2: Fix some typos in the thread identifier range
Reported by:	kaktus
Approved by:	bcr (mentor)
Differential Revision:	https://reviews.freebsd.org/D23936
2020-03-03 09:51:53 +00:00
Martin Matuska
f55be4fc57 MFV r358511,r358532:
Sync libarchive with vendor.

Relevant vendor changes:
  Issue #1257: Add testcase for ZIPX files with LZMA_STREAM_END marker
  PR #1331: cpio.5: fix hard link description
  Issue #1335: archive_read.c: fix UBSan warning about undefined behavior
  Issue #1338: XAR reader: fix UBSan warning about undefined behavior
  Issue #1339: bsdcpio_test: fix datatype in from_hex()
  Issue #1341: Safe writes: delete temporary file if rename fails.
  Issue #1341: Safe writes: improve error handling

MFC after:	1 week
2020-03-02 08:44:58 +00:00
Mateusz Guzik
8d03b99b9d fd: move vnodes out of filedesc into a dedicated structure
The new structure is copy-on-write. With the assumption that path lookups are
significantly more frequent than chdirs and chrooting this is a win.

This provides stable root and jail root vnodes without the need to reference
them on lookup, which in turn means less work on globally shared structures.
Note this also happens to fix a bug where jail vnode was never referenced,
meaning subsequent access on lookup could run into use-after-free.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D23884
2020-03-01 21:53:46 +00:00
Dimitry Andric
91019ea7d4 Merge ^/head r358400 through r358465. 2020-02-29 15:08:14 +00:00
Ed Maste
c45018041d retire the LLVM_LIBUNWIND option
LLVM's libunwind is used on all FreeBSD-supported CPU architectures and
is a required component.

Reviewed by:	brooks (earlier)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D23123
2020-02-29 12:43:43 +00:00
Dimitry Andric
75dfc66c1b Merge ^/head r358269 through r358399. 2020-02-27 19:07:10 +00:00
Dimitry Andric
4739579419 Merge ^/vendor/llvm-project/release-10.x up to its last change (upstream
commit llvmorg-10.0.0-rc2-70-ge5cb70267e7), and bump versions.
2020-02-27 19:04:39 +00:00
Warner Losh
f33b14f02e Remove libthr, csu, libthread_db and testfloat sparc64 specific directories.
Submitted by:	kib@ (libthr)
2020-02-27 04:44:58 +00:00
Ed Maste
acb8858f05 Return ENOTSUP for mmap/mprotect if prot not subset of prot_max
From POSIX,

[ENOTSUP]
    The implementation does not support the combination of accesses
    requested in the prot argument.

This fits the case that prot contains permissions which are not a subset
of prot_max.

Reviewed by:	brooks, cem
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D23843
2020-02-26 20:03:43 +00:00
Warner Losh
a5b6c2960d Remove sparc64 specific parts of libc.
Also update comments for which architectures use 128 bit long doubles,
as appropriate.

The softfloat specialization routines weren't updated since they
appear to be from an upstream source which we may want to update in
the future to get a more favorable license.

Reviewed by: emaste@
Differential Revision:  https://reviews.freebsd.org/D23658
2020-02-26 18:55:09 +00:00
Warner Losh
a8197ad3aa Remove sparc64 specific parts of libm and fix comments
Once upon a time, sparc64 was the only ld128 architecture. However,
both aarch64 and riscv are now such architectures. Many of the
comments about how slow multiplication was on old sparc64 processors
are now no longer true. However, since no evaluation has been done for
aarch64 yet, it's unclear if they are still relevant or not. If not,
the code should be changed. If so, the comments should remove the
uncertainty.

Reviewed by: emaste@
Differential Revision: https://reviews.freebsd.org/D23658
2020-02-26 18:55:03 +00:00
Ed Maste
5c6d07fb9c mprotect.2: sort errors alphabetically
Reported by:	brooks
MFC after:	3 days
2020-02-26 18:46:41 +00:00
Dimitry Andric
c0ac260c74 Instead of using just the long upstream commit hash for LLVM component
versions, use "git describe --tags --long" output, which is more
descriptive.  E.g., "90c78073f73eac58f4f8b4772a896dc8aac023bc" becomes
"llvmorg-10.0.0-rc2-0-g90c78073f73".
2020-02-24 19:18:50 +00:00
Dimitry Andric
24a22d1d9c Merge r358179 through r358238.
PR:		244251
2020-02-22 09:58:11 +00:00
Kyle Evans
5ac6a2c94d fetch(3): plug some leaks
In the successful case, sockshost is not freed prior to return.

The failure case can now be hit after fetch_reopen(), which was not true
before. Thus, we need to make sure to clean up all of the conn resources
which will also close sd. For all of the points prior to fetch_reopen(), we
continue to just close sd.

CID:		1419598, 1419616
2020-02-21 18:21:57 +00:00
Eric van Gyzen
3ae8839afe truncate(2): extending the file is required by POSIX 2008
Update the man page to mention that extending a file with truncate(2)
is required by POSIX as of 2008.

Reviewed by:	bcr
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D23354
2020-02-20 23:47:09 +00:00
Dimitry Andric
6c140a7281 Merge ^/head r358131 through r358178. 2020-02-20 19:07:29 +00:00
Mateusz Guzik
0573d0a9b8 vfs: add realpathat syscall
realpath(3) is used a lot e.g., by clang and is a major source of getcwd
and fstatat calls. This can be done more efficiently in the kernel.

This works by performing a regular lookup while saving the name and found
parent directory. If the terminal vnode is a directory we can resolve it using
usual means. Otherwise we can use the name saved by lookup and resolve the
parent.

See the review for sample syscall counts.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D23574
2020-02-20 16:58:19 +00:00
Baptiste Daroussin
e0989ec919 ncurses: bump shlib number to version 9
ABI has change in between ncurses 5 or 6. While theorically ncurses 6 is buildable with
backward compatibility, I fail at building in a way where the application linked against
the previous version of ncurses are rendering properly.
Let's go on the new ABI which provides all the latest features.

A compat12x package is cooking for backward compatibility
2020-02-20 09:12:07 +00:00
Dimitry Andric
43c7dd6b59 Merge ^/head r358075 through r358130. 2020-02-19 21:03:06 +00:00
Jeff Roberson
c6fd3e23f7 Use per-domain locks for the bucket cache.
This gives much better concurrency when there are a large number of
cores per-domain and multiple domains.  Avoid taking the lock entirely
if it will not be productive.  ROUNDROBIN domains will have mixed
memory in each domain and will load balance to all domains.

While here refactor the zone/domain separation and bucket limits to
simplify callers.

Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D23673
2020-02-19 18:48:46 +00:00
Baptiste Daroussin
e18651243e Update to 6.2-20200215
While I didn't plan another upgrade, This version incorporate fixes from
kevans@ so let's upgrade to it
2020-02-19 17:09:08 +00:00
Kyle Evans
c70019dd0a libsysdecode: grab shmflags from sys/mman.h, add decode method
Any SHM_* flag here is (and likely will continue to be) a shmflag that may
be passed to shm_open2(), with exception to SHM_ANON. This is a prereq to
adding appropriate support to truss/kdump.

Reviewed by:	kaktus (slightly earlier version)
Differential Revision:	https://reviews.freebsd.org/D23733
2020-02-19 14:52:32 +00:00
Baptiste Daroussin
9b61ffab6b lib_gen.c now also depends on ncurses_dll.h specify it to prevent some breakage
if ncurses_dll.h is already present in base while building
2020-02-19 14:09:15 +00:00
Sergio Carlavilla Delgado
8209febbb3 Add some HISTORY sections to manpages
environ(7) was in AT&T Version 7
ac(8): Add a HISTORY section
sa(8): Add a HISTORY section
sqrt(3): Add the actual sqrt function to the HISTORY section

Obtained from: OpenBSD

Submitted by:	gbergling@gmail.com
Approved by:	bcr@(mentor)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D23693
2020-02-19 12:49:49 +00:00
Dimitry Andric
abaad9d77d Merge ^/head r358049 through r358074. 2020-02-18 17:59:37 +00:00
Cy Schubert
e8c4b9d46b This commit makes significant changes to pam_login_access(8) to bring it
up to par with the Linux pam_access(8).

Like the Linux pam_access(8) our pam_login_access(8) is a service module
for pam(3) that allows a administrator to limit access from specified
remote hosts or terminals. Unlike the Linux pam_access, pam_login_access
is missing some features which are added by this commit:

Access file can now be specified. The default remains /etc/access.conf.
The syntax is consistent with Linux pam_access.

By default usernames are matched. If the username fails to match a match
against a group name is attempted. The new nodefgroup module option will
only match a username and no attempt to match a group name is made.
Group names must be specified in brackets, "()" when nodefgroup is
specified. Otherwise the old backward compatible behavior is used.
This is consistent with Linux pam_access.

A new field separator module option allows the replacement of the default
colon (:) with any other character. This facilitates potential future
specification of X displays. This is also consistent with Linux pam_access.

A new list separator module option to replace the default space/comma/tab
with another character. This too is consistent with Linux pam_access.

Linux pam_access options not implemented in this commit are the debug
and audit options. These will be implemented at a later date.

Reviewed by:	bjk, bcr (for manpages)
Approved by:	des (blanket, implicit)
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D23198
2020-02-18 11:27:08 +00:00
Cy Schubert
6f1ed8ae58 strchr() returns a pointer not an int.
Reported by:	bjk
Approved by:	des (blanket, implicit)
MFC after:	3 days
2020-02-18 11:27:05 +00:00
Cy Schubert
9c9372ad3f Add missing SYNOPSIS section.
Reported by:	ports/textproc/igor
MFC after:	3 days
2020-02-18 11:27:02 +00:00
Cy Schubert
88fcc10c94 There is no pam(8) man page, it is pam(3).
Approved by:	des (implicit, blanket)
MFC after:	3 days
2020-02-18 11:26:59 +00:00
Cy Schubert
0d960f7379 When pam_login_access(5) fails to match a username it attempts to
match the primary group a user belongs to. This commit extends the
match to secondary groups a user belongs to as well, just as the Linux
pam_access(5) does.

Approved by:	des (implicit, blanket)
2020-02-18 11:26:56 +00:00
Cy Schubert
f47effabd5 The words ALL, LOCAL, and EXCEPT have special meaning and are documented
as in the login.access(5) man page. However strcasecmp() is used to compare
for these special strings. Because of this User accounts and groups with
the corresponding lowercase names are misintrepreted to have special
whereas they should not.

This commit fixes this, conforming to the man page and to how the Linux
pam_access(8) handles these special words.

Approved by:	des (implicit, blanket)
2020-02-18 11:26:52 +00:00
Baptiste Daroussin
aae38d10b4 Update ncurses to 20200118
Among the changes from before:
- Add support for extended colors on widechar version
- Enable ncurses extended functions
- Enable version 2 of the extended mouse support
- Enable SCREEN extensions

Modification that differs from upstream:
- _nc_delink_entries used to be exposed and was turn static,
  turn it back as dynamic to not break abi
- Adapt our old termcap.c to modern ncurses

MFC after:	3 weeks
2020-02-18 08:11:52 +00:00