]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agomsdosfs: Fix a leak of dirent padding bytes
Mark Johnston [Sun, 27 Dec 2020 21:52:30 +0000 (16:52 -0500)]
msdosfs: Fix a leak of dirent padding bytes

This was missed in r340856 / commit
6d2e2df764199f0a15fd743e79599391959cc17d.  Three bytes from the kernel
stack may be leaked when reading directory entries.

Reported by: Syed Faraz Abrar <faraz@elttam.com>

(cherry picked from commit 599f90446376370eb365a0fde857ea2b5766873a)

3 years agoqatfw: Fix firmware autoloading for qat_c2xxx devices
Mark Johnston [Wed, 23 Dec 2020 16:31:47 +0000 (11:31 -0500)]
qatfw: Fix firmware autoloading for qat_c2xxx devices

r368193 was suppsed to rename the MOF firmware image, but the
qat_c2xxxfw makefile defined the two images in the wrong order so the
MMP image was renamed instead.

(cherry picked from commit 3b216bfb6cce24aa84519315138be8d23ac5d613)

3 years agoffs: Avoid out-of-bounds accesses in the fs_active bitmap
Mark Johnston [Wed, 23 Dec 2020 16:13:00 +0000 (11:13 -0500)]
ffs: Avoid out-of-bounds accesses in the fs_active bitmap

We use a bitmap to track which cylinder groups have changed between
snapshot creation and filesystem suspension.  The "legs" of the bitmap
are four bytes wide (see ACTIVESET()) so we must round up the allocation
size to a multiple of four bytes.

I believe this bug is harmless since UMA/kmem_* will both pad the
allocation and zero the full allocation.  Note that malloc() does inline
zeroing when the allocation size is known at compile-time.

Reported by: pho (using KASAN)
Reviewed by: kib, mckusick

(cherry picked from commit ace3d9475ceecd9bcb766bb82a1c8f87e8f560be)

3 years agonetgraph: Fix ng_ether's shutdown handing
Mark Johnston [Wed, 23 Dec 2020 05:11:16 +0000 (00:11 -0500)]
netgraph: Fix ng_ether's shutdown handing

When tearing down a VNET, netgraph sends shutdown messages to all of the
nodes before detaching interfaces (SI_SUB_NETGRAPH comes before
SI_SUB_INIT_IF in teardown order).  ng_ether nodes handle this by
destroying themselves without detaching from the parent ifnet.  Then,
when ifnets go away they detach their ng_ether nodes again, triggering a
use-after-free.

Handle this by modifying ng_ether_shutdown() to detach from the ifnet.
If the shutdown was triggered by an ifnet being destroyed, we will clear
priv->ifp in the ng_ether detach callback, so priv->ifp may be NULL.

Also get rid of the printf in vnet_netgraph_uninit().  It can be
triggered trivially by ng_ether since ng_ether_shutdown() persists the
node unless NG_REALLY_DIE is set.

PR: 233622
Reviewed by: afedorov, kp, Lutz Donnerhacke

(cherry picked from commit cd698c51790e956fed0975f451d3dfc361dc7c24)

3 years agoacpi: Ensure that adjacent memory affinity table entries are coalesced
Mark Johnston [Fri, 18 Dec 2020 16:04:48 +0000 (16:04 +0000)]
acpi: Ensure that adjacent memory affinity table entries are coalesced

The SRAT may contain multiple distinct entries that together describe a
contiguous region of physical memory.  In this case we were not
coalescing the corresponding entries in the memory affinity table, which
led to fragmented phys_avail[] entries.  Since r338431 the vm_phys_segs[]
entries derived from phys_avail[] will be coalesced, resulting in a
situation where vm_phys_segs[] entries do not have a covering
phys_avail[] entry.  vm_page_startup() will not add such segments to the
physical memory allocator, leaving them unused.

Reported by: Don Morris <dgmorris@earthlink.net>
Reviewed by: kib, vangyzen

(cherry picked from commit 0f8b212a1e41d6eabf2a17442bcbe4f128f023f8)

3 years agoixl: quiet -Wunused-function
Ryan Libby [Tue, 5 Jan 2021 20:51:40 +0000 (12:51 -0800)]
ixl: quiet -Wunused-function

Direct commit to stable/12.

svn r363876 / git 2bba796c66ede62803ed5da3d83e7efb70c5e9bc MFC'd head
svn r361992 / git b4a7ce0690aedd9763b3b47ee7fcdb421f0434c7.  These two
prototypes were brought back, but the definitions were not.  The
definitions had been introduced earlier for unrelated work, in svn
r353503 / git ba76aa63573f4aeb8fbea6dc85548660cc6d083b, which has not
been MFC'd.

Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D27817

3 years agoPerform kernel linker ifunc test only for builds
Ed Maste [Sun, 27 Dec 2020 00:34:24 +0000 (19:34 -0500)]
Perform kernel linker ifunc test only for builds

dvl reported that "make installkernel" failed with "amd64/arm64/i386
kernel requires linker ifunc support."  This test should apply to builds
only; the linker is not used at install time.

I think the same (ifunc-supporting) linker used to build the kernel
should be detected at install time in usual cases (and so not trigger
this error).  However, there is no reason to disallow the install, if
for some reason the expected linker isn't the one tested at install
time.

PR: 251580
Reported by: dvl
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 581ade97d561e136dbb7cf7a413128c343a23199)

3 years agoFix typo in an_initator_name.
Alexander Motin [Tue, 29 Dec 2020 18:41:56 +0000 (13:41 -0500)]
Fix typo in an_initator_name.

(cherry picked from commit bdbc2a6fc2d8c524d2059e3124f81be08f025a65)

3 years agoFix typo in ap_initator_portal.
Alexander Motin [Tue, 29 Dec 2020 18:32:05 +0000 (13:32 -0500)]
Fix typo in ap_initator_portal.

(cherry picked from commit a3434cdc6b01f23a6a2184923c4367c098ae084d)

3 years agoUFS2: Fix DoS due to corrupted extattrfile
Conrad Meyer [Fri, 30 Oct 2020 19:00:42 +0000 (19:00 +0000)]
UFS2: Fix DoS due to corrupted extattrfile

Prior versions of FreeBSD (11.x) may have produced a corrupt extattr file.
(Specifically, r312416 accidentally fixed this defect by removing a strcpy.)
CURRENT FreeBSD supports disk images from those prior versions of FreeBSD.
Validate the internal structure as soon as we read it in from disk, to
prevent these extattr files from causing invariants violations and DoS.

Attempting to access the extattr portion of these files results in
EINTEGRITY.  At this time, the only way to repair files damaged in this way
is to copy the contents to another file and move it over the original.

PR: 244089
Reported by: Andrea Venturoli <ml AT netfence.it>
Reviewed by: kib
Discussed with: mckusick (earlier draft)

(cherry picked from commit e6790841f749b3cc1ac7d338181d9358aae04d0b)

3 years agogdb(4) fix x86 signal reporting
Mitchell Horne [Wed, 23 Dec 2020 19:36:17 +0000 (15:36 -0400)]
gdb(4) fix x86 signal reporting

The existing values correspond to x86 exception vector numbers, but the
trap numbers used in the kernel do not match these 1-to-1. Prefer the
definitions from x86/trap.h, as they are what actually get passed to
kdb_trap(). This is of little consequence, as gdb_cpu_signal() only
reports the trap reason (signal number) to the gdb client.

