]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agosh: Allow more scripts without #!
Jilles Tjoelker [Sat, 30 May 2020 16:00:49 +0000 (16:00 +0000)]
sh: Allow more scripts without #!

Austin Group bugs #1226 and #1250 changed the requirements for shell scripts
without #! (POSIX does not specify #!; this is about the shell execution
when execve(2) returns an [ENOEXEC] error).

POSIX says we shall allow execution if the initial part intended to be
parsed by the shell consists of characters and does not contain the NUL
character.  This allows concatenating a shell script (ending with exec or
exit) and a binary payload.

In order to reject common binary files such as PNG images, check that there
is a lowercase letter or expansion before the last newline before the NUL
character, in addition to the check for the newline character suggested by
POSIX.

(cherry picked from commit e0f5c1387df23c8c4811f5b24a7ef6ecac51a71a)

3 years agosh: Test that executing various binary files is rejected
Jilles Tjoelker [Mon, 30 Dec 2019 21:32:55 +0000 (21:32 +0000)]
sh: Test that executing various binary files is rejected

If executing a file fails with an [ENOEXEC] error, the shell executes the
file as a shell script, except that this execution may instead result in an
error message if the file is binary.

Per a recent Austin Group interpretation, we will need to change this to
allow a concatenation of a shell script and a binary payload. See
Austin Group bugs #1226 and #1250.

MFC after: 1 week

(cherry picked from commit 2a55bade0ed3e08a8c4f922df0ecf67d1ee32f53)

3 years agokevent(2): Bugfix for wrong EVFILT_TIMER timeouts
Jan Kokemüller [Sat, 9 Jan 2021 19:00:25 +0000 (20:00 +0100)]
kevent(2): Bugfix for wrong EVFILT_TIMER timeouts

When using NOTE_NSECONDS in the kevent(2) API, US_TO_SBT should be
used instead of NS_TO_SBT, otherwise the timeout results are
misleading.

PR: 252539
Reviewed by: kevans, kib
Approved by: kevans
Differential Revision: https://reviews.freebsd.org/D28067

(cherry picked from commit 4d0c33be634a929f323117f04e6b1670776f9e37)

3 years agoelfctl: prefix disable flags with "no"
Ed Maste [Wed, 13 Jan 2021 18:08:31 +0000 (13:08 -0500)]
elfctl: prefix disable flags with "no"

Some ELF feature flags indicate a request to opt-out of some feature,
for example NT_FREEBSD_FCTL_ASLR_DISABLE indicates that ASLR should be
disabled for the tagged binary.  Using "aslr" as the short name for the
flag is confusing as it seems to indicate a request for ASLR to be
enabled.  Rename "noaslr", and make a similar change for other opt-out
flags.

Reviewed by: bapt, manu, markj
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28139

(cherry picked from commit c763f99d11fdc9641308124c4a030c90b6a7fdbb)

3 years agoelfctl: allow features to be specified by value
Ed Maste [Fri, 22 Jan 2021 17:22:35 +0000 (12:22 -0500)]
elfctl: allow features to be specified by value

This will allow elfctl on older releases to set bits that are not yet
known there, so that the binary will have the correct settings applied
if run on a later FreeBSD version.

PR: 252629 (related)
Suggested by: kib
Reviewed by: gbe (manpage, earlier), kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28284

(cherry picked from commit 86f33b5fcf6087bf4439881011b920ff99e6e300)

elfctl: fix typo from last-minute refactoring

Reported by: jkim

(cherry picked from commit f302fd1aa6730facd53a3f761e0a57302731b03e)

elfctl: Fix type errors.

Target value for val has uint32_t type, not uint, adjust used constant.
Change val type to unsigned so that left and right sides of comparision
operator do not expose different signed types of same range [*].

Switch to unsigned long long and strtoll(3) so that 0x80000000 is
accepted by conversion function [**].

Reported by: kargl [*]
Noted by: emaste [**]
Reviewed by: emaste
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28301

(cherry picked from commit 9940ac808de7b7d4ed0408c3e739f667dca06d3b)

3 years agoelfctl: add backwards compatibility for "no" prefixes
Ed Maste [Wed, 13 Jan 2021 19:21:38 +0000 (14:21 -0500)]
elfctl: add backwards compatibility for "no" prefixes

I am going to prefix opt-out ELF feature flag names with "no" to make
their meaning more clear (review D28139), but there are some uses of the
existing names already (e.g., the PR referenced below).

For now accept the older, unprefixed name as well, and emit a warning.
We can revert this after FreeBSD 13 branches.

% elfctl -e +aslr foo
elfctl: interpreting aslr as noaslr; please specify noaslr

PR: 239873 (related)
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28140

(cherry picked from commit 3dfcb70b6ae9bcb9fd6a66721bebdb8c6a53c329)

3 years agorctl(4): support throttling resource usage to 0
Jason A. Harmening [Wed, 30 Dec 2020 23:29:44 +0000 (15:29 -0800)]
rctl(4): support throttling resource usage to 0

For rate-based resources that support throttling (e.g.
readiops/writeips), this fixes a divide-by-zero panic when rctl(8)
passes 0 as the throttle value.  For these resources, treat
zero-throttle requests as requests to suspend forward progress as long
as possible using the duration specified in
kern.racct.rctl.throttle_max.

PR: 251803
Reported by: chris@cretaforce.gr

(cherry picked from commit e8a5a1ad7154dc34e3a5234267e19faa86d5ff33)

3 years agondis: Per user request, delay removal to 14
Brooks Davis [Mon, 25 Jan 2021 22:16:27 +0000 (22:16 +0000)]
ndis: Per user request, delay removal to 14

We will remove ndis shortly after the 13 branch.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D28049

(cherry picked from commit d7a7d6a7c3c6a9b6e03e4739df6801e2a0a296e9)

3 years agoVFS_QUOTACTL: Remove needless casts of arg
Brooks Davis [Mon, 25 Jan 2021 22:16:26 +0000 (22:16 +0000)]
VFS_QUOTACTL: Remove needless casts of arg

The argument is a void * so there's no need to cast it to caddr_t.

Update documentation to match function decleration.

Reviewed by: freqlabs
Obtained from: CheriBSD
MFC after: 1 week
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D27093

(cherry picked from commit 52e63ec2f1ddf76c9411b6833bc5d021457b5005)

3 years agocontrib/tzdata: import tzdata 2021a
Philip Paeps [Mon, 25 Jan 2021 00:18:14 +0000 (08:18 +0800)]
contrib/tzdata: import tzdata 2021a

