Commit graph

21524 commits

Author SHA1 Message Date
Konstantin Belousov
d4a478c270 procctl(2): Add PROC_WXMAP_CTL/STATUS
(cherry picked from commit 796a8e1ad1)
2021-09-24 03:26:59 +03:00
Edward Tomasz Napierala
e79a18dadf procctl(2): add PROC_NO_NEW_PRIVS_CTL, PROC_NO_NEW_PRIVS_STATUS
(cherry picked from commit db8d680ebe)
2021-09-24 03:26:59 +03:00
Daniel Kolesa
037c2f4fe3 libfetch: use more portable getline() interface
this is for better portability in order to avoid using a function
which is BSD-only or available via libbsd

(cherry picked from commit ee3ca711a8)
(cherry picked from commit 635eb7ac79)
2021-09-22 11:57:35 +02:00
Dimitry Andric
b2cfac207d compiler-rt: add aarch64 init function for LSE atomics
As reported by Ronald, adding the out-of-line LSE atomics helpers for
aarch64 to compiler-rt was not sufficient to link programs using these,
as they also require a __aarch64_have_lse_atomics global. This is
initialized in compiler-rt's lib/builtins/cpu_model.c, roughly similar
to the x86 CPU model and feature detection in that file.

Since upstream does not yet have a FreeBSD specific implementation for
getting the required information, add a simple one that should work for
now, while I try to get it sorted with the LLVM people.

Reported by:	Ronald Klop <ronald-lists@klop.ws>
Fixes:		cc55ee8009
PR:		257392

(cherry picked from commit efe67f33c3)
2021-09-21 20:17:05 +02:00
Ed Maste
f8c4000ca6 libprocstat: extend zfs_defs hack for .pieo
By default _pie.a archives are built only for INTERNALLIBs, so there is
usually no need for zfs_defs.pieo to exist.  However, some experimental
work builds _pie.a archives for everything.  Extend the existing set of
zfs_defs hacks to build zfs_defs.pieo as well.

Reviewed by:	arichardson
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D31924

(cherry picked from commit b9df18d6e8)
2021-09-19 21:28:26 -04:00
Alexander Motin
c8f2af5f5d geli(8): Do not report error on resize to the same size.
Just validate the old metadata and exit.  Originally the check was
added to not thash the only copy of metadata, but we can achieve the
same just by skipping the writing/trashing.  The metadata validation
should protect user from wrongly specifying new size instead of old.

MFC after:	1 month
Sponsored by:	iXsystems, Inc.

(cherry picked from commit c7cf100aaf)
2021-09-16 21:39:07 -04:00
Mark Johnston
ad9f3a91d5 libc: Use the initial-exec TLS model
This permits more efficient accesses of thread-local variables, which
are heavily used at least by jemalloc and locale-aware code.  Note that
on amd64 and i386, jemalloc's thread-local variables already have their
TLS model overridden by defining JEMALLOC_TLS_MODEL.

For now the change is applied only to tested platforms, but should in
principle be enabled everywhere.

PR:		255840
Suggested by:	jrtc27
Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 9c97062b62)
2021-09-14 08:50:53 -04:00
Mark Johnston
603c9bb029 kqueue.2: Document the fact that EVFILT_READ can be used on kqueues
Reviewed by:	bcr, kib
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit f756c91168)
2021-09-14 08:50:31 -04:00
Warner Losh
5918f48652 clock_gettime: Add Linux aliases for CLOCK_*
Linux standardized what we call CLOCK_{REALTIME,MONOTONIC}_FAST as
CLOCK_{REALTIME,MONOTONIC}_COARSE. In addition, Linux spells
CLOCK_UPTIME as CLOCK_BOOTTIME.

Add aliases to time.h and document these new aliases in
clock_gettime(2).

Reviewed by:		vangyzen, kib (prior), dchagin (prior)
Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D30988

(cherry picked from commit 155f15118a)
2021-09-12 09:56:16 -06:00
Martin Matuska
aef1ff87fe libarchive: import changes from upstream
Libarchive 3.5.2

New features:
  PR #1502: Support for PWB and v7 binary cpio formats
  PR #1509: Support of deflate algorithm in symbolic link decompression
            for ZIP archives

Important bugfixes:
  IS #1044: fix extraction of hardlinks to symlinks
  PR #1480: Fix truncation of size values during 7zip archive
            extraction on 32bit architectures
  PR #1504: fix rar header skiming
  PR #1514: ZIP excessive disk read - fix location of central directory
  PR #1520: fix double-free in CAB reader
  PR #1521: Fixed leak of rar before ending with error
  PR #1530: Handle short writes from archive_write_callback
  PR #1532: 7zip: Use compression settings from file also for file header
  IS #1566: do not follow symlinks when processing the fixup list