This is limited to the subset of trap values for which kdb_trap() is
reachable.

Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.

(cherry picked from commit 962c06c5a32deb9357851d5aca060defc79e6e90)

3 years agogdb(4): allow bulk write of registers
Mitchell Horne [Wed, 23 Dec 2020 18:37:05 +0000 (14:37 -0400)]
gdb(4): allow bulk write of registers

Add support for the remote 'G' packet. This is not widely used by gdb
when 'P' is supported, but is technically required by any remote gdb
stub implementation [1].

[1] https://sourceware.org/gdb/current/onlinedocs/gdb/Overview.html

Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.

(cherry picked from commit 3f3cc995a35a3e9136204a98af0af5808c11047f)

3 years agogdb(4): handle single register read packets
Mitchell Horne [Wed, 23 Dec 2020 18:36:08 +0000 (14:36 -0400)]
gdb(4): handle single register read packets

We support bulk reads of the register set, but not reading specific
registers via the 'p' packet. This is useful at least for the 'call'
command in gdb.

Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.

(cherry picked from commit fd29833d9a7d8355ce21743ed8c706b72ba03363)

3 years agoamd64: use register macros for gdb_cpu_getreg()
Mitchell Horne [Fri, 18 Dec 2020 16:16:03 +0000 (16:16 +0000)]
amd64: use register macros for gdb_cpu_getreg()

Prefer these newly-added definitions to bare values.

Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.

(cherry picked from commit 72939459bdfa930348d0b3397db5d947593ad348)

3 years agoamd64: allow gdb(4) to write to most registers
Mitchell Horne [Fri, 18 Dec 2020 16:09:24 +0000 (16:09 +0000)]
amd64: allow gdb(4) to write to most registers

Similar to the recent patch to arm's gdb stub in r368414, allow GDB to
update the contents of most general purpose registers.

Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.

(cherry picked from commit 0ef474de88fdb78e3cb7ac9bc0b1b98e5b49b4e4)

3 years agoFix daily_backup_gpart_exclude in periodic daily 221.backup-gpart
Ed Maste [Sun, 27 Dec 2020 00:24:18 +0000 (19:24 -0500)]
Fix daily_backup_gpart_exclude in periodic daily 221.backup-gpart

Since gpart_devs was not quoted (losing embedded newlines), if
daily_backup_gpart_exclude matched something, gpart_devs was empty.

PR: 251961
Submitted by: Kan Sasaki

(cherry picked from commit 93900fc697992f893e2e69dce0c2f67b1f66a774)

3 years agopf tests: Verify (tcp) checksum modification on unaligned options
Kristof Provost [Sat, 19 Dec 2020 15:06:03 +0000 (16:06 +0100)]
pf tests: Verify (tcp) checksum modification on unaligned options

It turns out pf incorrectly updates the TCP checksum if the TCP option
we're modifying is not 2-byte algined with respect to the start of the
packet.

Create a TCP packet with such an option and throw it through a scrub
rule, which will update timestamps and modify the packet.

PR: 240416
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D27688

(cherry picked from commit 2d3fda5fa1dc99aa8788e5f8d8bb71e682101063)

3 years agopf: Fix unaligned checksum updates
Kristof Provost [Sun, 20 Dec 2020 20:06:32 +0000 (21:06 +0100)]
pf: Fix unaligned checksum updates

The algorithm we use to update checksums only works correctly if the
updated data is aligned on 16-bit boundaries (relative to the start of
the packet).

Import the OpenBSD fix for this issue.

PR: 240416
Obtained from: OpenBSD
MFC after: 1 week
Reviewed by: tuexen (previous version)
Differential Revision: https://reviews.freebsd.org/D27696

(cherry picked from commit c3f69af03ae7acc167cc1151f0c1ecc5e014ce4e)

3 years agoFollow r354121 to fix some python3 errors in sys.netpfil.*
Li-Wen Hsu [Sun, 27 Oct 2019 21:07:50 +0000 (21:07 +0000)]
Follow r354121 to fix some python3 errors in sys.netpfil.*

stderr:

Traceback (most recent call last):
  File "/usr/tests/sys/netpfil/common/pft_ping.py", line 135, in <module>
    main()
  File "/usr/tests/sys/netpfil/common/pft_ping.py", line 124, in main
    ping(args.sendif[0], args.to[0], args)
  File "/usr/tests/sys/netpfil/common/pft_ping.py", line 74, in ping
    raw = sp.raw(str(PAYLOAD_MAGIC))
  File "/usr/local/lib/python3.6/site-packages/scapy/compat.py", line 52, in raw
    return bytes(x)
TypeError: string argument without an encoding

MFC with: r354121
Sponsored by: The FreeBSD Foundation

(cherry picked from commit cfa8b6482740b2be1719d51e927f76b4adec3b92)

3 years agoUpgrade (scapy) py2 tests to work on py3.
Bjoern A. Zeeb [Sat, 26 Oct 2019 21:19:55 +0000 (21:19 +0000)]
Upgrade (scapy) py2 tests to work on py3.

In order to move python2 out of the test framework to avoid py2 vs. py3
confusions upgrade the remaining test cases using scapy to work with py3.
That means only one version of scapy needs to be installed in the CI system.
It also gives a path forward for testing i386 issues observed in the CI
system with some of these tests.

Fixes are:
- Use default python from environment (which is 3.x these days).
- properly ident some lines as common for the rest of the file to avoid
  errors.
- cast the calculated offset to an int as the division result is considered
  a float which is not accepted input.
- when comparing payload to a magic number make sure we always add the
  payload properly to the packet and do not try to compare string in
  the result but convert the data payload back into an integer.
- fix print formating.

Discussed with: lwhsu, kp (taking it off his todo :)
MFC after: 2 weeks

(cherry picked from commit f0297f121aee3ff9ae6de9d445fc4a7981385d05)

3 years agoFix path issues after r351212
Li-Wen Hsu [Thu, 22 Aug 2019 12:08:35 +0000 (12:08 +0000)]
Fix path issues after r351212

This fixes sys.netpfil.pf.forward.v4 and sys.netpfil.pf.icmp.cve_2019_5598
failures in CI system.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit cdac716946b14572d8c5c764a99617fe5a176da2)

3 years agonetpfil tests: Move pft_ping.py and sniffer.py to the common test directory
Kristof Provost [Mon, 19 Aug 2019 10:48:27 +0000 (10:48 +0000)]
netpfil tests: Move pft_ping.py and sniffer.py to the common test directory

The pft_ping.py and sniffer.py tool is moved from tests/sys/netpfil/pf to
tests/sys/netpfil/common directory because these tools are to be used in
common for all the firewalls.

Submitted by: Ahsan Barkati
Reviewed by: kp, thj
Sponsored by: Google, Inc. (GSoC 2019)
Differential Revision: https://reviews.freebsd.org/D21276

(cherry picked from commit 9531253098a1b889520b49a98af0bb81a2373ac0)

3 years agopf tests: Fix accidental duplication of content
Mateusz Piotrowski [Thu, 15 Aug 2019 12:00:59 +0000 (12:00 +0000)]
pf tests: Fix accidental duplication of content

Some files got their contented duplicated in r345409. Some mistakes where
fixed in r345430. The only file that was left with a duplicated content was
CVE-2019-5598.py.