Merge commit '4cd7e1071de16a7392b0e466287f13e9e6f2081a'

Changes: https://github.com/eggert/tz/blob/2021a/NEWS

(cherry picked from commit 8c5bef2eb24cb191c87712a56a9860d8c29415a0)

3 years agosafexcel: Simplify request allocation
Mark Johnston [Mon, 18 Jan 2021 22:07:56 +0000 (17:07 -0500)]
safexcel: Simplify request allocation

Rather than preallocating a set of requests and moving them between
queues during state transitions, maintain a shadow of the command
descriptor ring to track the driver context of each request.  This is
simpler and requires less synchronization between safexcel_process() and
the ring interrupt handler.

Sponsored by: Rubicon Communications, LLC (Netgate)

(cherry picked from commit 1a6ffed5d73a22858182e68e629662afda1b9f6d)

3 years agosafexcel: Handle command/result descriptor exhaustion gracefully
Mark Johnston [Mon, 18 Jan 2021 22:07:56 +0000 (17:07 -0500)]
safexcel: Handle command/result descriptor exhaustion gracefully

Rather than returning a hard error in this case, return ERESTART so that
upper layers get a chance to retry the request (or drop it, depending on
the desired policy).

This case is hard to hit due to the somewhat low bound on queued
requests, but that will no longer be true after an upcoming change.

Sponsored by: Rubicon Communications, LLC (Netgate)

(cherry picked from commit b7e27af36b7df05f4b6cdc706750413f3a048640)

3 years agosafexcel: Add counters for some resource exhaustion conditions
Mark Johnston [Mon, 18 Jan 2021 22:07:55 +0000 (17:07 -0500)]
safexcel: Add counters for some resource exhaustion conditions

This is useful when analyzing performance problems.

Sponsored by: Rubicon Communications, LLC (Netgate)

(cherry picked from commit 0371c3faaa2412413d4fb44254b03124f97dfe66)

3 years agosafexcel: Dispatch requests to the current CPU's ring
Mark Johnston [Mon, 18 Jan 2021 22:07:55 +0000 (17:07 -0500)]
safexcel: Dispatch requests to the current CPU's ring

This gives better performance in some tests than the previous policy of
statically binding each session to a ring.

Sponsored by: Rubicon Communications, LLC (Netgate)

(cherry picked from commit e934d455ba37ea777bd32cdcb0f9754865f9e818)

3 years agogdb: only return signal values for powerpc's gdb_cpu_signal()
Mitchell Horne [Fri, 22 Jan 2021 18:56:56 +0000 (14:56 -0400)]
gdb: only return signal values for powerpc's gdb_cpu_signal()

Reviewed by: alfredo

(cherry picked from commit 57a543d8b85065f77e0b68162d09a03335970f90)

3 years agoarm64: gdb(4) machine-dependent bits
mhorne [Wed, 9 Dec 2020 20:38:42 +0000 (16:38 -0400)]
arm64: gdb(4) machine-dependent bits

Sponsored by: The FreeBSD Foundation

(cherry picked from commit bbfa199cbc1698631a0e932848e62dd76559d4d7)

3 years agoarm64: remove pcb_pc
mhorne [Mon, 21 Dec 2020 16:16:09 +0000 (12:16 -0400)]
arm64: remove pcb_pc

Reviewed by: markj, jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 5f66d5a313bf2b2254de92b2915e48e5cf528893)

3 years agoarm64: don't pass user trapframe to kdb_trap()
mhorne [Fri, 18 Dec 2020 18:43:52 +0000 (14:43 -0400)]
arm64: don't pass user trapframe to kdb_trap()

Reviewed by: jhb (slightly earlier version)
Sponsored by: The FreeBSD Foundation

(cherry picked from commit e9bb4ce3d0e714d35b12ffdc7ecb56cade01f4a0)

3 years agoddb: add ability to print user registers
mhorne [Fri, 18 Dec 2020 20:06:46 +0000 (16:06 -0400)]
ddb: add ability to print user registers

Reviewed by: jhb (earlier version), markj, bcr (manpages)
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 088a7eef95b1f1919fe6eee722a57c4d4e1e0656)

3 years agotcp: add sysctl to tolerate TCP segments missing timestamps
Michael Tuexen [Wed, 13 Jan 2021 21:48:17 +0000 (22:48 +0100)]
tcp: add sysctl to tolerate TCP segments missing timestamps

When timestamp support has been negotiated, TCP segements received
without a timestamp should be discarded. However, there are broken
TCP implementations (for example, stacks used by Omniswitch 63xx and
64xx models), which send TCP segments without timestamps although
they negotiated timestamp support.
This patch adds a sysctl variable which tolerates such TCP segments
and allows to interoperate with broken stacks.

Reviewed by: jtl@, rscheff@
Differential Revision: https://reviews.freebsd.org/D28142
Sponsored by: Netflix, Inc.
PR: 252449

(cherry picked from commit d2b3ceddccac60b563f642898e3a314647666a10)

3 years agotcp: fix handling of TCP RST segments missing timestamps
Michael Tuexen [Wed, 13 Jan 2021 22:43:40 +0000 (23:43 +0100)]
tcp: fix handling of TCP RST segments missing timestamps

A TCP RST segment should be processed even it is missing TCP
timestamps.

Reported by: dmgk@, kevans@
Reviewed by: rscheff@, dmgk@
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D28143

(cherry picked from commit cc3c34859eab1b317d0f38731355b53f7d978c97)

3 years agoiflib: add assert to prevent out-of-bounds array access
Vincenzo Maffione [Sun, 10 Jan 2021 13:49:51 +0000 (13:49 +0000)]
iflib: add assert to prevent out-of-bounds array access

The iflib_queues_alloc() allocates isc_nrxqs iflib_dma_info structs
for each rxqset, and links each struct to a different free list.
As a result, it must be isc_nrxqs >= isc_nfl (plus the completion
queue, if present).
Add an assertion to make this constraint explicit.

MFC after: 2 weeks

(cherry picked from commit 4ba9ad0dc316940f32065b05f24259f942c0692d)

3 years agolualoader: fix lua-lint run
Kyle Evans [Thu, 17 Dec 2020 18:29:30 +0000 (18:29 +0000)]
lualoader: fix lua-lint run

luacheck rightfully complains that i is unused in the show-module-options
loop at the end (it was used for some debugging in the process).

We've added a new pager module that's compiled in, so declare that as an
acceptable global.

(cherry picked from commit 29842cb36e74037989b7a7f0bf38a47f342bac91)

