]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agoUse uintptr_t instead of unsigned long for pointers.
John Baldwin [Wed, 16 Dec 2020 00:13:32 +0000 (00:13 +0000)]
Use uintptr_t instead of unsigned long for pointers.

The sense_ptr thing is quite broken.  As near as I can tell, the
driver tries to copyout to a physical address rather than whatever
user address the sense buffer should be copied to.  It is not
immediately obvious what user address the sense buffer should be
copied to.

Reviewed by: imp
Obtained from: CheriBSD
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D27578

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.

Reviewed by: imp
Obtained from: CheriBSD
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D27576

3 years agoloader: allow loader to accept zfs feature com.delphix:bookmark_written
Toomas Soome [Tue, 15 Dec 2020 22:37:03 +0000 (22:37 +0000)]
loader: allow loader to accept zfs feature com.delphix:bookmark_written

We do not need to actually read bookmarks, just whitelist this feature.

Reported by: mjg

3 years agoloader: allow loader to accept zfs feature com.datto:bookmark_v2
Toomas Soome [Tue, 15 Dec 2020 21:48:35 +0000 (21:48 +0000)]
loader: allow loader to accept zfs feature com.datto:bookmark_v2

We do not need to actually read bookmarks, just whitelist this feature

Reported by: jpaetzel

3 years agoBugfix to not hide jailparam flags, which for example changes the output
Jamie Gritton [Tue, 15 Dec 2020 20:56:35 +0000 (20:56 +0000)]
Bugfix to not hide jailparam flags, which for example changes the output
"vnet=2" to the less opaque "vnet=inherit"

Reported by: kevans
MFC after: 5 days

3 years agoRevert r368523 which fixed contig allocs waiting forever.
Bryan Drewery [Tue, 15 Dec 2020 19:38:16 +0000 (19:38 +0000)]
Revert r368523 which fixed contig allocs waiting forever.

This needs to account for empty NUMA domains or domains which do not
satisfy the requested range.

Discussed with: markj

3 years agohme(4): remove stray directories
Brooks Davis [Tue, 15 Dec 2020 18:46:23 +0000 (18:46 +0000)]
hme(4): remove stray directories

Sponsored by:  DARPA
Differential Revision: https://reviews.freebsd.org/D27526

3 years agoRemove Doxyfiles for removed drivers
Brooks Davis [Tue, 15 Dec 2020 18:44:41 +0000 (18:44 +0000)]
Remove Doxyfiles for removed drivers

Reported by: emaste

3 years agoRemove additional GDB leftovers missed in r368667
Ed Maste [Tue, 15 Dec 2020 18:12:03 +0000 (18:12 +0000)]
Remove additional GDB leftovers missed in r368667

3 years agoAdd relnote for r368667, GDB 6.1.1 removal
Ed Maste [Tue, 15 Dec 2020 17:52:04 +0000 (17:52 +0000)]
Add relnote for r368667, GDB 6.1.1 removal

3 years agoRetire obsolete GDB 6.1.1
Ed Maste [Tue, 15 Dec 2020 17:44:19 +0000 (17:44 +0000)]
Retire obsolete GDB 6.1.1

GDB 6.1.1 was released in June 2004 and is long obsolete. It does not
support all of the architectures that FreeBSD does, and imposes
limitations on the FreeBSD kernel build, such as the continued use of
DWARF2 debugging information.

It was kept (in /usr/libexec/) only for use by crashinfo(8), which
extracts some basic information from a kernel core dump after a crash.
Crashinfo already prefers gdb from port/package if installed.

Future work may add kernel debug support to LLDB or find another path
for crashinfo's needs, but in any case we do not want to ship the
excessively outdated GDB in FreeBSD 13.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27610

3 years agoImprove handling of alternate settings in the USB stack.
Hans Petter Selasky [Tue, 15 Dec 2020 15:36:41 +0000 (15:36 +0000)]
Improve handling of alternate settings in the USB stack.

Move initialization of num_altsetting under USB_CFG_INIT, else
there will be a page fault when enumerating USB devices.

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

3 years agorelease: Rename arm64/RPI3.conf to arm64/RPI.conf
Emmanuel Vadot [Tue, 15 Dec 2020 15:13:06 +0000 (15:13 +0000)]
release: Rename arm64/RPI3.conf to arm64/RPI.conf

We now have a u-boot port and config.txt for booting on all 64bits
variant of the RPI boards (RPI2v1.1, RPI3* and RPI4*) so use
the new u-boot-rpi-arm64 and the config_arm64.txt files.

Discussed with: karels, kevans

3 years agoImprove handling of alternate settings in the USB stack.
Hans Petter Selasky [Tue, 15 Dec 2020 12:05:07 +0000 (12:05 +0000)]
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
MFC after: 1 week
Submitted by: Ma, Horse <Shichun.Ma@dell.com>
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoImprove handling of alternate settings in the USB stack.
Hans Petter Selasky [Tue, 15 Dec 2020 11:51:17 +0000 (11:51 +0000)]
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
MFC after: 1 week
Submitted by: Ma, Horse <Shichun.Ma@dell.com>
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoWhen receiving a file having a length, which is a mulitple of the blocksize,
Michael Tuexen [Tue, 15 Dec 2020 09:43:18 +0000 (09:43 +0000)]
When receiving a file having a length, which is a mulitple of the blocksize,
close the file once it is received.