Reviewed by: kp
Approved by: src (kp)
Differential Revision: https://reviews.freebsd.org/D21267

(cherry picked from commit 03d8a4b7d39af6da7ceaaf07211cf0fde1e623ed)

3 years agopf tests: Fix accidental duplication of content
Kristof Provost [Sat, 23 Mar 2019 01:07:51 +0000 (01:07 +0000)]
pf tests: Fix accidental duplication of content

Also use the correct name for the scapy test script.

(cherry picked from commit dcccc93ae404ab8ead535efc4ddcd0fe9e3ee612)

3 years agopf tests: Test CVE-2019-5598
Kristof Provost [Fri, 22 Mar 2019 07:39:28 +0000 (07:39 +0000)]
pf tests: Test CVE-2019-5598

Verify that pf correctly drops inconsistent ICMP packets (i.e. where the
IP src/dst do not match the IP src/dst in the ICMP packet.

(cherry picked from commit 7de4bd92b8a1f510c88ea3b5af0bcb106af6ba11)

3 years agopf tests: Move Sniffer to its own file
Kristof Provost [Thu, 21 Mar 2019 08:15:46 +0000 (08:15 +0000)]
pf tests: Move Sniffer to its own file

Make it easier to re-use the sniffer class in other test support
scripts.

(cherry picked from commit d1805f60afc3f3c65f5d2bb360ed1ab55ea705da)

3 years agopf tests: Add a defer mode test for pfsync
Kristof Provost [Wed, 5 Dec 2018 19:53:09 +0000 (19:53 +0000)]
pf tests: Add a defer mode test for pfsync

Repeat the pfsync test, this time with the 'defer' option enabled. This
exercises slightly different code paths.

(cherry picked from commit 369d9a2c153e45e2645bc78cdc3a8cdc42f45b7b)

3 years agoMFC r368804: ipfw(8): Fix a few mandoc related issues
Gordon Bergling [Sat, 19 Dec 2020 12:47:40 +0000 (12:47 +0000)]
MFC r368804: ipfw(8): Fix a few mandoc related issues

- no blank before trailing delimiter
- missing section argument: Xr inet_pton
- skipping paragraph macro: Pp before Ss
- unusual Xr order: syslogd after sysrc
- tab in filled text

There were a few multiline NAT examples which used the .Dl macro with
tabs. I converted them to .Bd, which is a more suitable macro for that case.

(cherry picked from commit bae74ca92238e7df070c22f4b53dab12f60d82ef)

3 years agoMFC r366402: ipfw(8): Bugfixes for some issues reported by mandoc
Gordon Bergling [Sat, 3 Oct 2020 18:30:01 +0000 (18:30 +0000)]
MFC r366402: ipfw(8): Bugfixes for some issues reported by mandoc

- whitespace at end of input line
- new sentence, new line
- skipping paragraph macro: Pp before Pp

(cherry picked from commit 8636dd5703dbacff4e8f88385f98c9251526b751)

3 years agoMFC r364459 (by fernape): ipfw(8): Fix typo in man page
Fernando ApesteguĂ­a [Fri, 21 Aug 2020 17:45:17 +0000 (17:45 +0000)]
MFC r364459 (by fernape): ipfw(8): Fix typo in man page

s/exmaple/example

Approved by: manpages (gbe@)
Differential Revision: https://reviews.freebsd.org/D26147

(cherry picked from commit 71230912a70c5a64c02005603bf077d1d4b767cd)

3 years agoMFC r365628 by ae: Fix compatibility regression after r364117.
Andrey V. Elsukov [Fri, 11 Sep 2020 10:07:09 +0000 (10:07 +0000)]
MFC r365628 by ae: Fix compatibility regression after r364117.

Properly handle the case, when some opcode keywords follow after
the `frag` opcode without additional options.

Reported by: Evgeniy Khramtsov <evgeniy at khramtsov org>
Approved by: glebius

(cherry picked from commit b876085f5589f4e6d531d97ad902c5730ec55339)

3 years agoMFC r364117 by glebius:
Gleb Smirnoff [Tue, 11 Aug 2020 15:46:22 +0000 (15:46 +0000)]
MFC r364117 by glebius:

ipfw: make the "frag" keyword accept additional options "mf",
"df", "rf" and "offset".  This allows to match on specific
bits of ip_off field.

For compatibility reasons lack of keyword means "offset".

Reviewed by: ae
Approved by: glebius
Differential Revision: https://reviews.freebsd.org/D26021

(cherry picked from commit 825398f946221045c565363a0349f68d054d6455)

3 years agopf: Use counter(9) for pf_state byte/packet tracking
Kristof Provost [Wed, 23 Dec 2020 08:37:59 +0000 (09:37 +0100)]
pf: Use counter(9) for pf_state byte/packet tracking

This improves cache behaviour by not writing to the same variable from
multiple cores simultaneously.

pf_state is only used in the kernel, so can be safely modified.

Reviewed by: Lutz Donnerhacke, philip
MFC after: 1 week
Sponsed by: Orange Business Services
Differential Revision: https://reviews.freebsd.org/D27661

(cherry picked from commit 1c00efe98ed7d103b9684ff692ffd5e3b64d0237)

3 years ago81720dba:
Guangyuan Yang [Sun, 3 Jan 2021 00:11:49 +0000 (00:11 +0000)]
81720dba:
mmap(2): Fix a typo

PR:             252097
Reported by:    Nick Frampton <nick.frampton@akips.com>

a1d78367:
mmap(2): Update .Dd missed in the last commit

(cherry picked from commit 81720dbab2a84669ec719149501b75ae78c3d4ee)
(cherry picked from commit a1d783675213798620550f4af137340458abe6c5)

3 years agoMFC r368802: nvmecontrol(8): Fix a few mandoc related issues and add a SEE ALSO section
Gordon Bergling [Sat, 19 Dec 2020 11:47:38 +0000 (11:47 +0000)]
MFC r368802: nvmecontrol(8): Fix a few mandoc related issues and add a SEE ALSO section

- inserting missing end of block: Ss breaks Bl
- skipping paragraph macro: Pp before Ss
- referenced manual not found: Xr nvme 4 (2 times)
- unknown standard specifier: St The

The macro .St can only be used for standards known by mdoc(7). So add a
SEE ALSO section and add a reference to the NVM Express Base Specification.

(cherry picked from commit 9bca273d8496a078787ffbff18b9ae925e25cc36)

3 years agocaroot: drop $FreeBSD$ expansion from root bundle
Kyle Evans [Mon, 28 Dec 2020 03:47:41 +0000 (21:47 -0600)]
caroot: drop $FreeBSD$ expansion from root bundle

This debatably could have waited until the next update would have taken
place, but it's easier to see what changes if we get it out of the way
now.

(cherry picked from commit f20c0e3319524d51ab474608851bc705d57a7482)

3 years agoFix bad libbxo format strings in jls
Alex Richardson [Wed, 4 Nov 2020 14:31:52 +0000 (14:31 +0000)]
Fix bad libbxo format strings in jls

The existing format string for the empty case was trying to read varargs
values that weren't passed to xo_emit. This appears to work on x86 (since
the next argument is probably a pointer an empty string), but for CHERI
we can bound variadic arguments and detect a read past the end.