3 years agostand: remove bogus dependency from libsa32
Kyle Evans [Thu, 7 Jan 2021 22:02:55 +0000 (16:02 -0600)]
stand: remove bogus dependency from libsa32

libsa32 is independent of libsa, they can build in parallel if needed.

(cherry picked from commit 27e90f70e09d9d003bdea09c41be64a7ec2ece9a)

3 years agostand: properly declare subdir deps or .WAIT, do parallel build
Kyle Evans [Thu, 31 Dec 2020 17:15:45 +0000 (11:15 -0600)]
stand: properly declare subdir deps or .WAIT, do parallel build

buildworld already runs the stand build in parallel[1], so make it easier to
identify ordering issues by properly establishing dependencies or adding
.WAIT where needed.

Everything in stand/ relies on libsa, either directly or indirectly, because
libsa build is where the stand headers get installed and it gets linked in
most places.

Interpreters depend on their libs, machine dirs usually depend on top-level
libs that are getting built and at least one of the interpreter flavors.

For i386, order btx/libi386/libfirewire before everything else using a
big-ol-.WAIT hammer. btx is the most common dependency, but the others are
used sporadically. This seems to be where the race reporting on the mailing
list is- AFAICT, the following sequence is happening:

1.) One of the loaders gets built based on stale btx/btxldr
2.) btx/btxldr gets rebuilt
3.) installworld triggers loader rebuild because btx was rebuilt after

This seems like the most plausible explanation, as they've verified system
time and timestamps.

While we're here, let's switch stand/ over to a completely parallel build so
we can work out these kinds of issues in isolation rather than in the middle
of a larger build.

(cherry picked from commit ac5f382a9d0a26685b92b49abb845d3b30ea5f91)
(cherry picked from commit 8b4c3a03f933b77b65c78fdef976831d27942d9d)
(cherry picked from commit e41367e3ae1246c2b086f9f920a175108aa72380)

3 years agoMove stand/ofw/libofw to stand/libofw.
Brandon Bergren [Thu, 2 Jan 2020 04:34:22 +0000 (04:34 +0000)]
Move stand/ofw/libofw to stand/libofw.

Since rS330365, there has been no particular reason for libofw to be in a
subdirectory of ofw. Move libofw up a level to make it fit in better with
the other top level libraries.

Also add a LIBOFWSRC to stand/defs.mk to match what all the other
libraries are doing.

(cherry picked from commit 475008d6ca47ccb2b4baca59a37421d95916d2ba)

3 years agoPartial revert of ac6e3a14070
Kyle Evans [Sun, 24 Jan 2021 04:43:46 +0000 (22:43 -0600)]
Partial revert of ac6e3a14070

refcount_load() does not yet exist on this branch, and the path to MFC'ing
it is slightly non-trivial. Back out the part that uses it -- it's a ddb
command anyways, so the cost of getting it wrong is ~low.

Pointy hat: kevans (did not test with DDB)

(direct commit)

3 years agodu: tests: make H_flag tests more strict about output requirements
Kyle Evans [Tue, 5 Jan 2021 21:49:46 +0000 (15:49 -0600)]
du: tests: make H_flag tests more strict about output requirements

The current version of this test will effectively pass as long as one of the
specified paths is in the output, and it could even be a subset of one of
the paths.

Strengthen up the test a little bit:
  * Specify beginning/end anchors for each path
  * Add egrep -v checks to make sure we don't have any *additional* paths
  * Ratchet down paths2 to exactly the two paths we expect to appear

(cherry picked from commit 3c5c39c7ad8f010cfa5fc0db43d15d1964b4cf16)

3 years agodu: tests: fix the H_flag test (primarily grep usage)
Kyle Evans [Tue, 5 Jan 2021 21:33:06 +0000 (15:33 -0600)]
du: tests: fix the H_flag test (primarily grep usage)

This test attempts to use \t (tab intended) in a grep expression.  With the
former /usr/bin/grep (i.e. gnugrep), this was interpreted as a literal 't'.
The expression would work anyways because the tr(1) usage would ultimately
replace all of the spaces with a single newline, and they would match the
paths whether they were correctly fromatted or not.

Current /usr/bin/grep (i.e. bsdgrep) is less-tolerant of ordinary-escapes, a
property of the underlying regex(3) engine, to make it easier to identify
when stuff like this happens. In-fact, this expression broke after the
switch happened.

This revision does the bare basics to fix the usage by using a printf to get
a literal tab character to insert into the expression. It also swaps out the
manual insertion of the line prefix into the grep expression by pulling
that part out of $sep and reusing it for the leading path.

The secondary issue was the tr(1) usage, since tr would only replace the
first character of string1 with the first character of string2.  This has
instead been replaced by a sed expression, which similary understands \n to
be a newline on all supported versions of FreeBSD.  Each path now gets
prefixed with the appropriate context that should be there (i.e. numeric
sequence followed by a tab).

PR: 252446

(cherry picked from commit 4832d2e8ae1df6f907ac00275764f8135722cb7e)

3 years agocpuset: refcount-clean
Mateusz Guzik [Tue, 17 Nov 2020 00:04:05 +0000 (00:04 +0000)]
cpuset: refcount-clean

(cherry picked from commit 1a7bb8962904b4eef9d968d98afda31c08612868)

3 years agolibc: tests: add some tests for cpuset(2)
Kyle Evans [Thu, 31 Dec 2020 18:30:43 +0000 (12:30 -0600)]
libc: tests: add some tests for cpuset(2)

The cpuset(2) tests should be run as root (require.user properly set) with
>= 3 cpus for maximum coverage. All tests that want to modify the cpuset
don't assume any particular cpu layout (i.e. the first cpu may not be 0, the
last may not be first + count) and the following scenarios are tested:

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

(cherry picked from commit 1fc421287d5ddbcfba99412cf968ee3490383fe7)

3 years agoBump up the low range of cpuset numbers to account for the kernel cpuset.
Stephen J. Kiernan [Thu, 5 Sep 2019 17:48:39 +0000 (17:48 +0000)]
Bump up the low range of cpuset numbers to account for the kernel cpuset.

Obtained from: Juniper Networks, Inc.

(cherry picked from commit d57cd5ccd38299ae9834c4f913c4b5cbe53dee1e)

3 years agolibc: tests: hook CPUSET(9) test up to the build
Kyle Evans [Thu, 31 Dec 2020 18:26:01 +0000 (12:26 -0600)]
libc: tests: hook CPUSET(9) test up to the build