Reported by: Timo Voelker
MFC after: 1 week

3 years agoRemove more cx,ctau leftovers
Ed Maste [Tue, 15 Dec 2020 01:45:19 +0000 (01:45 +0000)]
Remove more cx,ctau leftovers

Missed in r359178

3 years agoFix LINT-NOINET6 build after r368571.
Alexander V. Chernikov [Mon, 14 Dec 2020 22:54:32 +0000 (22:54 +0000)]
Fix LINT-NOINET6 build after r368571.

Reported by: mjg

3 years agoamd64 pmap: fix PCID mode invalidations
Konstantin Belousov [Mon, 14 Dec 2020 22:52:29 +0000 (22:52 +0000)]
amd64 pmap: fix PCID mode invalidations

When r362031 moved local TLB invalidation after shootdown IPI send, it
moved too much.  In particular, PCID-mode clearing of the pm_gen
generation counters must occur before IPIs are send, which is in fact
described by the comment before seq_cst fence in the invalidation
functions.

Fix it by extracting pm_gen clearing into new helper
pmap_invalidate_preipi(), which is executed before a call to
smp_masked_tlb_shootdown().

Rest of the local invalidation callbacks is simplified as result, and
become very similar to the remote shootdown handlers (to be merged in
some future).

Move pin of the thread to pmap_invalidate_preipi(), and do unpin in
smp_masked_tlb_shootdown().

Reported and tested by: mjg (previous version)
Reviewed by: alc, cem (previous version), markj
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D227588

3 years agoEnable ROUTE_MPATH support in GENERIC kernels.
Alexander V. Chernikov [Mon, 14 Dec 2020 22:23:08 +0000 (22:23 +0000)]
Enable ROUTE_MPATH support in GENERIC kernels.

Ability to load-balance traffic over multiple path is a must-have thing for routers.
It may be used by the servers to balance outgoing traffic over multiple default gateways.

The previous implementation, RADIX_MPATH stayed in the shadow for too long.
It was not well maintained, which lead us to a vicious circle - people were using
 non-contiguous mask or firewalls to achieve similar goals. As a result, some routing
 daemons implementation still don't have multipath support enabled for FreeBSD.

Turning on ROUTE_MPATH by default would fix it. It will allow to reduce networking
 feature gap to other operating systems. Linux and OpenBSD enabled similar support
 at least 5 years ago.

ROUTE_MPATH does not consume memory unless actually used. It enables around ~1k LOC.

It does not bring any behaviour changes for userland.
Additionally, feature is (temporarily) turned off by the net.route.multipath sysctl
 defaulting to 0.

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

3 years agoImprove the counting of blocks used to transfer a file from the
Michael Tuexen [Mon, 14 Dec 2020 22:13:58 +0000 (22:13 +0000)]
Improve the counting of blocks used to transfer a file from the
server to the client in case of not using an OACK: Don't miss
the first block in case of it is not also the last one.

MFC after: 1 week

3 years agoRemove unused functions and variables in cpufunc.[ch].
Michal Meloun [Mon, 14 Dec 2020 14:00:54 +0000 (14:00 +0000)]
Remove unused functions and variables in cpufunc.[ch].

3 years agoFinish implementation of ARM PMU interrupts.
Michal Meloun [Mon, 14 Dec 2020 13:10:19 +0000 (13:10 +0000)]
Finish implementation of ARM PMU interrupts.
The ARM PMU may use single per-core interrupt or may use multiple generic
interrupts, one per core. In this case, special attention must be paid to
the correct identification of the physical location of the core, its order
in the external database (FDT) and the associated cpuid.

Also keep in mind that a SoC can have multiple different PMUs
(usually one per cluster)

3 years agoVerify (and fix) the context_id argument passed to the mpentry () by PSCI.
Michal Meloun [Mon, 14 Dec 2020 11:57:43 +0000 (11:57 +0000)]
Verify (and fix) the context_id argument passed to the mpentry () by PSCI.

Some older PSCI implementations corrupt (or do not pass) the context_id
argument to newly started secondary cores. Although the ideal solution to this
problem is u-boot update, we can find the correct value for the argument (cpuid)
by comparing of real core mpidr register with the value stored in pcu->mpidr.

MFC after: 2 weeks

3 years agoBe bug compatible with other operating systems by allowing non-sequential
Hans Petter Selasky [Mon, 14 Dec 2020 11:56:16 +0000 (11:56 +0000)]
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
MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoloader: Ignore the .interp section on RISC-V
Jessica Clarke [Mon, 14 Dec 2020 00:54:05 +0000 (00:54 +0000)]
loader: Ignore the .interp section on RISC-V

Without this we risk having the .interp section be placed earlier in the
file and mess with section offsets; in particular it has been seen to be
placed at the start of the file and cause the PE/COFF header to not be
at address 0. This is the same fix as was done for arm64 in r365578.

Reviewed by: mhorne, imp
Approved by: mhorne, imp
Differential Revision: https://reviews.freebsd.org/D27603

3 years agostrdup.3: Function appeared in 4.3BSD-Reno, not 4.4BSD
Jessica Clarke [Mon, 14 Dec 2020 00:50:45 +0000 (00:50 +0000)]
strdup.3: Function appeared in 4.3BSD-Reno, not 4.4BSD