While touching these lines also use the libxo 'a' modifier to avoid having to
construct the libxo format string using asprintf.

Found by: CHERI
Reviewed By: allanjude
Differential Revision: https://reviews.freebsd.org/D26885

(cherry picked from commit d24f17df969107b47af60e5ccc1ed0f1a467fc6f)

3 years agoAlso pass SKEIN_USE_ASM to the assembler, via AFLAGS
Ed Maste [Fri, 5 Jun 2020 18:56:43 +0000 (18:56 +0000)]
Also pass SKEIN_USE_ASM to the assembler, via AFLAGS

(cherry picked from commit f2b86886645fc3fa331543565268808b80d5abdb)

3 years agoApply C SKEIN_LOOP setting only to skein_block.c
Ed Maste [Fri, 5 Jun 2020 17:00:38 +0000 (17:00 +0000)]
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).

(cherry picked from commit 310e81aede569411ad005f6d6e7259ae0cdafd82)

3 years agoUpdate leap-seconds to leap-seconds.3676924800.
Xin LI [Wed, 30 Dec 2020 06:01:46 +0000 (22:01 -0800)]
Update leap-seconds to leap-seconds.3676924800.

Obtained from: ftp://ftp.nist.gov/pub/time/leap-seconds.3676924800
MFC after: 3 days

(cherry picked from commit 2edcc10cb123ea845e00127f3241155dd98dac3b)

3 years agoMFC: Correct and add some comments.
Kirk McKusick [Thu, 31 Dec 2020 23:15:44 +0000 (15:15 -0800)]
MFC: Correct and add some comments.

Sponsored by: Netflix

(cherry picked from commit 68dc94c7d314b02ef80fe972f524a2b3c6e68a1c)

3 years agoFix the build of scandir_b with GCC.
John Baldwin [Mon, 31 Aug 2020 21:55:25 +0000 (21:55 +0000)]
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

(cherry picked from commit d10af81d2defe43db0db0a7dca3eefb047bd8ddc)

3 years agolibc: hide alphasort_thunk behind I_AM_SCANDIR_B
Mateusz Guzik [Sun, 23 Aug 2020 11:06:59 +0000 (11:06 +0000)]
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]

(cherry picked from commit 992bcb37c28ad1a6426df7996f297187ae3d901a)

3 years agoUse the 't' modifier to print a ptrdiff_t.
John Baldwin [Wed, 16 Dec 2020 00:11:30 +0000 (00:11 +0000)]
Use the 't' modifier to print a ptrdiff_t.

Obtained from: CheriBSD
Sponsored by: DARPA

(cherry picked from commit ce8395ecfda2c8e332a2adf9a9432c2e7f35ea81)

3 years agoDon't transmit mbufs that aren't yet ready on TOE sockets.
John Baldwin [Thu, 3 Dec 2020 22:01:13 +0000 (22:01 +0000)]
Don't transmit mbufs that aren't yet ready on TOE sockets.

This includes mbufs waiting for data from sendfile() I/O requests, or
mbufs awaiting encryption for KTLS.

Sponsored by: Chelsio Communications

(cherry picked from commit 99963f5343a017e934e4d8ea2371a86789a46ff9)

3 years agoMFC: Fix calendar -a processing of files included in the user's home directory
Stefan EĂźer [Thu, 29 Oct 2020 08:26:38 +0000 (08:26 +0000)]
MFC: Fix calendar -a processing of files included in the user's home directory

The existing code performed a chdir() into the home directory, but the
parser fell back to using the invoking user's home directory as the base
directory for the search for an include file.

Since use of the -a option is limited to UID==0, the directory searched
was typically ~root/.calendar, not the .calendar directory of the user
whose file is being processed.

PR: 205580
Reported by: greg.bal4@gmail.com (Greg Balfour)
MFC after: 3 days

(cherry picked from commit 3fa2a149d68d22fa32ba7b6c09773388ac490fd1)

The code in -CURRENT is quite different (forks sub-processes tp
process the files for each user) but this change should provide the
same functionality as the referenced commit to -CURRENT.

3 years agocopyrights: Happy New Year 2021
Glen Barber [Thu, 31 Dec 2020 15:44:52 +0000 (10:44 -0500)]
copyrights: Happy New Year 2021

Good riddance 2020.
(This fixes the previous MFC)

Sponsored by: Rubicon Communications, LLC (netgate.com)

3 years agocopyrights: Happy New Year 2021
Glen Barber [Thu, 31 Dec 2020 15:23:36 +0000 (10:23 -0500)]
copyrights: Happy New Year 2021

Good riddance 2020.

Sponsored by: Rubicon Communications, LLC (netgate.com)

(cherry picked from commit c3e89a30fdc2c985b73f46ab2f414d53945fc00b)

3 years agoMFC addr2line label checks when DW_AT_range and DW_AT_low_pc cannot be used
Ed Maste [Thu, 19 Nov 2020 21:10:36 +0000 (21:10 +0000)]
MFC addr2line label checks when DW_AT_range and DW_AT_low_pc cannot be used

addr2line: swap if conditions for diff reduction in upcoming change

No functional change intended.

(cherry picked from commit 65c207758a9586116a023dea8eb3d173e85cb0a9)

addr2line: add label checks when DW_AT_range and DW_AT_low_pc cannot be used

Check label's ranges for address we want to translate if a CU doesn't
have usable DW_AT_range or DW_AT_low_pc.

Use more appropriate names: "struct CU" -> "struct range"

Developed as part of upstream ELF Tool Chain bug report
https://sourceforge.net/p/elftoolchain/tickets/552/ although this does
not address the specific case reported there.

Submitted by: Tiger Gao <tig@freebsdfoundation.org>
Sponsored by: The FreeBSD Foundation
Differential Revision: D23782

(cherry picked from commit a36179937e7e768d1840896ac1ea13ba6f118a09)

addr2line: rework check_range conditions

Simplify logic and reduce indentation for DW_AT_low_pc case.

Reviewed by: Tiger Gao, markj
Sponsored by: The FreeBSD Foundation
Differential Revision: D27426

(cherry picked from commit f4d6ed9a5c5f5e78b9e20ae0c4b3ab78922aaf20)

addr2line: fix allocation leak in error path

CID: 1437677
Reported by: Coverity Scan
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 67b94fc58e61a78225930d54eadaba77f46a73b7)

3 years agoMFC: contrib/tzdata: import tzdata 2020f
Philip Paeps [Wed, 30 Dec 2020 04:50:26 +0000 (12:50 +0800)]
MFC: contrib/tzdata: import tzdata 2020f

Merge commit '96b88ac701b35ce68425046d4be8f51cb75b5d5b' into main

Changes: https://github.com/eggert/tz/blob/2020f/NEWS

(cherry picked from commit e35a01eec6926bfb5c088ca8961079b51a067bf3)

3 years agoDon't add -Wno-class-memaccess with older gcc.
Brooks Davis [Fri, 9 Aug 2019 23:50:57 +0000 (23:50 +0000)]
Don't add -Wno-class-memaccess with older gcc.

This is a gcc 8.0+ warning which needed to be silenced on for the riscv
build.  amd64-xtoolchain-gcc still uses gcc 6.4.0 and does not understand
this flag.

Reviewed by: asomers
Feedback from: imp
Differential Revision: https://reviews.freebsd.org/D21195