Add shims to map NetBSD's API to CPUSET(9). Obviously the invalid input
parts of these tests are relatively useless since we're just testing the
shims that aren't used elsewhere, there's still some amount of value in
the parts testing valid inputs.

Differential Revision: https://reviews.freebsd.org/D27307

(cherry picked from commit 9e1281eabafa4aaf84828e70488c1802717b59af)

3 years agolibregex: re-enable `make check`
Kyle Evans [Fri, 8 Jan 2021 19:57:32 +0000 (13:57 -0600)]
libregex: re-enable `make check`

The tests are generally expected to pass, uncomment the annotation that
lets `make check` work. Note that `make check` currently requires kyua
from ports or an appropriate symlink into /usr/local/bin.

(cherry picked from commit 04a3ba363d13cf5efaeb63f64cd3fdd6b9c71248)

3 years agoflua: implement chmod
Ed Maste [Fri, 13 Mar 2020 15:40:35 +0000 (15:40 +0000)]
flua: implement chmod

Lua does not provide a native way to change the permission of a file.

(cherry picked from commit 405e3338ac841999673056a2b5537b4c0ad677db)

3 years agoFix -Wundef warnings when building liblua
Alex Richardson [Tue, 25 Aug 2020 13:30:34 +0000 (13:30 +0000)]
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).

(cherry picked from commit 0c54932d50a0cbffdd083bf6b2e8d587902f90c9)

3 years agoflua: don't allow dlopen, et al., for bootstrap flua
Kyle Evans [Fri, 14 Aug 2020 02:22:19 +0000 (02:22 +0000)]
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.

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.

(cherry picked from commit c2a2b4f3cf11e770892a524df637f671f5989719)
(cherry picked from commit 967fbfd9e2b7a015d5cba1491badcdf9044b28b9)

3 years agoflua: support "require" for binary objects in the base system
Ed Maste [Thu, 13 Aug 2020 23:13:05 +0000 (23:13 +0000)]
flua: support "require" for binary objects in the base system

Export symbols from flua, and enable dlopen.

(cherry picked from commit 3bd8419597b44dc3da2b1e6ffc2c7ee9cf4aa195)

3 years agoflua: initial support for "require" in the base system
Ed Maste [Thu, 13 Aug 2020 00:19:05 +0000 (00:19 +0000)]
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.

(cherry picked from commit bceabe277e1286ec694e34c186a73e7bf2c9de4f)

3 years agoMakefile: add a small blurb about building with gcc xtoolchain
Kyle Evans [Fri, 16 Oct 2020 15:16:23 +0000 (15:16 +0000)]
Makefile: add a small blurb about building with gcc xtoolchain

The key details are to install the appropriate flavor of devel/freebsd-gcc6
and pass CROSS_TOOLCHAIN while building.

(cherry picked from commit 5f2aaba4532c713f74279f0e83208c97af3a3e69)
(cherry picked from commit cf82304d7d5e8d9433d46cbdf2db8c2576b85edd)

3 years agokern: dup: do not assume oldfde is valid
Kyle Evans [Mon, 23 Nov 2020 00:33:06 +0000 (00:33 +0000)]
kern: dup: do not assume oldfde is valid

oldfde may be invalidated if the table has grown due to the operation that
we're performing, either via fdalloc() or a direct fdgrowtable_exp().

This was technically OK before rS367927 because the old table remained valid
until the filedesc became unused, but now it may be freed immediately if
it's an unshared table in a single-threaded process, so it is no longer a
good assumption to make.

This fixes dup/dup2 invocations that grow the file table; in the initial
report, it manifested as a kernel panic in devel/gmake's configure script.

(cherry picked from commit f96078b8fe55c944f32c3c82ebb9c360bc155823)

3 years agolualoader: add loader_conf_dirs support (loader.conf.d)
Kyle Evans [Fri, 10 Jul 2020 01:50:15 +0000 (20:50 -0500)]
lualoader: add loader_conf_dirs support (loader.conf.d)

loader_conf_dirs is the supporting mechanism for the included
/boot/loader.conf.d directory.  When lualoader finishes processing all of
the loader_conf_files it finds after walking /boot/defaults/loader.conf,
it will now check any and all loader_conf_dirs and process files ending
in ".conf" as if they were a loader.conf.

Note that loader_conf_files may be specified in a loader.conf.d config
file, but loader_conf_dirs may *not*. It will only be processed as specified
in /boot/defaults/loader.conf and any loader_conf_files that were loaded
from there.

Relnotes: yes

(cherry picked from commit 72cf7db3aaf17db412183886f19320e5074dc8b7)

3 years agolibc: regex: rework unsafe pointer arithmetic
Miod Vallat [Fri, 8 Jan 2021 18:59:00 +0000 (12:59 -0600)]
libc: regex: rework unsafe pointer arithmetic

regcomp.c uses the "start + count < end" idiom to check that there are
"count" bytes available in an array of char "start" and "end" both point to.

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

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

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

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

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

PR: 252403
(cherry picked from commit d36b5dbe28d8ebab219fa29db533734d47f0c4a3)

3 years agolualoader: use floor division to get correct type
Kyle Evans [Fri, 15 Jan 2021 14:15:40 +0000 (08:15 -0600)]
lualoader: use floor division to get correct type

This fixes the positioning of the "Welcome to FreeBSD" heading, which was
misplaced after the recent update to Lua 5.4. The issue was previously
masked by a compatibility knob in Lua 5.3 that would cause float-tagged
numbers to render faithfully without the decimal component. Lua 5.4 dropped
that and ensures that it always prints a decimal component, even if it has
to append a ".0" to the value.