Linux claims 4.3BSD, we claim 4.4BSD and OpenBSD claims 4.3BSD-Reno. It turns
out that OpenBSD got it right: the function was added in late 1988 a few months
after 4.3BSD-Tahoe, well in advance of 4.3BSD-Reno.

Reviewed by: bcr
Approved by: bcr
Differential Revision: https://reviews.freebsd.org/D27392

3 years agomips: Fix sub-word atomics implementation
Jessica Clarke [Mon, 14 Dec 2020 00:47:59 +0000 (00:47 +0000)]
mips: Fix sub-word atomics implementation

These aligned the address but then always used the least significant
bits of the value in memory, which is the wrong half 50% of the time for
16-bit atomics and the wrong quarter 75% of the time for 8-bit atomics.
These bugs were all present in r178172, the commit that added the mips
port, and have remained for its entire existence to date.

Reviewed by: jhb (mentor)
Approved by: jhb (mentor)
Differential Revision: https://reviews.freebsd.org/D27343

3 years agoloader: Print autoboot countdown immediately, not at 9
Jessica Clarke [Mon, 14 Dec 2020 00:46:24 +0000 (00:46 +0000)]
loader: Print autoboot countdown immediately, not at 9

For the first second otime and ntime are equal so no message gets
printed. Instead we should print the countdown right from the start,
although we do it at the end of the first iteration so that if a key has
already been pressed then the message is suppressed.

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

3 years agoHarden the handling of outgoing streams in case of an restart or INIT
Michael Tuexen [Sun, 13 Dec 2020 23:51:51 +0000 (23:51 +0000)]
Harden the handling of outgoing streams in case of an restart or INIT
collision. This avouds an out-of-bounce access in case the peer can
break the cookie signature. Thanks to Felix Wilhelm from Google for
reporting the issue.

MFC after: 1 week

3 years agouipc: disable prediction in unp_pcb_lock_peer
Mateusz Guzik [Sun, 13 Dec 2020 21:32:19 +0000 (21:32 +0000)]
uipc: disable prediction in unp_pcb_lock_peer

The branch is not very predictable one way or the other, at least during
buildkernel where it only correctly matched 57% of calls.

3 years agoPatch annotation in sigdeferstop
Mateusz Guzik [Sun, 13 Dec 2020 21:30:42 +0000 (21:30 +0000)]
Patch annotation in sigdeferstop

Probability flipped since sigdefer handling was moved away from regular VOP
calls.

3 years agocache: fix ups bad predicts
Mateusz Guzik [Sun, 13 Dec 2020 21:29:39 +0000 (21:29 +0000)]
cache: fix ups bad predicts

- last level fallback normally sees CREATE; the code should be optimized to not
get there for said case
- fast path commonly fails with ENOENT

3 years agovfs: correctly predict last fdrop on failed open
Mateusz Guzik [Sun, 13 Dec 2020 21:28:15 +0000 (21:28 +0000)]
vfs: correctly predict last fdrop on failed open

Arguably since the count is guaranteed to be 1 the code should be modified
to avoid the work.

3 years agoFix TDP_WAKEUP/thr_wake(curthread->td_tid) after r366428.
Konstantin Belousov [Sun, 13 Dec 2020 19:45:42 +0000 (19:45 +0000)]
Fix TDP_WAKEUP/thr_wake(curthread->td_tid) after r366428.

Reported by: arichardson
Reviewed by: arichardson, markj
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D27597

3 years agoCorrect indent.
Konstantin Belousov [Sun, 13 Dec 2020 19:43:45 +0000 (19:43 +0000)]
Correct indent.

Sponsored by: The FreeBSD Foundation

3 years agoFix WITHOUT_ICONV build
Stefan Eßer [Sun, 13 Dec 2020 19:06:59 +0000 (19:06 +0000)]
Fix WITHOUT_ICONV build

Move the include of langinfo.h out of the WITH_ICONV condition block,
since it is not dependent on ICONV. This was correct when nl_langinfo()
had only been called in the WITH_ICONV case, but that is no longer the
case.

Submitted by: yuripv

3 years agoRevert r368606
Stefan Eßer [Sun, 13 Dec 2020 19:03:38 +0000 (19:03 +0000)]
Revert r368606

The issue will be fixed in a different way.

Reported by: yuripv

3 years agofd: fix fdrop prediction when closing a fd
Mateusz Guzik [Sun, 13 Dec 2020 18:06:24 +0000 (18:06 +0000)]
fd: fix fdrop prediction when closing a fd

Most of the time this is the last reference, contrary to typical fdrop use.

3 years agoMFV r368607:
Martin Matuska [Sun, 13 Dec 2020 16:26:37 +0000 (16:26 +0000)]
MFV r368607:
Sync libarchive with vendor.

Vendor changes:
  Issue #1461: Unbreak build without lzma
  Issue #1462: warc reader: Fix build with gcc11
  Issue #1463: Fix code compatibility in test_archive_read_support.c
  Issue #1464: Use built-in strnlen on platforms where not available
  Issue #1465: warc reader: fix undefined behaviour in deconst() function

MFC after: 3 days
X-MFC-With: 368234