(cherry picked from commit 4a045a66fd912b0e28a0585dbd8991643ccc2cb0)

3 years agoImplement strerror_l().
Konstantin Belousov [Wed, 16 Dec 2020 09:02:09 +0000 (09:02 +0000)]
Implement strerror_l().

PR: 251651

MFC of r368692, r368723
(cherry picked from commit 675079b1ea61b310f3a42cb0d352a49c1780f89a)
(cherry picked from commit 65bf3043365bd86fc5d4d387ad0c42217f11330b)

3 years agoMFC r356352, r368272
Alan Somers [Sat, 4 Jan 2020 18:59:46 +0000 (18:59 +0000)]
MFC r356352, r368272

lio_listio_empty_nowait_thread sometimes does *not* hang.

The other tests consistently do hang though.

Sponsored by: DellEMC

(cherry picked from commit 0cb4586a0be3b1b5909b73b24798032ddf2f4002)

AIO tests: update expected failure messages after r368265

PR: 220398, 251515

(cherry picked from commit 23693bd8f3e36b4721d7b59d52154d3e3f49e3cd)

3 years ago[nvmecontrol] Fix type signedness warning-to-error on gcc-6.4
Adrian Chadd [Tue, 17 Nov 2020 17:12:28 +0000 (17:12 +0000)]
[nvmecontrol] Fix type signedness warning-to-error on gcc-6.4

This fixes a type signedness comparison warning-to-error on
gcc-6.4. The ternary operation casts it right but the actual
assignment doesn't.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D26791

(cherry picked from commit 44c52406ced4cbba704f9bec588a8238d5a5ef32)

3 years ago[libnetmap] Fix 32 bit compilation under gcc-6.4
Adrian Chadd [Mon, 2 Nov 2020 15:01:37 +0000 (15:01 +0000)]
[libnetmap] Fix 32 bit compilation under gcc-6.4

Use uintptr_t to cast a uint64_t to a pointer type.
Yeah, it isn't technically correct for platforms with pointers
> 64 bits, but it's fine here.

This fixes 32 bit compat library builds on amd64 and also
mips32 builds.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D26790

(cherry picked from commit 26c29e743bbdbb82762540f72d4bc449bae2e092)

3 years ago[libsa] Fix typecast of pointer for st_dev
Adrian Chadd [Thu, 16 Apr 2020 23:29:49 +0000 (23:29 +0000)]
[libsa] Fix typecast of pointer for st_dev

This code was trying to use a pointer value for st_dev, which is definitely
not a pointer.  Instead, cast to uintptr_t so it becomes a non-pointer value
before casting it.

Tested: mips-gcc cross compile, mips32 build
(cherry picked from commit 6c88ef1c81fce18d6545c4ee8d0df32a25098770)

3 years agotftpd: tests: raise targeted cstd to c11
Kyle Evans [Thu, 5 Mar 2020 22:45:16 +0000 (22:45 +0000)]
tftpd: tests: raise targeted cstd to c11

r358556 added alignas() use to the functional tests, which isn't defined
until C11. Raise the -std to C11 to fix the build under freebsd-gcc{6,9}.

Reported by: mhorne, Jenkins/CI

(cherry picked from commit 924e10b809a9fcbc8688c1b5848f60b48e6103fe)

3 years agoAdd MODULE_PNP_INFO() to vmci(4). This allows devd(8) to load the
Hiroki Sato [Sun, 25 Aug 2019 18:46:10 +0000 (18:46 +0000)]
Add MODULE_PNP_INFO() to vmci(4).  This allows devd(8) to load the
kernel module automatically when FreeBSD is running on VMware.

Reviewed by: mp
Differential Revision: https://reviews.freebsd.org/D21182

(cherry picked from commit 639eac208771e9eb3d1141882514be35377abeee)

3 years agouplcom: add ATen/Prolific USB-232 Controller D USB ID
Ed Maste [Tue, 17 Nov 2020 18:28:20 +0000 (18:28 +0000)]
uplcom: add ATen/Prolific USB-232 Controller D USB ID

PR: 251166
Submitted by: marcus
MFC after: 2 weeks

(cherry picked from commit 46a5f8837dff05f6581b908170aeecb811f1e95e)

3 years agoUpdate GNU_DIFF knob descriptions
Ed Maste [Wed, 20 May 2020 17:20:48 +0000 (17:20 +0000)]
Update GNU_DIFF knob descriptions

After r317209 the WITH_/WITHOUT_GNU_DIFF knob controls only diff3;
diff is always BSD diff.

MFC after: 1 week

(cherry picked from commit e578c8c3b51fdfa8dd4eafd113457d516d447984)

3 years agoAdd some non-default src.conf(5) knob descriptions
Ed Maste [Wed, 21 Nov 2018 14:50:45 +0000 (14:50 +0000)]
Add some non-default src.conf(5) knob descriptions

Some WITH_/WITHOUT_ defaults will likey change in the future (e.g. as we
migrate to copyfree base system components).

Add non-default descriptions for the benefit of WIP branches.

(cherry picked from commit 0161256ccc89660285140ea2056441ec8e882831)

3 years agoLift scope of buf[] to make it extend to a potential access via *basename
Stefan EĂźer [Thu, 10 Dec 2020 09:31:05 +0000 (09:31 +0000)]
Lift scope of buf[] to make it extend to a potential access via *basename

It can be assumed that the contents of the buffer was still allocated and
valid at the point of the out-of-scope access, so there was no security
issue in practice.

(cherry picked from commit 7483b9e4dcfb4c444f8b5d54117fb6c8c48c20e9)

3 years agocrunchgen: fix NULL-deref bug introduced in r364647
Alex Richardson [Fri, 4 Dec 2020 15:53:37 +0000 (15:53 +0000)]
crunchgen: fix NULL-deref bug introduced in r364647

While porting over the local changes from CheriBSD for upstreaming, I
accidentally committed a broken version of find_entry_point(): we have to
return NULL if the value is not found instead of a value with
ep->name == NULL, since the checks in main were changed to check ep instead
of ep->name for NULL.

This only matters if the crunched tool cannot be found using normal lookup
and one of the fallback paths is used, so it's unlikely to be triggered
in rescue. However, I noticed that one of our CheriBSD test scripts was
failing to run commands under `su` on minimal disk images where all
binaries are hardlinks to a `cheribsdbox` tool generated with crunchgen.

This also updates the bootstrapping check in Makefile.inc1 to bootstrap
crunchgen up to the next version bump.

(cherry picked from commit f7ff7baaf62dd2e7b1f7b00c584cd4b968b4de1d)

3 years ago[rcorder] [crunch] Fix C function declarations to include void
Adrian Chadd [Mon, 21 Sep 2020 17:59:45 +0000 (17:59 +0000)]
[rcorder] [crunch] Fix C function declarations to include void

This fixes a compile issue under gcc6 which complains about
legacy style C function declarations.

(cherry picked from commit 0dcdda0984d779cd2024030535a7d270b18b273d)

3 years agosrc.conf(5): regenerate after GNU_GREP_COMPAT default change
Kyle Evans [Tue, 29 Dec 2020 15:58:21 +0000 (09:58 -0600)]
src.conf(5): regenerate after GNU_GREP_COMPAT default change