Relnotes:	yes

(cherry picked from commit ddce862ad8)
2021-09-10 10:24:13 +02:00
Jessica Clarke
b20eb96fe8 clang: Build with -fno-strict-aliasing when using GCC
Somewhat ironically, there are strict aliasing violations in Clang,
which can result in the following assertion failure:

  Assertion `*(NamedDecl **)&Data == ND && "PointerUnion mangles the NamedDecl pointer!"' failed.

Upstream's clang/CMakeLists.txt specifically (not LLVM as a whole)
passes -fno-strict-aliasing if the compiler is not Clang, and this fixes
the above issue.

This was seen when cross-building from Linux using a bootstrap
compiler, but likely also affects worlds built with a new enough
external GCC toolchain.

MFC after:	1 week
Reviewed by:	dim
Differential Revision:	https://reviews.freebsd.org/D31533

(cherry picked from commit c1f7d8dd23)
2021-09-07 13:08:19 +01:00
Jessica Clarke
5ef9ae5c6d clang: Fix inverted condition in llvm.build.mk
Fixes:		31ba4ce889 ("Allow bootstrapping llvm-tblgen on macOS and Linux")
MFC after:	1 week

(cherry picked from commit 5ff5d1177b)
2021-09-07 13:08:17 +01:00
Jessica Clarke
c69a739379 riscv: Implement non-stub __vdso_gettc and __vdso_gettimekeep
PR:	256905
Reviewed by:	arichardson, mhorne
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D30963

(cherry picked from commit 348c41d181)
2021-09-07 13:06:44 +01:00
Kristof Provost
d1d99d7575 libpfctl: Implement DIOCGETSTATUS wrappers
MFC after:	1 week
Sponsored by:	Modirum MDPay
Differential Revision:	https://reviews.freebsd.org/D31696

(cherry picked from commit 46fb68b1de)
2021-09-06 10:06:33 +02:00
Kristof Provost
6f85e21674 libpfctl: fix double free
Reviewed by:	donner
MFC after:	1 week
Sponsored by:	Modirum MDPay
Differential Revision:	https://reviews.freebsd.org/D31695

(cherry picked from commit b0ccc2e277)
2021-09-06 10:06:29 +02:00
Toomas Soome
343da8f5e9 libsecureboot: define SOPEN_MAX
With commit 97cbd5e722, the SOPEN_MAX
was removed from stand.h.

We would need better mechanism there.

(cherry picked from commit ee6dc333e1)

PR:	258211
2021-09-03 23:45:16 +03:00
Dimitry Andric
ef314cd4ba Fix null pointer subtraction in mergesort()
Clang 13 produces the following warning for this function:

lib/libc/stdlib/merge.c:137:41: error: performing pointer subtraction with a null pointer has undefined behavior [-Werror,-Wnull-pointer-subtraction]
        if (!(size % ISIZE) && !(((char *)base - (char *)0) % ISIZE))
                                               ^ ~~~~~~~~~

This is meant to check whether the size and base parameters are aligned
to the size of an int, so use our __is_aligned() macro instead.

Also remove the comment that indicated this "stupid subtraction" was
done to pacify some ancient and unknown Cray compiler, and which has
been there since the BSD 4.4 Lite Lib Sources were imported.

(cherry picked from commit 4e5d32a445)
2021-08-31 21:05:43 +02:00
Mitchell Horne
3d51152bfe pmc(3): remove Pentium-related man pages and references
Support for Pentium events was removed completely in e92a1350b5.

Don't bump .Dd where we are just removing xrefs.

Reviewed by:	emaste
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D31423

(cherry picked from commit d78896e46f)
2021-08-30 12:54:47 -03:00
Dimitry Andric
ab18f56db4 Cleanup compiler warning flags in lib/libefivar/Makefile
There is no need to set -Wno-unused-parameter twice, and instead of
appending to CFLAGS, append to CWARNFLAGS instead. While here, add
-Wno-unused-but-set-variable for the sake of clang 13.0.0.

(cherry picked from commit f643997a17)
2021-08-29 12:29:26 +02:00
Dimitry Andric
38a2bbfa12 googletest: Silence warnings about deprecated implicit copy constructors
Our copy of googletest is rather stale, and causes a number of -Werror
warnings about implicit copy constructor definitions being deprecated,
because several classes have user-declared copy assignment operators.
Silence the warnings until we either upgrade or remove googletest.

(cherry picked from commit d396c67f26)
2021-08-29 12:29:21 +02:00
Kyle Evans
d511b903b9 kenv: allow listing of static kernel environments
The early environment is typically cleared, so these new options
need the PRESERVE_EARLY_KENV kernel config(8) option. These environments
are reported as missing by kenv(1) if the option is not present in the
running kernel.

(cherry picked from commit db0f264393)
2021-08-26 01:35:33 -05:00
Gordon Bergling
a2d0f28a8e rpc(3): Correct a few common typos in source code comments
- s/therfore/therefor/
- s/activte/active/

Obtained from:	NetBSD

(cherry picked from commit 0d55bc8eb2)
2021-08-25 08:25:12 +02:00
Gordon Tetlow
a75324d674 Fix libfetch out of bounds read.
Approved by:	so
Security:	SA-21:15.libfetch
Security:	CVE-2021-36159

(cherry picked from commit 3be62d49ae2b6f9050f39fe74210c88f35901fa5)
2021-08-24 10:59:43 -07:00
Kristof Provost
b98f2ec0d6 libpfctl: Fix endianness issues
Several fields are supplied in big-endian format, so we need to convert
them before we display them.

MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 719b5397c2)
2021-08-23 16:19:39 +02:00
Konstantin Belousov
6295883670 libc tls: use TLS_DTV_OFFSET defined by rtld.h
(cherry picked from commit 300e08933e)
2021-08-23 12:20:56 +03:00
Fangrui Song
2aa761055c rtld: Remove calculate_tls_end
(cherry picked from commit 8f63fa78e8)
2021-08-23 12:20:56 +03:00
Mark Johnston
acabc20906 kevent: Prohibit negative change and event list lengths
Previously, a negative change list length would be treated the same as
an empty change list.  A negative event list length would result in
bogus copyouts.  Make kevent(2) return EINVAL for both cases so that
application bugs are more easily found, and to be more robust against
future changes to kevent internals.

Reviewed by:	imp, kib
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit e00bae5c18)
2021-08-21 12:08:58 -04:00
Gordon Bergling
f296898fb7 Fix a common typo in source code comments
- s/aligment/alignment/

(cherry picked from commit a1581cd735)
2021-08-19 09:18:35 +02:00
Alexander Motin
09d4fe40e0 Fix race between first rand(3) calls with _once().
Before this patch there was a chance for thread that called rand(3)
slightly later to see rand3_state already allocated, but not yet
initialized.  While this API is not expected to be thread-safe, it
is not expected to crash.  ztest on 64-thread system reproduced it
reliably for me.

Submitted by:	avg@
MFC after:	1 month

(cherry picked from commit 3a57f08b50)
2021-08-18 21:11:51 -04:00
Mateusz Piotrowski
5cdee2441e getprogname.3: Add an example
It shows the difference between getprogname() and argv[0].

Reviewed by:	yuripv
Approved by:	yuripv (src)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D27204

(cherry picked from commit 1ffdcdadf6)
2021-08-15 23:19:09 +02:00
Dimitry Andric
ed698ef1e1 Apply upstream lld fix for compressed input sections on BE targets
Merge commit c6ebc651b6fa from llvm git (by Simon Atanasyan):

  [LLD] Support compressed input sections on big-endian targets

  This patch enables compressed input sections on big-endian targets by
  checking the target endianness and selecting an appropriate `Chdr`
  structure.

  Fixes PR51369

  Differential Revision: https://reviews.llvm.org/D107635

Reported by:	emaste

(cherry picked from commit d69d07569e)

Follow-up to d69d07569e by bumping lld local version

This makes it easier to detect that lld's support for compressed input
sections on BE targets is fixed.

(cherry picked from commit cd38d9cf26)
2021-08-14 14:52:55 +02:00
Konstantin Belousov
c24e3f5d44 ipsec_set_policy(3): fix sentence
(cherry picked from commit ba3896e169)
2021-08-13 12:34:42 +03:00
Konstantin Belousov
c4bb20a5ec _Exit(3): document implementation
(cherry picked from commit ee62fb2e1e)
2021-08-12 15:37:54 +03:00
Konstantin Belousov
5d7b612949 fork(2): comment about doubtful use of stdio and exit(3) in example
(cherry picked from commit 2a51e8823a)
2021-08-12 15:37:54 +03:00
Ceri Davies
f59374b69a fork.2: correct minor typo in manpage.
(cherry picked from commit 383dbdb2eb)
2021-08-12 15:37:54 +03:00
Konstantin Belousov
1c54a109d7 Add _Fork()
(cherry picked from commit 49ad342cc1)
2021-08-12 15:37:54 +03:00
Konstantin Belousov
8c51479a6e Style
(cherry picked from commit 2d319ebe5c)
2021-08-12 15:37:54 +03:00
Mateusz Piotrowski
3248a03c1a fork.2: Fix a typo in an example
(cherry picked from commit ca904beafd)
2021-08-12 15:37:54 +03:00
Mateusz Piotrowski
a9c0baa1d0 fork.2: Add a simple use pattern
(cherry picked from commit c4207d867c)
2021-08-12 15:37:54 +03:00
Mitchell Horne
952226eedb Prefer MK_SSP=no to SSP_CFLAGS=
It is more idiomatic. CFLAGS is only augmented with $SSP_CFLAGS when
$MK_SSP != "no".

Reviewed by:	imp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D31401

(cherry picked from commit 61ed578ee6)
2021-08-11 13:56:28 -03:00
Roy Marples
f452713408 socket: Implement SO_RERROR
SO_RERROR indicates that receive buffer overflows should be handled as
errors. Historically receive buffer overflows have been ignored and
programs could not tell if they missed messages or messages had been
truncated because of overflows. Since programs historically do not
expect to get receive overflow errors, this behavior is not the
default.

This is really really important for programs that use route(4) to keep
in sync with the system. If we loose a message then we need to reload
the full system state, otherwise the behaviour from that point is
undefined and can lead to chasing bogus bug reports.

Reviewed by:	philip (network), kbowling (transport), gbe (manpages)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D26652

(cherry picked from commit 7045b1603b)
2021-08-10 18:54:00 -07:00
Mark Johnston
d888157844 libc/locale: Use O_CLOEXEC when opening locale tables
Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 98bfb9dac2)
2021-08-05 08:45:22 -04:00
Alex Richardson
7809becb4e Add missing bsd.linker.mk include after 31ba4ce889
This is needed for -DWITH_CLEAN builds since the cleandir phase does not
include bsd.linker.mk from bsd.compiler.mk

(cherry picked from commit 9f1db6c555)
2021-08-05 11:45:33 +01:00
Alex Richardson
c65dab7dd2 Allow bootstrapping llvm-tblgen on macOS and Linux
This is needed in order to build various LLVM binutils (e.g. addr2line)
as well as clang/lld/lldb.

Co-authored-by: Jessica Clarke <jrtc27@FreeBSD.org>
Test Plan:	Compiles on ubuntu 18.04 and macOS 11.4
Reviewed By:	dim
Differential Revision: https://reviews.freebsd.org/D31057

(cherry picked from commit 31ba4ce889)
2021-08-05 10:01:08 +01:00
Alex Richardson
85c76b4117 tools/build: Don't redefine open() for the linux bootstrap
This is needed to bootstrap llvm-tblgen on Linux since LLVM calls
`::open(...)` which does not work if open is a statement macro.
Also stop defining O_SHLOCK/O_EXLOCK and update the only bootstrap tools
user of those flags to deal with missing definitions.

Reviewed By:	jrtc27
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D31226

(cherry picked from commit 5f6c8ce245)
2021-08-05 10:00:45 +01:00
Alex Richardson
22548a3b80 Simplify and speed up the kyua build
Instead of having multiple kyua libraries, just include the files as part
of usr.bin/kyua. Previously, we would build each kyua source up to four
times: once as a .o file and once as a .pieo. Additionally, the kyua
libraries might be built again for compat32. As all the kyua libraries
amount to 102 C++ sources the build time is significant (especially when
using an assertions enabled compiler). This change ensures that we build
306 fewer .cpp source files as part of buildworld.

Reviewed By:	brooks
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D30967

Remove lib/kyua from the build

I forgot to include this line in 2eb9ad4274.

Reported by:	Jenkins CI
MFC after:	1 week
Fixes:		2eb9ad427475190ei ("Simplify and speed up the kyua build")

Revert "Remove lib/kyua from the build"

Accidentally removed it from the wrong file...

This reverts commit 8ec4ba8a76.

Remove lib/kyua from the build

I forgot to include this line in 2eb9ad4274.

Reported by:    Jenkins CI
MFC after:      1 week
Fixes:          2eb9ad427475190ei ("Simplify and speed up the kyua build")

(cherry picked from commit 2eb9ad4274)
(cherry picked from commit 8ec4ba8a76)
(cherry picked from commit 89da04fcaa)
(cherry picked from commit c951566915)
2021-08-05 09:56:47 +01:00
Konstantin Belousov
a1b0744399 x86 __vdso_gettc: add O_CLOEXEC flag to open
(cherry picked from commit cbf6f55e77)
2021-08-05 03:56:46 +03:00
Tom Jones
64a0116cd0 Correct section reference for examples in RFC3542
Reviewed by:	bz, network
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D26272

(cherry picked from commit 44752e92e1)
2021-08-04 09:15:27 +01:00
Mark Johnston
225d3b0771 libvmmapi: Fix warnings and stop overridding WARNS
- Avoid shadowing the global optarg.
- Sprinkle __unused.
- Cast nitems() to int.
- Fix sign in vm_copy_setup().

Reviewed by:	grehan
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 45cd18ec73)
2021-08-02 15:01:02 -04:00
Dimitry Andric
af732203b8 Merge llvm-project 12.0.1 release and follow-up fixes
Merge llvm-project main llvmorg-12-init-17869-g8e464dd76bef

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-12-init-17869-g8e464dd76bef, the last commit before the
upstream release/12.x branch was created.

PR:		255570

(cherry picked from commit e8d8bef961)

Merge llvm-project 12.0.0 release

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-12.0.0-0-gd28af7c654d8, a.k.a. 12.0.0 release.

PR:		255570

(cherry picked from commit d409305fa3)

Disable strict-fp for powerpcspe, as it does not work properly yet

Merge commit 5c18d1136665 from llvm git (by Qiu Chaofan)

  [SPE] Disable strict-fp for SPE by default

  As discussed in PR50385, strict-fp on PowerPC SPE has not been
  handled well. This patch disables it by default for SPE.

  Reviewed By: nemanjai, vit9696, jhibbits

  Differential Revision: https://reviews.llvm.org/D103235

PR:		255570

(cherry picked from commit 715df83abc)

Apply upstream libc++ fix to allow building with devel/xxx-xtoolchain-gcc

Merge commit 52e9d80d5db2 from llvm git (by Jason Liu):

  [libc++] add `inline` for __open's definition in ifstream and ofstream

  Summary:

  When building with gcc on AIX, it seems that gcc does not like the
  `always_inline` without the `inline` keyword.
  So adding the inline keywords in for __open in ifstream and ofstream.
  That will also make it consistent with __open in basic_filebuf
  (it seems we added `inline` there before for gcc build as well).

  Differential Revision: https://reviews.llvm.org/D99422

PR:		255570

(cherry picked from commit d099db2546)

Undefine HAVE_(DE)REGISTER_FRAME in llvm's config.h on arm

Otherwise, the lli tool (enable by WITH_CLANG_EXTRAS) won't link on arm,
stating that __register_frame is undefined. This function is normally
provided by libunwind, but explicitly not for the ARM Exception ABI.

Reported by:	oh
PR:		255570

(cherry picked from commit f336b45e94)

Merge llvm-project 12.0.1 rc2

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-12.0.1-rc2-0-ge7dac564cd0e, a.k.a. 12.0.1 rc2.

PR:		255570

(cherry picked from commit 23408297fb)

Revert libunwind change to fix backtrace segfault on aarch64

Revert commit 22b615a96593 from llvm git (by Daniel Kiss):

  [libunwind] Support for leaf function unwinding.

  Unwinding leaf function is useful in cases when the backtrace finds a
  leaf function for example when it caused a signal.
  This patch also add the support for the DW_CFA_undefined because it marks
  the end of the frames.

  Ryan Prichard provided code for the tests.

  Reviewed By: #libunwind, mstorsjo

  Differential Revision: https://reviews.llvm.org/D83573

  Reland with limit the test to the x86_64-linux target.

Bisection has shown that this particular upstream commit causes programs
using backtrace(3) on aarch64 to segfault. This affects the lang/rust
port, for instance. Until we can upstream to fix this problem, revert
the commit for now.

Reported by:	mikael
PR:		256864

(cherry picked from commit 5866c369e4)

Merge llvm-project 12.0.1 release

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-12.0.1-0-gfed41342a82f, a.k.a. 12.0.1 release.

PR:		255570

(cherry picked from commit 4652422eb4)

compilert-rt: build out-of-line LSE atomics helpers for aarch64

Both clang >= 12 and gcc >= 10.1 now default to -moutline-atomics for
aarch64. This requires a bunch of helper functions in libcompiler_rt.a,
to avoid link errors like "undefined symbol: __aarch64_ldadd8_acq_rel".

(Note: of course you can use -mno-outline-atomics as a workaround too,
but this would negate the potential performance benefit of the faster
LSE instructions.)

Bump __FreeBSD_version so ports maintainers can easily detect this.

PR:		257392

(cherry picked from commit cc55ee8009)
2021-07-31 20:56:55 +02:00