3 years agoUpdate vendor/libarchive/dist to b2c3ee7e2907511533eeb2a0f2ceecc1faa73185
Martin Matuska [Sun, 13 Dec 2020 15:29:19 +0000 (15:29 +0000)]
Update vendor/libarchive/dist to b2c3ee7e2907511533eeb2a0f2ceecc1faa73185

Vendor changes:
  Issue #1461: Unbreak build without lzma
  Issue #1462: warc reader: Fix build with gcc11
  Issue #1463: Fix code compatibility in test_archive_read_support.c
  Issue #1464: Use built-in strnlen on platforms where not available
  Issue #1465: warc reader: fix undefined behaviour in deconst() function

3 years agoFix WITHOUT_ICONV build
Stefan Eßer [Sun, 13 Dec 2020 09:38:50 +0000 (09:38 +0000)]
Fix WITHOUT_ICONV build

There was an unprotected use of nl_langinfo() to determine the order of
day vs. month in the generated output.

When building without ICONV support, the order will be: month, day.

3 years ago[PowerPC] Floating-point exception trap followup
Brandon Bergren [Sun, 13 Dec 2020 03:58:43 +0000 (03:58 +0000)]
[PowerPC] Floating-point exception trap followup

* Fix incorrect operation on 32-bit caused by incorrectly-sized storage
  for a temporary FPSCR.
* Fix several whitespace problems.
* Don't try to enable VSX during cleanup_fpscr().

Reviewed by: alfredo, jhibbits (earlier version)
Sponsored by: Tag1 Consulting, Inc.
Differential Revision: https://reviews.freebsd.org/D27453

3 years agolocale: fix mode for installed files to be 644, not 755
Yuri Pankov [Sat, 12 Dec 2020 23:41:47 +0000 (23:41 +0000)]
locale: fix mode for installed files to be 644, not 755

While here, drop '-c' flag to install as it's default and provided for
backward compatibility only.

3 years agoClean up more resouces of an existing SCTP association in case of
Michael Tuexen [Sat, 12 Dec 2020 22:23:45 +0000 (22:23 +0000)]
Clean up more resouces of an existing SCTP association in case of
a restart.

This fixes a use-after-free scenario, which was reported by Felix
Wilhelm from Google in case a peer is able to modify the cookie.
However, this can also be triggered by an assciation restart under
some specific conditions.

MFC after: 1 week

3 years agostand: liblua: add a pager module
Kyle Evans [Sat, 12 Dec 2020 21:25:38 +0000 (21:25 +0000)]
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.

MFC after: 1 week

3 years agopf: Allow net.pf.request_maxcount to be set from loader.conf
Kristof Provost [Sat, 12 Dec 2020 20:14:39 +0000 (20:14 +0000)]
pf: Allow net.pf.request_maxcount to be set from loader.conf

Mark request_maxcount as RWTUN so we can set it both at runtime and from
loader.conf. This avoids usings getting caught out by the change from tunable
to run time configuration.

Suggested by: Franco Fichtner
MFC after: 3 days

3 years agoamdtemp(4): Add missing Family 17h models
Conrad Meyer [Sat, 12 Dec 2020 19:43:38 +0000 (19:43 +0000)]
amdtemp(4): Add missing Family 17h models

Add missing model numbers M20h (Dali, Zen1), M60H (Renoir, Zen2), and
M90H (Van Gogh, Zen2).

Submitted by: Greg V <greg AT unrelenting.technology>

3 years agoamdsmn(4), amdtemp(4): add support for Family 19h (Zen 3)
Conrad Meyer [Sat, 12 Dec 2020 19:34:12 +0000 (19:34 +0000)]
amdsmn(4), amdtemp(4): add support for Family 19h (Zen 3)

Zen 3 "Vermeer" support, tested on Ryzen 9 5950X.

Model numbers from https://en.wikichip.org/wiki/amd/cpuid "Extended
Model" column.

Submitted by: Greg V <greg AT unrelenting.technology>
Differential Revision: https://reviews.freebsd.org/D27552

3 years agoProvide userland notification of gpio pin changes ("userland gpio interrupts").
Ian Lepore [Sat, 12 Dec 2020 18:34:15 +0000 (18:34 +0000)]
Provide userland notification of gpio pin changes ("userland gpio interrupts").

This is an import of the Google Summer of Code 2018 project completed by
Christian Kramer (and, sadly, ignored by us for two years now).  The goals
stated for that project were:

    FreeBSD already has support for interrupts implemented in the GPIO
    controller drivers of several SoCs, but there are no interfaces to take
    advantage of them out of user space yet. The goal of this work is to
    implement such an interface by providing descriptors which integrate
    with the common I/O system calls and multiplexing mechanisms.

The initial imported code supports the following functionality:

 -  A kernel driver that provides an interface to the user space; the
    existing gpioc(4) driver was enhanced with this functionality.
 -  Implement support for the most common I/O system calls / multiplexing
    mechanisms:
     -  read() Places the pin number on which the interrupt occurred in the
        buffer. Blocking and non-blocking behaviour supported.
     - poll()/select()
     - kqueue()
     - signal driven I/O. Posting SIGIO when the O_ASYNC was set.
 -  Many-to-many relationship between pins and file descriptors.
     -  A file descriptor can monitor several GPIO pins.
     -  A GPIO pin can be monitored by multiple file descriptors.
 -  Integration with gpioctl and libgpio.