3 years agobuild: flip the bsdgrep default back to WITH_GNU_GREP_COMPAT
Kyle Evans [Tue, 29 Dec 2020 15:50:31 +0000 (09:50 -0600)]
build: flip the bsdgrep default back to WITH_GNU_GREP_COMPAT

libregex is a more functional provider of gnugrep compatibility.  Turn the
option back on by default for folks that opt to use bsdgrep.

This is a direct commit to stable/12, because the option was removed from
13.0 rather than cycling back through default-on.

3 years agobsdgrep: switch to libregex for GNU_GREP_COMPAT
Kyle Evans [Tue, 4 Aug 2020 02:47:24 +0000 (02:47 +0000)]
bsdgrep: switch to libregex for GNU_GREP_COMPAT

libregex is incomplete, but it's a bit less buggy than the in-base
libgnuregex and mostly OK.

While here, rename -DIWTH_GNU -> -DWITH_GNU_COMPAT; the option implies
that we're compatible with the GNU counterpart, not that we're including GNU
anything.

(cherry picked from commit cab7d341dcd98138443bbdb51649f966093a3a84)

3 years agolibi386: remove CLANG_NO_IAS workaround
Ed Maste [Sat, 20 Oct 2018 22:35:06 +0000 (22:35 +0000)]
libi386: remove CLANG_NO_IAS workaround

Clang's Integrated Assembler was previously disabled for i386 with the
note that it "doesn't grok .codeNN directives yet."  This is no longer
the case (and hasn't been for some time), and the assembled output .text
is identical between gas and IAS.

MFC after: 2 months
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 188b0da1ce6708f4168309f5b925f1c9df836bc7)

3 years agoMFC r368791: disk(9): Fix a few mandoc related errors
Gordon Bergling [Sat, 19 Dec 2020 09:55:02 +0000 (09:55 +0000)]
MFC r368791: disk(9): Fix a few mandoc related errors

- function name without markup: g_io_deliver()
- function name without markup: disk_gone()
- sections out of conventional order: Sh SEE ALSO
- referenced manual not found: Xr MAKE_DEV 9

Actually the man page of MAKE_DEV has never existed.

(cherry picked from commit 9512f75fa8608d150178116ad63672672331b5e8)

3 years agoMFC r360492 (by bcr):
Benedict Reuschling [Thu, 30 Apr 2020 11:17:29 +0000 (11:17 +0000)]
MFC r360492 (by bcr):

Add HISTORY sections to disk(9), driver(9), and epoch(9).

Submitted by: gbergling_gmail.com
Differential Revision: https://reviews.freebsd.org/D24243

(cherry picked from commit 8c63b2db53862c523bc2cb3f7c4d0243018eb3de)

3 years agoMFC r339889 (by glebius):
Gleb Smirnoff [Mon, 29 Oct 2018 22:10:52 +0000 (22:10 +0000)]
MFC r339889 (by glebius):

Add a note that epoch(9) may change, to untie our hands for any future MFCs.

Approved by: glebius

(cherry picked from commit 24929e2cccdc62b19edb66d5f71c62562a051c8c)

3 years agoMFC r368182:
Hans Petter Selasky [Mon, 30 Nov 2020 09:47:53 +0000 (09:47 +0000)]
MFC r368182:
Use function macro for sema_init() in the LinuxKPI to limit macro expansion scope.

Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoMFC r368406:
Hans Petter Selasky [Mon, 7 Dec 2020 09:48:06 +0000 (09:48 +0000)]
MFC r368406:
Prefer using the MIN() function macro over the min() inline function
in the LinuxKPI. Linux defines min() to be a macro, while in FreeBSD
min() is a static inline function clamping its arguments to
"unsigned int".

Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoMFC r368415:
Hans Petter Selasky [Mon, 7 Dec 2020 16:08:31 +0000 (16:08 +0000)]
MFC r368415:
Properly define the bool type in the BSD kernel shim.

Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoMFC r368329 and r368341:
Hans Petter Selasky [Fri, 4 Dec 2020 14:50:55 +0000 (14:50 +0000)]
MFC r368329 and r368341:
Fix definition of int64_t and uint64_t when long is 64-bit. This gets the kernel
shim code in line with the rest of the kernel, sys/x86/include/_types.h.

Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoMFC r368659 and r368664:
Hans Petter Selasky [Tue, 15 Dec 2020 12:05:07 +0000 (12:05 +0000)]
MFC r368659 and r368664:
Improve handling of alternate settings in the USB stack.

Allow setting the alternate interface number to fail when there is only
one alternate setting present, to comply with the USB specification.

Refactor how iface->num_altsetting is computed.

Bump the __FreeBSD_version due to change of core USB structure.

PR: 251856
Submitted by: Ma, Horse <Shichun.Ma@dell.com>
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoMFC r368658:
Hans Petter Selasky [Tue, 15 Dec 2020 11:51:17 +0000 (11:51 +0000)]
MFC r368658:
Improve handling of alternate settings in the USB stack.

Limit the number of alternate settings to 256.
Else the alternate index variable may wrap around.

PR: 251856
Submitted by: Ma, Horse <Shichun.Ma@dell.com>
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoMFC r368632:
Hans Petter Selasky [Mon, 14 Dec 2020 11:56:16 +0000 (11:56 +0000)]
MFC r368632:
Be bug compatible with other operating systems by allowing non-sequential
interface numbering for USB descriptors in userspace. Else certain USB
control requests using the interface number, won't be recognized by the
USB firmware.

Refer to section 9.2.3 in the USB 2.0 specification:
Interfaces are numbered from zero to one less than the number of concurrent interfaces
supported by the configuration.

PR: 251784
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agotools/tools/locale: skip control character widths
Yuri Pankov [Wed, 23 Dec 2020 12:49:25 +0000 (15:49 +0300)]
tools/tools/locale: skip control character widths

Do not explicitly encode control characters widths as 0
allowing wcwidth() to return the proper implicit value for
non-printable characters (-1).

Reported by: naddy

(cherry picked from commit f952bdf1425d6a877f99b5c5ca59f25fc8bedabe)

3 years agolibregex: implement GNU extensions
Kyle Evans [Tue, 4 Aug 2020 02:14:51 +0000 (02:14 +0000)]
libregex: implement GNU extensions

18a1e2e9: 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.

61898cde: 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.

7518fb34: libc: regex: factor out ISBOW/ISEOW macros

These will be reused for \b (word boundary, which matches both sides).

No functional change.

