]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agoMFV r368607:
mm [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 agoFix WITHOUT_ICONV build
se [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
bdragon [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
yuripv [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
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
kevans [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
kp [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
cem [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)
cem [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 [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
yuripv [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
kevans [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
se [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
se [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
rew [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
kevans [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.
delphij [Sat, 12 Dec 2020 02:26:43 +0000 (02:26 +0000)]
Remove unused headers.

MFC after: 2 weeks

3 years agoRemove unneeded headers.
delphij [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.
melifaro [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.
melifaro [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
rlibby [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
rlibby [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
rlibby [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
rlibby [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
rlibby [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
rlibby [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
rlibby [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
rlibby [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
rlibby [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 [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 [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 [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
mhorne [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.
np [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
fernape [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
kevans [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
vangyzen [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
se [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).
ygy [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
kevans [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
kevans [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
ngie [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
ngie [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 [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.
jkim [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
ngie [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
ngie [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`
ngie [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
ngie [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
ngie [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
jmg [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
mhorne [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.
ken [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.
bdrewery [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.
bdrewery [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
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
fernape [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
rew [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
fernape [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
mjg [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

3 years agohyperv/vmbus: avoid crash, panic if vbe fb info is missing
bhughes [Thu, 10 Dec 2020 13:11:52 +0000 (13:11 +0000)]
hyperv/vmbus: avoid crash, panic if vbe fb info is missing

Do not assume that VBE framebuffer metadata can be used. Like with the
EFI fb metadata, it may be null, so we should take care not to
dereference the null vbefb pointer. This avoids a panic when booting
-CURRENT on a gen1 VM in Azure.

Approved by: tsoome
Sponsored by: Miles AS
Differential Revision: https://reviews.freebsd.org/D27533

3 years agoee(1): Whitespace cleanup
gbe [Thu, 10 Dec 2020 10:58:30 +0000 (10:58 +0000)]
ee(1): Whitespace cleanup

This is a direct commit to -CURRENT since the upstream went away.

MFC after: 1 week

3 years agoMake "diskinfo -i" also test 1MB reads.
trasz [Thu, 10 Dec 2020 10:23:18 +0000 (10:23 +0000)]
Make "diskinfo -i" also test 1MB reads.

3 years agoLift scope of buf[] to make it extend to a potential access via *basename
se [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.

Reported by: Coverity Scan CID 1437697
MFC after: 3 days

3 years agotruss: Add AIO syscalls.
tmunro [Thu, 10 Dec 2020 07:13:15 +0000 (07:13 +0000)]
truss: Add AIO syscalls.

Display the arguments of aio_read(2), aio_write(2), aio_suspend(2),
aio_error(2), aio_return(2), aio_cancel(2), aio_fsync(2), aio_mlock(2),
aio_waitcomplete(2) and lio_listio(2) in human-readable form.

Reviewed by: asomers
Differential Revision: https://reviews.freebsd.org/D27518

3 years agoFix staging riscv images.
gjb [Wed, 9 Dec 2020 20:38:26 +0000 (20:38 +0000)]
Fix staging riscv images.

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

3 years agoFix bug in ifconfig preventing proper VLAN creation.
hselasky [Wed, 9 Dec 2020 20:13:12 +0000 (20:13 +0000)]
Fix bug in ifconfig preventing proper VLAN creation.

Detection of interface type by filter must happen before detection of
interface type by prefix. Else the following sequence of commands will
try to create a LAGG interface instead of a VLAN interface, which
accidentially worked previously, because the date pointed to by the
ifr_data pointer was not parsed by VLAN create ioctl(2). This is a
regression after r368229, because the VLAN creation now parses the
ifr_data field.

How to reproduce:
# ifconfig lagg0 create
# ifconfig lagg0.256 create

Differential Revision: https://reviews.freebsd.org/D27521
Reviewed by: kib@ and kevans@
Reported by: raul.munoz@custos.es
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agodmar: reserve memory windows of PCIe root port
rlibby [Wed, 9 Dec 2020 18:43:58 +0000 (18:43 +0000)]
dmar: reserve memory windows of PCIe root port

PCI memory address space is shared between memory-mapped devices (MMIO)
and host memory (which may be remapped by an IOMMU). Device accesses to
an address within a memory aperture in a PCIe root port will be treated
as peer-to-peer and not forwarded to an IOMMU. To avoid this, reserve
the address space of the root port's memory apertures in the address
space used by the IOMMU for remapping.

Reviewed by: kib, tychon
Discussed with: Anton Rang <rang@acm.org>
Tested by: tychon
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D27503

3 years agoMerge commit 28de0fb48 from llvm git (by Luís Marques):
dim [Wed, 9 Dec 2020 18:37:43 +0000 (18:37 +0000)]
Merge commit 28de0fb48 from llvm git (by Luís Marques):

  [RISCV] Set __GCC_HAVE_SYNC_COMPARE_AND_SWAP_x defines

  The RISCV target did not set the GCC atomic compare and swap defines,
  unlike other targets. This broke builds for things like glib on
  RISCV.

  Patch by Kristof Provost (kprovost)

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

This should fix building glib20 on RISC-V and unblock a number of
dependent ports.

Requested by: kp
MFC after: 3 days

3 years agonetgraph: macfilter: small fixes
kevans [Wed, 9 Dec 2020 15:28:56 +0000 (15:28 +0000)]
netgraph: macfilter: small fixes

Two issues:
- The DEBUG macro defined is in direct conflict with the DEBUG kernel
  option, which broke the -LINT build[0]
- Building with NG_MACFILTER_DEBUG did not compile on LP64 systems due to
  using %d for sizeof().

Reported by: Jenkins[0]

3 years agoPlug a race between fd table teardown and several loops
markj [Wed, 9 Dec 2020 14:05:08 +0000 (14:05 +0000)]
Plug a race between fd table teardown and several loops

To export information from fd tables we have several loops which do
this:

FILDESC_SLOCK(fdp);
for (i = 0; fdp->fd_refcount > 0 && i <= lastfile; i++)
<export info for fd i>;
FILDESC_SUNLOCK(fdp);

Before r367777, fdescfree() acquired the fd table exclusive lock between
decrementing fdp->fd_refcount and freeing table entries.  This
serialized with the loop above, so the file at descriptor i would remain
valid until the lock is dropped.  Now there is no serialization, so the
loops may race with teardown of file descriptor tables.

Acquire the exclusive fdtable lock after releasing the final table
reference to provide a barrier synchronizing with these loops.

Reported by: pho
Reviewed by: kib (previous version), mjg
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27513

3 years agoUse refcount_load(9) to load fd table reference counts
markj [Wed, 9 Dec 2020 14:04:54 +0000 (14:04 +0000)]
Use refcount_load(9) to load fd table reference counts

No functional change intended.

Reviewed by: kib, mjg
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27512

3 years agogrep: replace the internal queue with a ring buffer
kevans [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.

MFC after: 2 weeks

3 years agogrep: tests: stop expecting a failure of gnuext w/ bsdgrep
kevans [Wed, 9 Dec 2020 05:12:04 +0000 (05:12 +0000)]
grep: tests: stop expecting a failure of gnuext w/ bsdgrep

libregex now supports these and we no longer offer to not link against
libregex.

3 years agokdump/truss: decode new _umtx_op flags
kevans [Wed, 9 Dec 2020 03:24:09 +0000 (03:24 +0000)]
kdump/truss: decode new _umtx_op flags

In both cases, print the flag bits first followed by the command.

Output now looks something like this:

(ktrace)
_umtx_op(0x8605f7008,0xf<UMTX_OP_WAIT_UINT_PRIVATE>,0,0,0)
_umtx_op(0x9fffdce8,0x80000003<UMTX_OP__32BIT|UMTX_OP_WAKE>,0x1,0,0)

(truss)
_umtx_op(0x7fffffffda50,UMTX_OP_WAKE,0x1,0x0,0x0) = 0 (0x0)
_umtx_op(0x9fffdd08,UMTX_OP__32BIT|UMTX_OP_WAKE,0x1,0x0,0x0) = 0 (0x0)

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D27325

3 years agolibsysdecode: decode _UMTX_OP flags
kevans [Wed, 9 Dec 2020 03:22:44 +0000 (03:22 +0000)]
libsysdecode: decode _UMTX_OP flags

Assume that UMTX_OP with a double underbar following is a flag, while any
underbar+alphanumeric combination immeiately following is an op.

This was a part of D27325.

Reviewed by: kib

3 years ago_umtx_op(2): document recent addition of 32bit compat flags
kevans [Wed, 9 Dec 2020 03:20:51 +0000 (03:20 +0000)]
_umtx_op(2): document recent addition of 32bit compat flags

This was part of D27325.

Reviewed by: kib

3 years agoMFV r368464:
cy [Wed, 9 Dec 2020 02:59:24 +0000 (02:59 +0000)]
MFV r368464:

Update unbound from 1.12.0 to 1.13.0

MFC after: 1 week
Security: CVE-2020-28935

3 years agoCopy arm64 make-memstick.sh and mkisoimages.sh to the riscv
gjb [Wed, 9 Dec 2020 02:21:25 +0000 (02:21 +0000)]
Copy arm64 make-memstick.sh and mkisoimages.sh to the riscv
directory to allow properly building *.iso and *.img files.

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

3 years agodev/mfi: Make a seemingly bogus conditional unconditional
jhibbits [Wed, 9 Dec 2020 02:07:01 +0000 (02:07 +0000)]
dev/mfi: Make a seemingly bogus conditional unconditional

Summary:
r358689 attempted to fix a clang warning/error by inferring the intent
of the condition "(cdb[0] != 0x28 || cdb[0] != 0x2A)".  Unfortunately, it looks
like this broke things.  Instead, fix this by making this path unconditional,
effectively reverting to the previous state.

PR: kern/251483
Reviewed By: ambrisko
MFC after: 2 days
Differential Revision: https://reviews.freebsd.org/D27515

3 years agoMerge OpenSSL 1.1.1i.
jkim [Wed, 9 Dec 2020 02:05:14 +0000 (02:05 +0000)]
Merge OpenSSL 1.1.1i.

3 years agoFixup r368446 with KERN_TLS.
glebius [Tue, 8 Dec 2020 23:54:09 +0000 (23:54 +0000)]
Fixup r368446 with KERN_TLS.

3 years agofts_read: Handle error from a NULL return better.
bdrewery [Tue, 8 Dec 2020 23:38:26 +0000 (23:38 +0000)]
fts_read: Handle error from a NULL return better.

This is addressing cases such as fts_read(3) encountering an [EIO]
from fchdir(2) when FTS_NOCHDIR is not set.  That would otherwise be
seen as a successful traversal in some of these cases while silently
discarding expected work.

As noted in r264201, fts_read() does not set errno to 0 on a successful
EOF so it needs to be set before calling it.  Otherwise we might see
a random error from one of the iterations.

gzip is ignoring most errors and could be improved separately.

Reviewed by: vangyzen
Sponsored by: Dell EMC
Differential Revision: https://reviews.freebsd.org/D27184

3 years agoVendor import of Unbound 1.13.0.
cy [Tue, 8 Dec 2020 21:23:03 +0000 (21:23 +0000)]
Vendor import of Unbound 1.13.0.

Security: CVE-2020-28935

3 years agocpuset_set{affinity,domain}: do not allow empty masks
kevans [Tue, 8 Dec 2020 18:47:22 +0000 (18:47 +0000)]
cpuset_set{affinity,domain}: do not allow empty masks

cpuset_modify() would not currently catch this, because it only checks that
the new mask is a subset of the root set and circumvents the EDEADLK check
in cpuset_testupdate().

This change both directly validates the mask coming in since we can
trivially detect an empty mask, and it updates cpuset_testupdate to catch
stuff like this going forward by always ensuring we don't end up with an
empty mask.

The check_mask argument has been renamed because the 'check' verbiage does
not imply to me that it's actually doing a different operation. We're either
augmenting the existing mask, or we are replacing it entirely.

Reported by: syzbot+4e3b1009de98d2fabcda@syzkaller.appspotmail.com
Discussed with: andrew
Reviewed by: andrew, markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D27511

3 years agokern: cpuset: resolve race between cpuset_lookup/cpuset_rel
kevans [Tue, 8 Dec 2020 18:45:47 +0000 (18:45 +0000)]
kern: cpuset: resolve race between cpuset_lookup/cpuset_rel

The race plays out like so between threads A and B:

1. A ref's cpuset 10
2. B does a lookup of cpuset 10, grabs the cpuset lock and searches
   cpuset_ids
3. A rel's cpuset 10 and observes the last ref, waits on the cpuset lock
   while B is still searching and not yet ref'd
4. B ref's cpuset 10 and drops the cpuset lock
5. A proceeds to free the cpuset out from underneath B

Resolve the race by only releasing the last reference under the cpuset lock.
Thread A now picks up the spinlock and observes that the cpuset has been
revived, returning immediately for B to deal with later.

Reported by: syzbot+92dff413e201164c796b@syzkaller.appspotmail.com
Reviewed by: markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D27498

3 years agokern: cpuset: plug a unr leak
kevans [Tue, 8 Dec 2020 18:44:06 +0000 (18:44 +0000)]
kern: cpuset: plug a unr leak

cpuset_rel_defer() is supposed to be functionally equivalent to
cpuset_rel() but with anything that might sleep deferred until
cpuset_rel_complete -- this setup is used specifically for cpuset_setproc.

Add in the missing unr free to match cpuset_rel. This fixes a leak that
was observed when I wrote a small userland application to try and debug
another issue, which effectively did:

cpuset(&newid);
cpuset(&scratch);

newid gets leaked when scratch is created; it's off the list, so there's
no mechanism for anything else to relinquish it. A more realistic reproducer
would likely be a process that inherits some cpuset that it's the only ref
for, but it creates a new one to modify. Alternatively, administratively
reassigning a process' cpuset that it's the last ref for will have the same
effect.

Discovered through D27498.

MFC after: 1 week

3 years agoarm64: fix struct l_sigaction_t layout
mhorne [Tue, 8 Dec 2020 18:24:33 +0000 (18:24 +0000)]
arm64: fix struct l_sigaction_t layout

The definition was copied from amd64, but the layout of the struct
differs slightly between these platforms. This fixes spurious
`unsupported sigaction flag 0xXXXXXXXX` messages when executing some
Linux binaries on arm64.

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

3 years agoCheck that the frame pointer is within the current stack.
jhb [Tue, 8 Dec 2020 18:00:58 +0000 (18:00 +0000)]
Check that the frame pointer is within the current stack.

This same check is used on other architectures.  Previously this would
permit a stack frame to unwind into any arbitrary kernel address
(including unmapped addresses).

Reviewed by: andrew, markj
Obtained from: CheriBSD
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D27362

3 years agoStack unwinding robustness fixes for RISC-V.
jhb [Tue, 8 Dec 2020 17:57:18 +0000 (17:57 +0000)]
Stack unwinding robustness fixes for RISC-V.

- Push the kstack_contains check down into unwind_frame() so that it
  is honored by DDB and DTrace.

- Check that the trapframe for an exception frame is contained in the
  traced thread's kernel stack for DDB traces.

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

3 years agoMissed adding netgraph to mtree in r368443:
n_hibma [Tue, 8 Dec 2020 17:44:34 +0000 (17:44 +0000)]
Missed adding netgraph to mtree in r368443:

New Netgraph module ng_macfilter:

Macfilter to route packets through different hooks based on sender MAC address.

Based on ng_macfilter written by Pekka Nikander

Sponsered by Retina b.v.

Reviewed by:    afedorov
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D27268

3 years agoFix indenting for netmap.
n_hibma [Tue, 8 Dec 2020 17:42:32 +0000 (17:42 +0000)]
Fix indenting for netmap.

3 years ago[ath] also remove the magic size value here for the transmit antenna statistics.
adrian [Tue, 8 Dec 2020 17:28:42 +0000 (17:28 +0000)]
[ath] also remove the magic size value here for the transmit antenna statistics.

3 years ago[ath] Don't use hard-coded values in the sanity check.
adrian [Tue, 8 Dec 2020 17:27:24 +0000 (17:27 +0000)]
[ath] Don't use hard-coded values in the sanity check.

Don't use hard-coded values in the phy error and receive antenna
checks.

3 years ago[ath] replace the hard-coded magic values in if_athioctl.h with constant defines
adrian [Tue, 8 Dec 2020 17:25:59 +0000 (17:25 +0000)]
[ath] replace the hard-coded magic values in if_athioctl.h with constant defines

Replace some hard-coded magic values in the ioctl stats struct with
#defines.  I'm going to follow up with some more sanity checking in
the receive path that also use these values so we don't do bad
things if the hardware is (more) confused.

3 years agoThe list of ports in configuration path shall be protected by locks,
glebius [Tue, 8 Dec 2020 16:46:00 +0000 (16:46 +0000)]
The list of ports in configuration path shall be protected by locks,
epoch shall be used only for fast path.  Thus use LAGG_XLOCK() in
lagg_[un]register_vlan.  This fixes sleeping in epoch panic.

PR: 240609

3 years agoOpenSSL: address CVE-2020-1971
emaste [Tue, 8 Dec 2020 16:43:35 +0000 (16:43 +0000)]
OpenSSL: address CVE-2020-1971

OpenSSL commit 3db2c9f3:
Complain if we are attempting to encode with an invalid ASN.1 template

OpenSSL commit 43a7033:
Check that multi-strings/CHOICE types don't use implicit tagging

OpenSSL commit f960d812:
Correctly compare EdiPartyName in GENERAL_NAME_cmp()

Obtained from: OpenSSL 3db2c9f343a7033f960d812
Security: CVE-2020-1971

3 years agoConvert LAGG_RLOCK() to NET_EPOCH_ENTER(). No functional changes.
glebius [Tue, 8 Dec 2020 16:36:46 +0000 (16:36 +0000)]
Convert LAGG_RLOCK() to NET_EPOCH_ENTER(). No functional changes.

3 years agoUse a macro to find the offset of kern_ttbr0
andrew [Tue, 8 Dec 2020 15:51:05 +0000 (15:51 +0000)]
Use a macro to find the offset of kern_ttbr0

Rather than hard coding the offset of kern_ttbr0 within arm64_bootparams
use a macro like the other fields.

Sponsored by: Innovate UK

3 years agoFree the arm64 bootparams memory after initarm
andrew [Tue, 8 Dec 2020 15:41:18 +0000 (15:41 +0000)]
Free the arm64 bootparams memory after initarm

This is only needed in initarm, we can return this memory to the stack
used by mi_startup.

Sponsored by: Innivate UK