I added some fixes (mostly to locking) and feature enhancements on top of
the original gsoc code.  The feature ehancements allow the user to choose
between detailed and summary event reporting.  Detailed reporting provides
a record describing each pin change event.  Summary reporting provides the
time of the first and last change of each pin, and a count of how many times
it changed state since the last read(2) call.  Another enhancement allows
the recording of multiple state change events on multiple pins between each
call to read(2) (the original code would track only a single event at a time).

The phabricator review for these changes timed out without approval, but I
cite it below anyway, because the review contains a series of diffs that
show how I evolved the code from its original state in Christian's github
repo for the gsoc project to what is being commited here.  (In effect,
the phab review extends the VC history back to the original code.)

Submitted by: Christian Kramer
Obtained from: https://github.com/ckraemer/freebsd/tree/gsoc2018
Differential Revision: https://reviews.freebsd.org/D27398

3 years agoxargs: compile yesexpr as ERE
Yuri Pankov [Sat, 12 Dec 2020 15:38:32 +0000 (15:38 +0000)]
xargs: compile yesexpr as ERE

yesexpr is an extended regular expression for quite some time now,
use appropriate flag when compiling it.

PR: 238762
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D27509

3 years agolualoader: config: fix module enabled check
Kyle Evans [Sat, 12 Dec 2020 14:53:34 +0000 (14:53 +0000)]
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.

3 years agoUse getlocalbase() instead of compiled in LOCALBASE to locate calendars
Stefan Eßer [Sat, 12 Dec 2020 11:51:29 +0000 (11:51 +0000)]
Use getlocalbase() instead of compiled in LOCALBASE to locate calendars

3 years agoChange getlocalbase() to not allocate any heap memory
Stefan Eßer [Sat, 12 Dec 2020 11:23:52 +0000 (11:23 +0000)]
Change getlocalbase() to not allocate any heap memory

After the commit of the current version, Scott Long pointed out, that an
attacker might be able to cause a use-after-free access if this function
returned the value of the sysctl variable "user.localbase" by freeing
the allocated memory without the cached address being cleared in the
library function.

To resolve this issue, I have proposed the originally suggested version
with a statically allocated buffer in a review (D27370). There was no
feedback on this review and after waiting for more than 2 weeks, the
potential security issue is fixed by this commit. (There was no security
risk in practice, since none of the programs converted to use this
function attempted to free the buffer. The address could only have
pointed into the heap if user.localbase was set to a non-default value,
into r/o data or the environment, else.)

This version uses a static buffer of size LOCALBASE_CTL_LEN, which
defaults to MAXPATHLEN. This does not increase the memory footprint
of the library at this time, since its data segment grows from less
than 7 KB to less than 8 KB, i.e. it will get two 4 KB pages on typical
architectures, anyway.

Compiling with LOCALBASE_CTL_LEN defined as 0 will remove the code
that accesses the sysctl variable, values between 1 and MAXPATHLEN-1
will limit the maximum size of the prefix. When built with such a
value and if too large a value has been configured in user.localbase,
the value defined as ILLEGAL_PREFIX will be returned to cause any
file operations on that result to fail. (Default value is "/dev/null/",
the review contained "/\177", but I assume that "/dev/null" exists and
can not be accessed as a directory. Any other string that can be assumed
not be a valid path prefix could be used.)

I do suggest to use LOCALBASE_CTL_LEN to size the in-kernel buffer for
the user.localbase variable, too. Doing this would guarantee that the
result always fit into the buffer in this library function (unless run
on a kernel built with a different buffer size.)

The function always returns a valid string, and only in case it is built
with a small static buffer and run on a system with too large a value in
user.localbase, the ILLEGAL_PREFIX will be returned, effectively causing
the created path to be non-existent.

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

3 years agogeom(8): list geoms with /dev/ prefix
Robert Wing [Sat, 12 Dec 2020 07:22:38 +0000 (07:22 +0000)]
geom(8): list geoms with /dev/ prefix

Allow geom(8) to list geoms with the '/dev/' prefix.

`geom part show` accepts the '/dev/' prefix but `geom part list` does not.

Modify find_geom() in sbin/geom/core/geom.c to be consistent with the behavior
of find_geom() in lib/geom/part/geom_part.c.

PR:             188213
Reported by:    Ronald F. Guilmette <rfg@tristatelogic.com>
Reviewed by:    imp, kevans
Approved by:    kevans (mentor)
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D27556

3 years agolualoader: provide module-manipulation commands
Kyle Evans [Sat, 12 Dec 2020 05:57:42 +0000 (05:57 +0000)]
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.

MFC after: 1 week

3 years agoRemove unused headers.
Xin LI [Sat, 12 Dec 2020 02:26:43 +0000 (02:26 +0000)]
Remove unused headers.

MFC after: 2 weeks

3 years agoRemove unneeded headers.
Xin LI [Sat, 12 Dec 2020 02:24:33 +0000 (02:24 +0000)]
Remove unneeded headers.

MFC after: 2 weeks