ca53e5ae: libregex: implement \` and \' (begin-of-subj, end-of-subj)

These are GNU extensions, generally equivalent to ^ and $ except that the
new syntax will not match beginning of line after the first in a multi-line
expression or the end of line before absolute last in a multi-line
expression.

6b986646: libregex: implement \b and \B (word boundary, not word boundary)

This is the last of the needed GNU expressions before we can unleash bsdgrep
by default. \b is effectively an agnostic equivalent of \< and \>, while
\B will match every space that isn't making a transition from
nonchar -> char or char -> nonchar.

4afa7dd6: libc: regex: retire internal EMPTBR ("Empty branch present")

It was realized just a little too late that this was a hack that belonged in
individual regex(3)-using applications. It was surrounded in NOTYET and not
implemented in the engine, so remove it.

4f1efa30: libc: regex: partial revert of r368358 (6b986646)

MFC NOTE: Altered to match the legacy behavior of a\bc => abc.

Part of the libregex functionality leaked into the tests it shares with
the standard regex(3). Introduce a P flag to set the REG_POSIX cflag to
indicate that libc regex should effectively do nothing while libregex should
specifically run it in non-extended mode.

This unbreaks the libc/regex test run.

(cherry picked from commit 18a1e2e9b9f109a78c5a9274e4cfb4777801b4fb)
(cherry picked from commit 61898cde69374d5a9994e2074605bc4101aff72d)
(cherry picked from commit 7518fb346fe9603f99d2406a073b30fb8e4a270c)
(cherry picked from commit ca53e5aedfebcc1b4091b68e01b2d5cae923f85e)
(cherry picked from commit 6b986646d434baa21ae3d74d6a662ad206c7ddbd)
(cherry picked from commit 4afa7dd61a3a1454a5b3cf5e6de2029c7e2d9a84)
(cherry picked from commit 4f1efa309ca48a088595dd57969ae6a397dd49d1)

3 years agoregex(3): Interpret many escaped ordinary characters as EESCAPE
Kyle Evans [Wed, 29 Jul 2020 23:21:56 +0000 (23:21 +0000)]
regex(3): Interpret many escaped ordinary characters as EESCAPE

MFC NOTE: This only merged the infrastructure back, the new regcomp symbol
that actually interprets these as EESCAPE was *dropped*. This is purely to
make future commits for libregex easier to merge back so that we can choose
to use it.

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/

(cherry picked from commit adeebf4cd47c3e85155d92f386bda5e519b75ab2)

3 years ago<regex.h>: reserve a regcomp field for REG_POSIX
Kyle Evans [Fri, 31 Jul 2020 12:40:31 +0000 (12:40 +0000)]
<regex.h>: reserve a regcomp field for REG_POSIX

For libc regcomp, this will be a nop. libregex will take this to mean that
it needs to turn off GNU extensions, effectively switching it back to the
POSIX-compliant libc implementation at runtime.

(cherry picked from commit 7c5ec5fe6afb50ba5c83ad0b3dab036f91b7dafe)

3 years agoregex(3): belatedly document REG_POSIX from r363734
Kyle Evans [Tue, 4 Aug 2020 02:06:49 +0000 (02:06 +0000)]
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.

(cherry picked from commit ba8b64de05d0df84ad9064be950ca38bc7bafe7d)

3 years agolib/libc/regex: fix build with REDEBUG defined
Yuri Pankov [Tue, 24 Sep 2019 12:21:01 +0000 (12:21 +0000)]
lib/libc/regex: fix build with REDEBUG defined

(cherry picked from commit 3c78771400e74f5bc54ee8e9a28fbf70190fd250)

3 years agogrep: replace the internal queue with a ring buffer
Kyle Evans [Wed, 9 Dec 2020 05:27:45 +0000 (05:27 +0000)]
grep: replace the internal queue with a ring buffer

We know up front how many items we can have in the queue (-B/Bflag), so
pay the cost of those particular allocations early on.

The reduced queue maintenance overhead seemed to yield about an ~8%
improvement for my earlier `grep -C8 -r closefrom .` test.

(cherry picked from commit df546c3b730d4abcace1da24226bd5f01280588e)

3 years agoMFC kern: cpuset: properly rebase when attaching to a jail
Kyle Evans [Wed, 25 Nov 2020 03:14:25 +0000 (03:14 +0000)]
MFC kern: cpuset: properly rebase when attaching to a jail

The current logic is a fine choice for a system administrator modifying
process cpusets or a process creating a new cpuset(2), but not ideal for
processes attaching to a jail.

Currently, when a process attaches to a jail, it does exactly what any other
process does and loses any mask it might have applied in the process of
doing so because cpuset_setproc() is entirely based around the assumption
that non-anonymous cpusets in the process can be replaced with the new
parent set.

This approach slightly improves the jail attach integration by modifying
cpuset_setproc() callers to indicate if they should rebase their cpuset to
the indicated set or not (i.e. cpuset_setproc_update_set).

If we're rebasing and the process currently has a cpuset assigned that is
not the containing jail's root set, then we will now create a new base set
for it hanging off the jail's root with the existing mask applied instead of
using the jail's root set as the new base set.

Note that the common case will be that the process doesn't have a cpuset
within the jail root, but the system root can freely assign a cpuset from
a jail to a process outside of the jail with no restriction. We assume that
that may have happened or that it could happen due to a race when we drop
the proc lock, so we must recheck both within the loop to gather up
sufficient freed cpusets and after the loop.

To recap, here's how it worked before in all cases:

0     4 <-- jail              0      4 <-- jail / process
|                             |
1                 ->          1
|
3 <-- process

Here's how it works now:

0     4 <-- jail             0       4 <-- jail
|                            |       |
1                 ->         1       5 <-- process
|
3 <-- process

or

0     4 <-- jail             0       4 <-- jail / process
|                            |
1 <-- process     ->         1

More importantly, in both cases, the attaching process still retains the
mask it had prior to attaching or the attach fails with EDEADLK if it's
left with no CPUs to run on or the domain policy is incompatible. The
author of this patch considers this almost a security feature, because a MAC
policy could grant PRIV_JAIL_ATTACH to an unprivileged user that's
restricted to some subset of available CPUs the ability to attach to a jail,
which might lift the user's restrictions if they attach to a jail with a
wider mask.

In most cases, it's anticipated that admins will use this to be able to,
for example, `cpuset -c -l 1 jail -c path=/ command=/long/running/cmd`,
and avoid the need for contortions to spawn a command inside a jail with a
more limited cpuset than the jail.

(cherry picked from commit d431dea5ac2aaab012f90182cf7ca13cc6dde5ea)

3 years agoMFC lualoader: module-manipulation commands
Kyle Evans [Sat, 12 Dec 2020 05:57:42 +0000 (05:57 +0000)]
MFC lualoader: module-manipulation commands

4634bb1f: lualoader: provide module-manipulation commands

Specifically, we have:
- enable-module
- disable-module
- toggle-module

These can be used to add/remove modules to be loaded or force modules to be
loaded in spite of modules_blacklist. In the typical case, a user is
expected to use them to recover an issue happening due to a module directive
they've added to their loader.conf or because they discover that they've
under-specified what to load.

10aeb6cd: lualoader: config: fix module enabled check

A last minute rewrite left this logically wrong; if it's present in
modules_blacklist, then we do not load it.

7ed84fa1: lualoader: cli: provide a show-module-options loader command

This effectively dumps everything lualoader knows about to the console using
the libsa pager; that particular lua interface was added in r368591.

A pager stub implementation has been added that just dumps the output as-is
as a compat shim for older loader binaries that do not have lpager. This
stub should be moved into a more appropriate .lua file if we add anything
else that needs the pager.

(cherry picked from commit 4634bb1f4052ff5f1c0a423fd8cce11396ca7fd2)
(cherry picked from commit 10aeb6cdab8fb09e2cc3ee2d8b2c68c395481c23)
(cherry picked from commit 7ed84fa14b00cdacfe9b43019cba7a14b33af352)

3 years agoMFC: stand: liblua: add a pager module
Kyle Evans [Sat, 12 Dec 2020 21:25:38 +0000 (21:25 +0000)]
MFC: stand: liblua: add a pager module

This is nearly a 1:1 mapping of the pager API from libsa.  The only real
difference is that pager.output() will accept any number of arguments and
coerce all of them to strings for output using luaL_tolstring (i.e. the
__tostring metamethod will be used).

The only consumer planned at this time is the upcoming "show-module-options"
implementation.

(cherry picked from commit 0a0d522b368b31ec51611b798047a75b52855f39)

3 years agoMFC kern: cpuset: allow jails to modify child jails' roots
Kyle Evans [Sat, 19 Dec 2020 03:30:06 +0000 (03:30 +0000)]
MFC kern: cpuset: allow jails to modify child jails' roots

This partially lifts a restriction imposed by r191639 ("Prevent a superuser
inside a jail from modifying the dedicated root cpuset of that jail") that's
perhaps beneficial after r192895 ("Add hierarchical jails."). Jails still
cannot modify their own cpuset, but they can modify child jails' roots to
further restrict them or widen them back to the modifying jails' own mask.

As a side effect of this, the system root may once again widen the mask of
jails as long as they're still using a subset of the parent jails' mask.
This was previously prevented by the fact that cpuset_getroot of a root set
will return that root, rather than the root's parent -- cpuset_modify uses
cpuset_getroot since it was introduced in r327895, previously it was just
validating against set->cs_parent which allowed the system root to widen
jail masks.

PR: 240687
(cherry picked from commit 54a837c8cca109ad0d7ecb4b93379086f6f49275)

3 years agoMFC freebsd-update: unconditionally regenerate passwd/login.conf files
Kyle Evans [Thu, 17 Dec 2020 03:42:54 +0000 (03:42 +0000)]
MFC freebsd-update: unconditionally regenerate passwd/login.conf files

The existing logic is nice in theory, but in practice freebsd-update will
not preserve the timestamps on these files. When doing a major upgrade, e.g.
from 12.1-RELEASE -> 12.2-RELEASE, pwd.mkdb et al. appear in the INDEX and
we clobber the timestamp several times in the process of packaging up the
existing system into /var/db/freebsd-update/files and extracting for
comparisons. This leads to these files not getting regenerated when they're
most likely to be needed.

Measures could be taken to preserve timestamps, but it's unclear whether
the complexity and overhead of doing so is really outweighed by the marginal
benefit.

I observed this issue when pkg subsequently failed to install a package that
wanted to add a user, claiming that the user was removed in the process.
bapt@ pointed to this pre-existing bug with freebsd-update as the cause.

PR: 234014, 232921

(cherry picked from commit ebebc41e4cfe44b8e8fd881badf2fa2c4be65aa4)

3 years agoMFC r368794: driver(9): Fix a mandoc related issue
Gordon Bergling [Sat, 19 Dec 2020 10:18:21 +0000 (10:18 +0000)]
MFC r368794: driver(9): Fix a mandoc related issue

- sections out of conventional order: Sh SEE ALSO

(cherry picked from commit f37f378d35710da29463f0346deafe6eeb7648ea)

3 years agoMFC r368809: config: Fix a few mandoc related errors
Gordon Bergling [Sat, 19 Dec 2020 13:11:44 +0000 (13:11 +0000)]
MFC r368809: config: Fix a few mandoc related errors

- new sentence, new line
- no blank before trailing delimiter

(cherry picked from commit aeb0c721f5ce785d954c35d2609748e9cb8dd2d0)

3 years agoMFC r368800: devd.conf(5): Fix a mandoc related issue
Gordon Bergling [Sat, 19 Dec 2020 11:03:04 +0000 (11:03 +0000)]
MFC r368800: devd.conf(5): Fix a mandoc related issue

- sections out of conventional order: Sh SEE ALSO

(cherry picked from commit 226f43e757ff7a0f945f9deb0fb1481a752274bc)

3 years agoMFC r368816: trim(8): Fix a few issues reported by mandoc
Gordon Bergling [Sat, 19 Dec 2020 13:56:19 +0000 (13:56 +0000)]
MFC r368816: trim(8): Fix a few issues reported by mandoc

- new sentence, new line
- unusual Xr order: ioctl(2) after da(4)
- unusual Xr order: sysexits(3) after nda(4)

(cherry picked from commit a652079615ac3cb503e516e50246284bb4ad60eb)

3 years agoMFC r368815: zonectl(8): Fix a few issues reported by mandoc
Gordon Bergling [Sat, 19 Dec 2020 13:51:46 +0000 (13:51 +0000)]
MFC r368815: zonectl(8): Fix a few issues reported by mandoc

- Add missing quotation mark for a comment above the .Dd
- inserting missing end of block: Sh breaks Bd
- skipping paragraph macro: Pp before Bl
- skipping paragraph macro: Pp before Bd
- empty block: Bd

(cherry picked from commit 8ef235787bcf90735e76bd476084f1ff016b7619)

3 years agoMFC r368796: ofw_bus_is_compatible(9): Fix a few mandoc related issues
Gordon Bergling [Sat, 19 Dec 2020 10:24:36 +0000 (10:24 +0000)]
MFC r368796: ofw_bus_is_compatible(9): Fix a few mandoc related issues

- missing comma before name: Nm ofw_bus_is_compatible_strict
- missing comma before name: Nm ofw_bus_node_is_compatible
- missing comma before name: Nm ofw_bus_search_compatible
- skipping paragraph macro: Pp after Sh

(cherry picked from commit 8bf0ef84d9c1aef72ba64f4dcbebb2a38edcf183)

3 years agoMFC r368814: nfsv4(4): Fix a few issues reported by mandoc
Gordon Bergling [Sat, 19 Dec 2020 13:45:39 +0000 (13:45 +0000)]
MFC r368814: nfsv4(4): Fix a few issues reported by mandoc

- new sentence, new line
- function name without markup: rtalloc()
- function name without markup: VOP_RECLAIM()

(cherry picked from commit 749ddf491b4370300a2edbd47aed9ee1b5d71178)

3 years agoMFC r368812: mpsutil(8): Remove trailing whitespace
Gordon Bergling [Sat, 19 Dec 2020 13:23:26 +0000 (13:23 +0000)]
MFC r368812: mpsutil(8): Remove trailing whitespace

(cherry picked from commit 84572415b4b55354811282cbc184f4a46f6952a1)

3 years agoMFC r368813: bluetooth: Fix a mandoc related issues
Gordon Bergling [Sat, 19 Dec 2020 13:36:59 +0000 (13:36 +0000)]
MFC r368813:  bluetooth: Fix a mandoc related issues

- new sentence, new line
- sections out of conventional order: Sh FILES
- unusual Xr order: bthost(1) after bthidd(8)
- no blank before trailing delimiter
- whitespace at end of input line
- sections out of conventional order: Sh EXIT STATUS

(cherry picked from commit 60ee05db4b19763137c399a0d79509af14e7440a)

3 years agoMFC r368797: ofw_bus_status_okay(9): Fix a few mandoc related issues
Gordon Bergling [Sat, 19 Dec 2020 10:26:40 +0000 (10:26 +0000)]
MFC r368797: ofw_bus_status_okay(9): Fix a few mandoc related issues

- missing comma before name: Nm ofw_bus_status_okay
- missing comma before name: Nm ofw_bus_node_status_okay
- skipping paragraph macro: Pp after Sh

(cherry picked from commit 0492f4030d2bd657fe9831ddf2a1e4b6204e4840)