Standard division produces a "float", floor division (//) can be used to
guarantee an integer. Floating point operations have been completely ripped
out of the liblua compiled for the bootloader, so this is a nop. This is
decidedly better than trying to hack out the float tag entirely.

(cherry picked from commit 994e1f40f6db059290cf4a8203c2b9eea22d9a38)

3 years agocertctl: replace hardcoded uses of /usr/local
Kyle Evans [Sat, 9 Jan 2021 04:00:41 +0000 (22:00 -0600)]
certctl: replace hardcoded uses of /usr/local

Use the new user.localbase sysctl here as well, to reduce the number of
hardcoded localbase by one (1).

(cherry picked from commit b799d38a2ad10ec84c8ffa4a554a1816465c0d12)

3 years agobectl: tests: use -R <mount> instead of specifying altroot
Kyle Evans [Sat, 16 Jan 2021 05:58:12 +0000 (23:58 -0600)]
bectl: tests: use -R <mount> instead of specifying altroot

-R is currently shorthand for cachefile=none, altroot=<mount>.  This is
functionally the same, but perhaps more resilient to future changes that
could be necessary that may be added when -R is specified.

(cherry picked from commit de661c9f8652f6a51a6ca83d404d9170404990f8)

3 years agokldxref(8): Sort MDT_MODULE info first in linker.hints output
Conrad Meyer [Mon, 27 May 2019 17:33:20 +0000 (17:33 +0000)]
kldxref(8): Sort MDT_MODULE info first in linker.hints output

MDT_MODULE info is required to be ordered before any other MDT metadata for
a given kld because it serves as an implicit record boundary between
distinct klds for linker.hints consumers.  kldxref(8) has previously relied
on the assumption that MDT_MODULE was ordered relative to other module
metadata in kld objects by source code ordering.

However, C does not require implementations to emit file scope objects in
any particular order, and it seems that GCC 6.4.0 and/or binutils 2.32 ld
may reorder emitted objects with respect to source code ordering.

So: just take two passes over a given .ko's module metadata, scanning for
the MDT_MODULE on the first pass and the other metadata on subsequent
passes.  It's not super expensive and not exactly a performance-critical
piece of code.  This ensures MDT_MODULE is always ordered before
MDT_PNP_INFO and other MDTs, regardless of compiler/linker movement.  As a
fringe benefit, it removes the requirement that care be taken to always
order MODULE_PNP_INFO after DRIVER_MODULE in source code.

Reviewed by: emaste, imp
Differential Revision: https://reviews.freebsd.org/D20405

(cherry picked from commit 9c1fa7a429145b298a012cb7b752c82a1e0b1184)

3 years agoUnify Intel CODEC naming.
Alexander Motin [Fri, 15 Jan 2021 14:56:15 +0000 (09:56 -0500)]
Unify Intel CODEC naming.

Submitted by: Dmitry Luhtionov <dmitryluhtionov@gmail.com>

(cherry picked from commit 510cc421263fa807a72c9b4b8d9a4091a96d9648)

3 years agoAdd Intel Gemini Lake AHCI ID.
Alexander Motin [Fri, 15 Jan 2021 14:53:35 +0000 (09:53 -0500)]
Add Intel Gemini Lake AHCI ID.

Submitted by: Dmitry Luhtionov <dmitryluhtionov@gmail.com>

(cherry picked from commit 006e2b2b8285842216ceb914a4cf828c89c2d7f7)

3 years agoFix dependency cleanup hack for pf_ruleset.c
Kristof Provost [Fri, 22 Jan 2021 16:24:07 +0000 (17:24 +0100)]
Fix dependency cleanup hack for pf_ruleset.c

In 4046f57601eaa0bcd1ec8496e1280939b948aa46 we added a dependency
cleanup to cope with the pf_ruleset.c changes.

This commit failed to include '; \' at the end of the shell lines in the
make target, causing build failures.

PR: 252910

3 years agoMFC 9a47ae044b48:
Hans Petter Selasky [Fri, 8 Jan 2021 10:45:26 +0000 (11:45 +0100)]
MFC 9a47ae044b48:
Bump driver versions for mlx5en(4) and mlx4en(4).

Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoMFC r353632:
Hans Petter Selasky [Wed, 16 Oct 2019 08:55:29 +0000 (08:55 +0000)]
MFC r353632:
Replace rdma_is_upper_dev_rcu() with rdma_vlan_dev_real_dev() in ibcore.
This reduces the number of references to VLAN_TRUNKDEV() in ibcore.
Currently only VLAN is supported as a child interface in FreeBSD.
Remove superfluous RCU locking.

Sponsored by: Mellanox Technologies

3 years agoMFC daa150aaa30f:
Hans Petter Selasky [Fri, 8 Jan 2021 10:52:44 +0000 (11:52 +0100)]
MFC daa150aaa30f:
Properly handle case where firmware dump returns more registers on second pass
in mlx5core.

Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoMFC a00718e1dfcd:
Hans Petter Selasky [Fri, 8 Jan 2021 11:12:02 +0000 (12:12 +0100)]
MFC a00718e1dfcd:
Implement SIOCGIFRSSKEY and SIOCGIFRSSHASH and mlx5en(4).

Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoMFC 89c0b4fa1172:
Hans Petter Selasky [Fri, 8 Jan 2021 11:21:58 +0000 (12:21 +0100)]
MFC 89c0b4fa1172:
Bump some copyrights in mlx5en(4).

Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoMFC 87b3c8cc99f9:
Hans Petter Selasky [Fri, 8 Jan 2021 10:54:16 +0000 (11:54 +0100)]
MFC 87b3c8cc99f9:
Fix spelling in mlx5core.

Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoMFC 82c7abe7785b:
Hans Petter Selasky [Fri, 8 Jan 2021 10:58:10 +0000 (11:58 +0100)]
MFC 82c7abe7785b:
The "unsigned" type is the same like "unsigned int".

Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoMFC 50a9f8bbc1dd:
Hans Petter Selasky [Fri, 8 Jan 2021 10:50:41 +0000 (11:50 +0100)]
MFC 50a9f8bbc1dd:
Downgrade error about missing VSC to warning and make messages consistent
in mlx5core.

Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoMFC 480570dbb309:
Hans Petter Selasky [Fri, 8 Jan 2021 11:06:11 +0000 (12:06 +0100)]
MFC 480570dbb309:
Fixes for SRIOV in mlx5core.

- call pci_iov_detach() on detaching from PCI device to take care of hang
  on destroying VFs after PF is down.

- disable eswitch SRIOV support right after pci_iov_detach(),
  else the eswitch cleanup sometimes occur while the SRIOV flow table
  is still present.

Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoMFC 376e130b4707:
Hans Petter Selasky [Fri, 8 Jan 2021 11:22:18 +0000 (12:22 +0100)]
MFC 376e130b4707:
Fix memory leaks in error paths in krping.

Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoMFC 376479200760:
Hans Petter Selasky [Fri, 8 Jan 2021 11:44:42 +0000 (12:44 +0100)]
MFC 376479200760:
Fix whitespace in mlx5en(4).

Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoarmv8crypto: print a message on probe failure
Mitchell Horne [Mon, 18 Jan 2021 20:59:21 +0000 (16:59 -0400)]
armv8crypto: print a message on probe failure

Similar to the message printed by aesni(4), let the user know if the
driver is unsupported by their CPU.

PR: 252543
Reported by: gbe
Sponsored by: The FreeBSD Foundation

(cherry picked from commit a520f5ca580fcff34fd0d9f0d64a4c165f57eb30)

3 years agorc.conf(5): describe devmatch rc variables
Mitchell Horne [Sun, 10 Jan 2021 20:53:59 +0000 (16:53 -0400)]
rc.conf(5): describe devmatch rc variables

Reviewed by: imp, gbe (manpages)

(cherry picked from commit ef757da441b199da680bfbd24afaa9d3c16e5b55)

3 years agoiwm(4): Add support for Intel Killer(R) Wireless-AC 1550i
Mark Johnston [Thu, 14 Jan 2021 16:41:28 +0000 (11:41 -0500)]
iwm(4): Add support for Intel Killer(R) Wireless-AC 1550i

PR: 252578
Submitted by: shu <ankohuu@outlook.com>

(cherry picked from commit 90cc8706ccb2da130c0b1a28434a9ec5d4c80d81)

3 years agotmpfs_reclaim: detach unlinked node on dereferencing.
Konstantin Belousov [Tue, 12 Jan 2021 16:10:07 +0000 (18:10 +0200)]
tmpfs_reclaim: detach unlinked node on dereferencing.

(cherry picked from commit 2d1e4220ebd50b9220d3266754425f025c786108)

3 years agopf tests: pass NULL buffer to DIOCRCLRTSTATS
Kristof Provost [Wed, 13 Jan 2021 18:41:07 +0000 (19:41 +0100)]
pf tests: pass NULL buffer to DIOCRCLRTSTATS

As discovered by syzcaller this used to provoke panics.

MFC after: 1 week

(cherry picked from commit 44117554b1ee8edd66d7383c17802d5799fd18f2)

3 years agopf: Don't hold PF_RULES_WLOCK during copyin() on DIOCRCLRTSTATS
Kristof Provost [Wed, 13 Jan 2021 18:30:01 +0000 (19:30 +0100)]
pf: Don't hold PF_RULES_WLOCK during copyin() on DIOCRCLRTSTATS

We cannot hold a non-sleepable lock during copyin(). This means we can't
safely count the table, so instead we fall back to the pf_ioctl_maxcount
used in other ioctls to protect against overly large requests.

Reported by: syzbot+81e380344d4a6c37d78a@syzkaller.appspotmail.com
MFC after: 1 week

(cherry picked from commit ea36212bf5711206bbaf5362a23ebb52c7f7e2a4)

3 years agopf: Copy kif flags to userspace
Kristof Provost [Thu, 7 Jan 2021 21:24:38 +0000 (22:24 +0100)]
pf: Copy kif flags to userspace

This was overlooked in the pfi_kkif/pfi_kif splitup and as a result
userspace could no longer tell which interfaces had the skip flag
applied.

MFC after: 2 weeks

(cherry picked from commit 0fcb03fbaca1307175edc96355c867471db309f8)

3 years agopfctl: Fix NOCLEAN build
Kristof Provost [Tue, 19 Jan 2021 12:48:31 +0000 (13:48 +0100)]
pfctl: Fix NOCLEAN build

We've created a new pf_ruleset.c file for pfctl and no longer use the
kernel vrsion, but the build system doesn't handle this dependency
change correctly. Delete the dependency file if it contains the kernel
version of the file.

(modified from commit c38e59ce1b0a6c030a942d0814d581dbd7f67e3c)

3 years agopfctl: Stop sharing pf_ruleset.c with the kernel
Kristof Provost [Thu, 24 Dec 2020 15:02:04 +0000 (16:02 +0100)]
pfctl: Stop sharing pf_ruleset.c with the kernel

Now that we've split up the datastructures used by the kernel and
userspace there's essentually no more overlap between the pf_ruleset.c
code used by userspace and kernelspace.

Copy the userspace bits to the pfctl directory and stop using the kernel
file.

Reviewed by: philip
MFC after: 2 weeks
Sponsored by: Orange Business Services
Differential Revision: https://reviews.freebsd.org/D27764

(cherry picked from commit fda7daf06301beef1bdad39891232a12c6925b22)

3 years agopf: Convert pfi_kkif to use counter_u64
Kristof Provost [Sun, 13 Dec 2020 16:20:02 +0000 (17:20 +0100)]
pf: Convert pfi_kkif to use counter_u64

Improve caching behaviour by using counter_u64 rather than variables
shared between cores.

The result of converting all counters to counter(9) (i.e. this full
patch series) is a significant improvement in throughput. As tested by
olivier@, on Intel Xeon E5-2697Av4 (16Cores, 32 threads) hardware with
Mellanox ConnectX-4 MCX416A-CCAT (100GBase-SR4) nics we see:

x FreeBSD 20201223: inet packets-per-second
+ FreeBSD 20201223 with pf patches: inet packets-per-second
+--------------------------------------------------------------------------+
|                                                                        + |
| xx                                                                     + |
|xxx                                                                    +++|
||A|                                                                       |
|                                                                       |A||
+--------------------------------------------------------------------------+
    N           Min           Max        Median           Avg        Stddev
x   5       9216962       9526356       9343902     9371057.6     116720.36
+   5      19427190      19698400      19502922      19546509     109084.92
Difference at 95.0% confidence
        1.01755e+07 +/- 164756
        108.584% +/- 2.9359%
        (Student's t, pooled s = 112967)

Reviewed by: philip
MFC after: 2 weeks
Sponsored by: Orange Business Services
Differential Revision: https://reviews.freebsd.org/D27763

(cherry picked from commit 5a3b9507d784aaa6a7ce35432b2111a7eec12cba)

3 years agopf: Allocate and free pfi_kkif in separate functions
Kristof Provost [Sun, 13 Dec 2020 10:36:54 +0000 (11:36 +0100)]
pf: Allocate and free pfi_kkif in separate functions

Factor out allocating and freeing pfi_kkif structures. This will be
useful when we change the counters to be counter_u64, so we don't have
to deal with that complexity in the multiple locations where we allocate
pfi_kkif structures.

No functional change.

MFC after: 2 weeks
Sponsored by: Orange Business Services
Differential Revision: https://reviews.freebsd.org/D27762

(cherry picked from commit 26c841e2a402ed43896313d1b3f00facaa9d839f)

3 years agopf: Split pfi_kif into a user and kernel space structure
Kristof Provost [Sat, 12 Dec 2020 14:14:56 +0000 (15:14 +0100)]
pf: Split pfi_kif into a user and kernel space structure

No functional change.

MFC after: 2 weeks
Sponsored by: Orange Business Services
Differential Revision: https://reviews.freebsd.org/D27761

(cherry picked from commit 320c11165b6b1113b34f9e156cbf85b5ed0aa5eb)

3 years agopf: Change pf_krule counters to use counter_u64
Kristof Provost [Sat, 5 Dec 2020 20:41:42 +0000 (21:41 +0100)]
pf: Change pf_krule counters to use counter_u64

This improves the cache behaviour of pf and results in improved
throughput.

MFC after: 2 weeks
Sponsored by: Orange Business Services
Differential Revision: https://reviews.freebsd.org/D27760

(cherry picked from commit c3adacdad4d72b045058cd932351b94579cdd543)

3 years agopf: Remove unused fields from pf_krule
Kristof Provost [Sat, 5 Dec 2020 13:38:12 +0000 (14:38 +0100)]
pf: Remove unused fields from pf_krule

The u_* counters are used only to communicate with userspace, as
userspace cannot use counter_u64. As pf_krule is not passed to userspace
these fields are now obsolete.

MFC after: 2 weeks
Sponsored by: Orange Business Services
Differential Revision: https://reviews.freebsd.org/D27759

(cherry picked from commit c7bdafe2f1b703fdf72489019edc3d6b9e5483da)

3 years agopf: Split pf_rule into kernel and user space versions
Kristof Provost [Sat, 5 Dec 2020 13:32:54 +0000 (14:32 +0100)]
pf: Split pf_rule into kernel and user space versions

No functional change intended.

MFC after: 2 weeks
Sponsored by: Orange Business Services
Differential Revision: https://reviews.freebsd.org/D27758

(cherry picked from commit e86bddea9fe62d5093a1942cf21950b3c5ca62e5)

3 years agopf: Migrate pf_rule and related structs to pf.h
Kristof Provost [Thu, 3 Dec 2020 16:17:39 +0000 (17:17 +0100)]
pf: Migrate pf_rule and related structs to pf.h

As part of the split between user and kernel mode structures we're
moving all user space usable definitions into pf.h.

No functional change intended.

MFC after:      2 weeks
Sponsored by:   Orange Business Services
Differential Revision: https://reviews.freebsd.org/D27757

(cherry picked from commit dc865dae89c34291467e0ba569a8c78fc7a5d360)

3 years agopf: Use counter_u64 in pf_src_node
Kristof Provost [Fri, 13 Nov 2020 19:31:51 +0000 (20:31 +0100)]
pf: Use counter_u64 in pf_src_node

Reviewd by: philip
MFC after:      2 weeks
Sponsored by:   Orange Business Services
Differential Revision: https://reviews.freebsd.org/D27756

(cherry picked from commit fbbf270eef271806a0a106e45356d91f5b5e1f55)

3 years agopf: Split pf_src_node into a kernel and userspace struct
Kristof Provost [Wed, 23 Dec 2020 13:51:52 +0000 (14:51 +0100)]
pf: Split pf_src_node into a kernel and userspace struct

Introduce a kernel version of struct pf_src_node (pf_ksrc_node).

This will allow us to improve the in-kernel data structure without
breaking userspace compatibility.

Reviewed by: philip
MFC after: 2 weeks
Sponsored by: Orange Business Services
Differential Revision: https://reviews.freebsd.org/D27707

(cherry picked from commit 17ad7334ca6225e0dc5caca12d1eb5886115f7af)

3 years agoAdd some examples to script.1
Mateusz Piotrowski [Tue, 5 Jan 2021 15:28:32 +0000 (16:28 +0100)]
Add some examples to script.1

While here:

- Split synopsis into two parts. The first explains how to record
  sessions, while the second one explains how to replay (some of)
  the recorded sessions.
- Fix the -width argument of the environment variables list.

(cherry picked from commit d41149a8e9cbb76ff89322a3363299f1b93823d2)

3 years agoImprove readability of the options list
Mateusz Piotrowski [Tue, 5 Jan 2021 14:46:56 +0000 (15:46 +0100)]
Improve readability of the options list

(cherry picked from commit 225afb6cad9808af42408875baaa243d6d75d92d)

3 years agoFix a typo
Mateusz Piotrowski [Thu, 7 Jan 2021 14:28:29 +0000 (15:28 +0100)]
Fix a typo

(cherry picked from commit 0199cbf641db5f28d258153014fa8a657ae98ea6)

3 years agoAdd a missing period and remove a macro from Bl's width argument
Mateusz Piotrowski [Thu, 12 Nov 2020 16:44:56 +0000 (16:44 +0000)]
Add a missing period and remove a macro from Bl's width argument

(cherry picked from commit 2bbc7e74368c73d198838ee821a4b3dd75a8be6a)

3 years agobootparamd: Fix build with GCC.
Yoshihiro Takahashi [Tue, 19 Jan 2021 17:41:37 +0000 (02:41 +0900)]
bootparamd: Fix build with GCC.

Remove CWARNFLAGS for GCC because GCC 4.2.1 does not have
-Wdiscarded-qualifiers option.

This is direct commit to stable/12.

Pointy hat to: nyan

3 years agobootparamd: Add missing __unused mark.
Yoshihiro Takahashi [Sat, 2 Jan 2021 15:40:34 +0000 (00:40 +0900)]
bootparamd: Add missing __unused mark.

e03764d931d820185a019334259b18df2e3f6b6c did not catch all unused
variables.

Submitted by: otis
Differential Revision: https://reviews.freebsd.org/D27894

(cherry picked from commit 8c45fe5d8ecda4be7564aadaa50712790c6c0a6f)

3 years agobootparamd: Fix several warnings and increase warn level to 6.
Yoshihiro Takahashi [Sat, 2 Jan 2021 03:36:09 +0000 (12:36 +0900)]
bootparamd: Fix several warnings and increase warn level to 6.

- Increase WARNS to 6.
- Except -Wcast-align and -Wincompatible-pointer-types-discards-qualifiers
  checks.
- Use ANSI C prototype.
- Statically variables and functions.
- Add extern declaration for global variables.
- Rename local variables to resolve shadow warnings.

PR: 71667

(cherry picked from commit e03764d931d820185a019334259b18df2e3f6b6c)

3 years agounzip: Sync with NetBSD upstream.
Yoshihiro Takahashi [Sat, 2 Jan 2021 01:50:08 +0000 (10:50 +0900)]
unzip: Sync with NetBSD upstream.

- Ignore malformed directory entries as created by Dropbox ("/").
  (rev 1.24)
- Use libarchive 3.x interface: check result for archive_read_free()
  and don't call archive_read_close manually. (rev 1.23)
- Always overwrite symlinks on extraction, ever if they're newer than
  entries in archive.
- Use getline() rather than getdelim().

PR: 231827
Submitted by: ak
Reviewed by: mm
Obtained from: NetBSD

(cherry picked from commit 0cdfa4956424dc816944a84568a4d9900b68f5e3)

3 years agoelftcl: add -i flag to ignore unknown flags
Ed Maste [Wed, 13 Jan 2021 03:24:52 +0000 (22:24 -0500)]
elftcl: add -i flag to ignore unknown flags

This may allow an identical elfctl invocation to be used on multiple
FreeBSD versions, with features not implemented on older releases being
silently ignored.

PR: 252629 (related)
Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28130

(cherry picked from commit f6d95a01103a49a94c876d5a51bb4be25c06d964)

3 years agortld: map without PROT_EXEC for relocation
Ed Maste [Mon, 4 Jan 2021 18:55:44 +0000 (13:55 -0500)]
rtld: map without PROT_EXEC for relocation

This makes text segment relocation work under W^X.

Submitted by: Greg V <greg@unrelenting.technology> (original version)
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D27953

(cherry picked from commit 613a08cfa2e0fb1b99906961c7a676d527e17f05)

3 years agoqat: Free counters during detach
Mark Johnston [Thu, 14 Jan 2021 16:41:28 +0000 (11:41 -0500)]
qat: Free counters during detach

Sponsored by: Rubicon Communications, LLC (Netgate)

(cherry picked from commit 6483fc224b1a68528a65c16e9d8e55e2b5535ee9)

3 years agoqat: Count request allocation failures
Mark Johnston [Thu, 14 Jan 2021 16:41:28 +0000 (11:41 -0500)]
qat: Count request allocation failures

This can be useful for troubleshooting performance problems.

Sponsored by: Rubicon Communications, LLC (Netgate)

(cherry picked from commit a33b29a0447b24a054ecc48e51355d2abf7e6b5b)

3 years agoqat: Fix DH895XCC firmware module autoloading
Mark Johnston [Thu, 14 Jan 2021 16:41:28 +0000 (11:41 -0500)]
qat: Fix DH895XCC firmware module autoloading

Sponsored by: Rubicon Communications, LLC (Netgate)

(cherry picked from commit 95ee7d9b879ce42088277c85d85e61f6c79674ad)

3 years agolibdtrace: Format USDT symbols correctly based on symbol binding
Mark Johnston [Sun, 10 Jan 2021 22:46:32 +0000 (17:46 -0500)]
libdtrace: Format USDT symbols correctly based on symbol binding

Before we did not handle weak symbols correctly, sometimes resulting in
link errors from dtrace -G when processing object files where functions
with weak aliases contain USDT probes.

Reported by: rlibby
Sponsored by: The FreeBSD Foundation

(cherry picked from commit d00431a7bd0c4b4607943baed588e58ad5ae6150)

3 years agomvneta: Acquire the softc lock before clearing the MIB
Mark Johnston [Sat, 9 Jan 2021 15:03:46 +0000 (10:03 -0500)]
mvneta: Acquire the softc lock before clearing the MIB

Reported by: Andrei Martin <andrei.cos.martin@gmail.com>

(cherry picked from commit 109260d202fb64be6f2efcf243c25090c1f64420)

3 years agomvneta: Fix 64-bit MIB reads
Mark Johnston [Mon, 4 Jan 2021 13:22:21 +0000 (08:22 -0500)]
mvneta: Fix 64-bit MIB reads

It appears we must read MIB values as 2 4-byte words, lower address
first.  A single 8-byte MIB read returns the value with the lower 4
bytes copied into the upper 4 bytes, resulting in bogus byte counter
values.

Reviewed by: mw
Sponsored by: Rubicon Communications, LLC (Netgate)
Differential Revision: https://reviews.freebsd.org/D27870

(cherry picked from commit caf552a607191ffc798e3edb697ae99d5b15711a)

3 years agoxen: allow limiting the amount of duplicated pending xenstore watches
Roger Pau Monné [Wed, 25 Nov 2020 11:34:38 +0000 (12:34 +0100)]
xen: allow limiting the amount of duplicated pending xenstore watches

Xenstore watches received are queued in a list and processed in a
deferred thread. Such queuing was done without any checking, so a
guest could potentially trigger a resource starvation against the
FreeBSD kernel if such kernel is watching any user-controlled xenstore
path.

Allowing limiting the amount of pending events a watch can accumulate
to prevent a remote guest from triggering this resource starvation
issue.

For the PV device backends and frontends this limitation is only
applied to the other end /state node, which is limited to 1 pending
event, the rest of the watched paths can still have unlimited pending
watches because they are either local or controlled by a privileged
domain.

The xenstore user-space device gets special treatment as it's not
possible for the kernel to know whether the paths being watched by
user-space processes are controlled by a guest domain. For this reason
watches set by the xenstore user-space device are limited to 1000
pending events. Note this can be modified using the
max_pending_watch_events sysctl of the device.

This is XSA-349.

Sponsored by: Citrix Systems R&D
MFC after: 3 days

(cherry picked from commit 4e4e43dc9e1afc863670a031cc5cc75eb5e668d6)

3 years agoxen/xenstore: remove unused functions
Roger Pau Monné [Thu, 26 Nov 2020 08:57:47 +0000 (09:57 +0100)]
xen/xenstore: remove unused functions

Those helpers are not used, so remove them. No functional change.

Sponsored by: Citrix Systems R&D
MFC after: 3 days

(cherry picked from commit 2ae75536d370c238f77ad09e5e994d2b8bdf010c)

3 years agoarm64: fix early devmap assertion
Mitchell Horne [Wed, 13 Jan 2021 18:30:50 +0000 (14:30 -0400)]
arm64: fix early devmap assertion

PR: 25241
Reported by: gbe
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 818390ce0ca539300dd15d7a817784f1e3f7a9b8)

3 years agolibthr malloc: support recursion on thr_malloc_umtx.
Konstantin Belousov [Tue, 12 Jan 2021 09:02:37 +0000 (11:02 +0200)]
libthr malloc: support recursion on thr_malloc_umtx.

PR: 252579

(cherry picked from commit 85d028223bc2768651f4d44881644ceb5dc2a664)

3 years agolibthr: wrap pdfork(2), same as fork(2).
Konstantin Belousov [Sun, 10 Jan 2021 19:22:49 +0000 (21:22 +0200)]
libthr: wrap pdfork(2), same as fork(2).

(cherry picked from commit 21f749da82e755aafab127618affeffb86cff9a5)