3 years agoFix NOINET6 build broken by r368571.
Alexander V. Chernikov [Sat, 12 Dec 2020 01:05:31 +0000 (01:05 +0000)]
Fix NOINET6 build broken by r368571.

3 years agoipfw kfib algo: Use rt accessors instead of accessing rib/rtentry directly.
Alexander V. Chernikov [Fri, 11 Dec 2020 23:57:30 +0000 (23:57 +0000)]
ipfw kfib algo: Use rt accessors instead of accessing rib/rtentry directly.

This removes assumptions on prefix storage and rtentry layout
 from an external code.

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

3 years agoposixshm_test.c: remove tautological checks
Ryan Libby [Fri, 11 Dec 2020 22:52:20 +0000 (22:52 +0000)]
posixshm_test.c: remove tautological checks

Reviewed by: kib, markj
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D27564

3 years agofdgrowtable_test.c: appease gcc
Ryan Libby [Fri, 11 Dec 2020 22:52:16 +0000 (22:52 +0000)]
fdgrowtable_test.c: appease gcc

Work around bogus gcc -Wreturn-type.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44511

Reviewed by: kevans, rew
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D27563

3 years agosavecore: bail on write error even when decompressing
Ryan Libby [Fri, 11 Dec 2020 22:52:12 +0000 (22:52 +0000)]
savecore: bail on write error even when decompressing

Reviewed by: markj
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D27560

3 years agozfs: quiet gcc -Wmissing-include-dirs
Ryan Libby [Fri, 11 Dec 2020 22:52:08 +0000 (22:52 +0000)]
zfs: quiet gcc -Wmissing-include-dirs

Don't tell it to look for headers in a non-existent directory.

Reviewed by: imp, mmacy
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D27565

3 years agoif_wg: appease gcc
Ryan Libby [Fri, 11 Dec 2020 22:52:03 +0000 (22:52 +0000)]
if_wg: appease gcc

 - remove -ferror-limit option
 - quiet -Wredundant-decls

Reviewed by: mmacy
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D27559

3 years agoffs: quiet -Wstrict-prototypes
Ryan Libby [Fri, 11 Dec 2020 22:51:57 +0000 (22:51 +0000)]
ffs: quiet -Wstrict-prototypes

Reviewed by: kib, markj, mckusick
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D27558

3 years agoqat: quiet -Wredundant-decls
Ryan Libby [Fri, 11 Dec 2020 22:51:53 +0000 (22:51 +0000)]
qat: quiet -Wredundant-decls

Reviewed by: markj
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D27554

3 years agontb: quiet gcc -Wreturn-type
Ryan Libby [Fri, 11 Dec 2020 22:51:48 +0000 (22:51 +0000)]
ntb: quiet gcc -Wreturn-type

Reviewed by: cem, markj
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D27553

3 years agocache_fplookup: quiet gcc -Wreturn-type
Ryan Libby [Fri, 11 Dec 2020 22:51:44 +0000 (22:51 +0000)]
cache_fplookup: quiet gcc -Wreturn-type

Reviewed by: markj, mjg
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D27555

3 years agondis(4): expand deprecation to the whole driver
Brooks Davis [Fri, 11 Dec 2020 21:51:50 +0000 (21:51 +0000)]
ndis(4): expand deprecation to the whole driver

nids(4) was a clever idea in the early 2000's when the market was
flooded with 10/100 NICs with Windows-only drivers, but that hasn't been
the case for ages and the driver has had no meaningful maintenance in
ages. It only supports Windows-XP era drivers.

Reviewed by: imp, bcr
MFC after: 3 days
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D27527

3 years agoNote removal of hme(4)
Brooks Davis [Fri, 11 Dec 2020 21:43:44 +0000 (21:43 +0000)]
Note removal of hme(4)

Sponsored by: DARPA

3 years agohme(4): Remove as previous announced
Brooks Davis [Fri, 11 Dec 2020 21:40:38 +0000 (21:40 +0000)]
hme(4): Remove as previous announced

The hme (Happy Meal Ethernet) driver was the onboard NIC in most
supported sparc64 platforms. A few PCI NICs do exist, but we have seen
no evidence of use on non-sparc systems.

Reviewed by: imp, emaste, bcr
Sponsored by: DARPA

3 years agoriscv: small counter(9) improvements
Mitchell Horne [Fri, 11 Dec 2020 20:01:45 +0000 (20:01 +0000)]
riscv: small counter(9) improvements

Prefer atomics to critical section. This reduces the cost of the
increment operation and removes the possibility of it being interrupted
by counter_u64_zero().

Use CPU_FOREACH() macro to skip absent CPUs.

Replace hand-rolled address calculation with zpcpu_get().

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D27536

3 years agovnet.9: Use correct location of vnet.h.
Navdeep Parhar [Fri, 11 Dec 2020 19:45:40 +0000 (19:45 +0000)]
vnet.9: Use correct location of vnet.h.

MFC after: 1 week
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D27557

3 years agolock(1): Add EXAMPLES section
Fernando Apesteguía [Fri, 11 Dec 2020 19:27:21 +0000 (19:27 +0000)]
lock(1): Add EXAMPLES section

Add simple example showing the use of the flags: p, t, v

Reviewed by: gbe@, yuripv@
Approved by: manpages (yuripv@)
Differential Revision: https://reviews.freebsd.org/D27541

3 years agocaroot: update bundle
Kyle Evans [Fri, 11 Dec 2020 18:14:43 +0000 (18:14 +0000)]
caroot: update bundle

Summary:
- One (1) added
- Ten (10) removed

MFC after: 3 days

3 years agodecryptcore: preload OpenSSL error strings; seed PRNG
Eric van Gyzen [Fri, 11 Dec 2020 14:32:42 +0000 (14:32 +0000)]
decryptcore: preload OpenSSL error strings; seed PRNG

As in r360226, preload OpenSSL error strings and seed the PRNG
before entering capability mode.

MFC after: 2 weeks
Sponsored by: Dell EMC Isilon

3 years agoInstall 2 forgotten shell scripts required to run the tests
Stefan Eßer [Fri, 11 Dec 2020 13:23:59 +0000 (13:23 +0000)]
Install 2 forgotten shell scripts required to run the tests

Submitted by: arichardson (Alexander Richardson)
Differential Revision: https://reviews.freebsd.org/D27568

3 years agoFix a grammar error on locate(1).
Guangyuan Yang [Fri, 11 Dec 2020 08:04:54 +0000 (08:04 +0000)]
Fix a grammar error on locate(1).

While here, also fix a useless .Tn reported by mandoc.

PR: 251746
MFC after: 1 week
Sumbitted by: David Schlachter <fbsd-bugzilla@schlachter.ca>

3 years agosrc.conf(5): regenerate after WITHOUT_GNU_GREP became default
Kyle Evans [Fri, 11 Dec 2020 04:02:19 +0000 (04:02 +0000)]
src.conf(5): regenerate after WITHOUT_GNU_GREP became default

3 years agoFlip the GNU_GREP default to OFF
Kyle Evans [Fri, 11 Dec 2020 03:59:41 +0000 (03:59 +0000)]
Flip the GNU_GREP default to OFF

bsdgrep was made the default in r368439. Stop building gnugrep entirely as
the natural next step towards removal.

3 years agotimespec_get(3): sort SEE ALSO correctly
Enji Cooper [Fri, 11 Dec 2020 02:22:42 +0000 (02:22 +0000)]
timespec_get(3): sort SEE ALSO correctly

clock_gettime(2) should be mentioned before gettimeofday(2).

Reported by: make manlint
MFC after: 1 week
Sponsored by: DellEMC Isilon

3 years agocpuset{,_getaffinity,_getdomain}.2: fix SEE ALSO
Enji Cooper [Fri, 11 Dec 2020 01:52:27 +0000 (01:52 +0000)]
cpuset{,_getaffinity,_getdomain}.2: fix SEE ALSO

Sort by manpage section, then sort entries alphabetically.

This makes the manpages `make manlint` clean.

MFC after: 1 week
Sponsored by: DellEMC Isilon

3 years agostyle(9): Correct whitespace in struct definitions
Brooks Davis [Fri, 11 Dec 2020 01:00:07 +0000 (01:00 +0000)]
style(9): Correct whitespace in struct definitions

struct ifconf and struct ifreq use the odd style "struct<tab>foo".
struct ifdrv seems to have tried to follow this but was committed with
spaces in place of most tabs resulting in "struct<space><space>ifdrv".

MFC after: 3 days

3 years agoRevert r366943. It did not work as expected.
Jung-uk Kim [Fri, 11 Dec 2020 00:42:53 +0000 (00:42 +0000)]
Revert r366943.  It did not work as expected.

3 years agoaio_suspend.2: properly canonicalize .Dd
Enji Cooper [Fri, 11 Dec 2020 00:28:28 +0000 (00:28 +0000)]
aio_suspend.2: properly canonicalize .Dd

Months should be fully spelled as their local-specific equivalents: in this
case `Oct` should have been spelled like `October`.

Reported by: make manlint
MFC after: 1 week
Sponsored by: DellEMC Isilon

3 years agocap_enter(2): fix CAVEATS section
Enji Cooper [Fri, 11 Dec 2020 00:26:49 +0000 (00:26 +0000)]
cap_enter(2): fix CAVEATS section

The CAVEATS section was misspelled as "CAVEAT" before this change. Fix the
spelling to identify issues related to the section.

Furthermore, given that the section order was incorrect, move the CAVEATS
section down to the bottom of the manpage, per the conventional section
order.

MFC after: 1 week
Reported by: make manlint
Sponsored by: DellEMC Isilon

3 years agoposix_spawn(3): fix section that references `vfork`
Enji Cooper [Fri, 11 Dec 2020 00:20:04 +0000 (00:20 +0000)]
posix_spawn(3): fix section that references `vfork`

`vfork(2)` should be referenced in paragraphs as `.Fn vfork`, not `vfork()`.
This change switches the reference to use `.Fn`, which in turn makes the
manpage `make manlint` clean.

MFC after: 1 week
Reported by: make manlint
Sponsored by: DellEMC Isilon

3 years agogetentropy(3): sort SEE ALSO sections
Enji Cooper [Fri, 11 Dec 2020 00:15:57 +0000 (00:15 +0000)]
getentropy(3): sort SEE ALSO sections

Sorting order should be done by manpage section (2 vs 3), then alphabetically.
This change fixes the order to sort by the manpage section, first.

Reported by: make manlint
MFC after: 1 week
Sponsored by: DellEMC Isilon

3 years agoarc4random(3): fix .Xr issues
Enji Cooper [Fri, 11 Dec 2020 00:13:39 +0000 (00:13 +0000)]
arc4random(3): fix .Xr issues

- pthreads(3) should actually be pthread(3).
- getentropy(2) should actually be getentropy(3).

This makes the manpage `make manlint` clean.

MFC after: 1 week
Sponsored by: DellEMC Isilon

3 years agofix up documentation/comments: processname is not defined, but programname
John-Mark Gurney [Thu, 10 Dec 2020 23:23:42 +0000 (23:23 +0000)]
fix up documentation/comments: processname is not defined, but programname
is..

a couple other minor documentation fixes that igor caught...

MFC after: 1 week

3 years agoriscv: handle debug.debugger_on_trap for fatal page faults
Mitchell Horne [Thu, 10 Dec 2020 22:20:20 +0000 (22:20 +0000)]
riscv: handle debug.debugger_on_trap for fatal page faults

Allows recovery or diagnosis of a fatal page fault before panicking the
system.

Reviewed by: jhb, kp
Differential Revision: https://reviews.freebsd.org/D27534

3 years agoAdd the LTO-9 density code to libmt and the mt(1) man page.
Kenneth D. Merry [Thu, 10 Dec 2020 21:06:06 +0000 (21:06 +0000)]
Add the LTO-9 density code to libmt and the mt(1) man page.

These values are taken directly from the density report from an
IBM LTO-9 tape drive.  (Using mt getdensity)

A LTO-9 drive stores 18TB raw (45TB with compression) on an LTO-9 tape.

lib/libmt/mtlib.c:
        Add the LTO-9 density code, and bpmm/bpi values.

usr.bin/mt/mt.1:
        Add the LTO-9 density code, bpmm/bpi values and number of
tracks.  Bump the man page date.

MFC after: 3 days
Sponsored by: Spectra Logic

3 years agolinux_dma: Ensure proper flags pass to allocators.
Bryan Drewery [Thu, 10 Dec 2020 20:45:08 +0000 (20:45 +0000)]
linux_dma: Ensure proper flags pass to allocators.

Possibly fixes the wrong flags being passed to the kernel
allocators in linux_dma_alloc_coherent() and linux_dma_pool_alloc().

Reviewed by: hps
MFC after: 2 weeks
Sponsored by: Dell EMC
Differential Revision: https://reviews.freebsd.org/D27508

3 years agocontig allocs: Don't retry forever on M_WAITOK.
Bryan Drewery [Thu, 10 Dec 2020 20:44:29 +0000 (20:44 +0000)]
contig allocs: Don't retry forever on M_WAITOK.

This restores behavior from before domain iterators were added in
r327895 and r327896.

The vm_domainset_iter_policy() will do a vm_wait_doms() and then
restart its iterator when M_WAITOK is set.  It will also force
the containing loop to have M_NOWAIT.  So we get an unbounded
retry loop rather than the intended bounded retries that
kmem_alloc_contig_pages() already handles.

This also restores M_WAITOK to the vmem_alloc() call in
kmem_alloc_attr_domain() and kmem_alloc_contig_domain().

Reviewed by: markj, kib
MFC after: 2 weeks
Sponsored by: Dell EMC
Differential Revision: https://reviews.freebsd.org/D27507

3 years agoFix the TFTP client when performing a RRQ for files smaller than 512 bytes
Michael Tuexen [Thu, 10 Dec 2020 19:36:33 +0000 (19:36 +0000)]
Fix the TFTP client when performing a RRQ for files smaller than 512 bytes
and the server not sending an OACK:
* Close the file.
* Report the correct the number of received blocks.

MFC after: 1 week

3 years agoid(1): Add EXAMPLES section
Fernando Apesteguía [Thu, 10 Dec 2020 18:34:15 +0000 (18:34 +0000)]
id(1): Add EXAMPLES section

Add some examples covering the flags: G, n, P, p, u

Add reference to groups(1)

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

3 years agoAdd deprecation notice for bvmconsole and bvmdebug
Robert Wing [Thu, 10 Dec 2020 18:07:25 +0000 (18:07 +0000)]
Add deprecation notice for bvmconsole and bvmdebug

Now that bhyve(8) supports UART, bvmconsole and bvmdebug are no longer needed.

Mark the '-b' and '-g' flag as deprecated for bhyve(8).

These will be removed in 13.

Reviewed by:    jhb, grehan
Approved by:    kevans (mentor)
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D27519

3 years agogroups(1): Add EXAMPLE
Fernando Apesteguía [Thu, 10 Dec 2020 17:48:34 +0000 (17:48 +0000)]
groups(1): Add EXAMPLE

Add a super simple example

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

3 years agofd: make serialization in fdescfree_fds conditional on hold count
Mateusz Guzik [Thu, 10 Dec 2020 17:17:22 +0000 (17:17 +0000)]
fd: make serialization in fdescfree_fds conditional on hold count

p_fd nullification in fdescfree serializes against new threads transitioning
the count 1 -> 2, meaning that fdescfree_fds observing the count of 1 can
safely assume there is nobody else using the table. Losing the race and
observing > 1 is harmless.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D27522