]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
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

3 years agoNew Netgraph module ng_macfilter:
n_hibma [Tue, 8 Dec 2020 15:09:42 +0000 (15:09 +0000)]
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 agoregen src.conf.5 after r368441, WITHOUT_GDB default
emaste [Tue, 8 Dec 2020 15:00:07 +0000 (15:00 +0000)]
regen src.conf.5 after r368441, WITHOUT_GDB default

3 years agoDefault to WITHOUT_GDB (GDB 6.1.1) for FreeBSD 13
emaste [Tue, 8 Dec 2020 14:56:15 +0000 (14:56 +0000)]
Default to WITHOUT_GDB (GDB 6.1.1) for FreeBSD 13

As discussed on -current, -stable, -toolchain, and with jhb@ and imp@,
disable the obsolete in-tree GDB 6.1.1 by default.  This was kept only
to provide kgdb for the crashinfo tool, but is long-obsolete, does not
support all architectures that FreeBSD does, and held back other work
(such as forcing the use of DWARF2 for kernel debug).

Crashinfo will use kgdb from the gdb package or devel/gdb port, and will
privde a message referencing those if no kgdb is found.

Relnotes: Yes
Sponsored by: The FreeBSD Foundation

3 years agosrc.conf(5): regen after r368439 (WITH_BSD_GREP default)
kevans [Tue, 8 Dec 2020 14:05:54 +0000 (14:05 +0000)]
src.conf(5): regen after r368439 (WITH_BSD_GREP default)

3 years agosrc.opts.mk: switch to bsdgrep as /usr/bin/grep
kevans [Tue, 8 Dec 2020 14:05:25 +0000 (14:05 +0000)]
src.opts.mk: switch to bsdgrep as /usr/bin/grep

This has been years in the making, and we all knew it was bound to happen
some day. Switch to the BSDL grep implementation now that it's been a
little more thoroughly tested and theoretically supports all of the
extensions that gnugrep in base had with our libregex(3).

Folks shouldn't really notice much from this update; bsdgrep is slower than
gnugrep, but this is currently the price to pay for fewer bugs. Those
dissatisfied with the speed of grep and in need of a faster implementation
should check out what textproc/ripgrep and textproc/the_silver_searcher
can do for them.

I have some WIP to make bsdgrep faster, but do not consider it a blocker
when compared to the pros of switching now (aforementioned bugs, licensing).

PR: 228798 (exp-run)
PR: 128645, 156704, 166842, 166862, 180937, 193835, 201650
PR: 232565, 242308, 246000, 251081, 191086, 194397
Relnotes: yes, please

3 years agoextattr_get_file(20: bump .Dd
ngie [Tue, 8 Dec 2020 04:18:16 +0000 (04:18 +0000)]
extattr_get_file(20: bump .Dd

This is being done for the formatting and context changes. While the net content
hasn't been changed, the content/context changes were sufficient to warrant the
date bump.

MFC after: 1 week
MFC with: r368431, r368433, r368434, r368435
Sponsored by: DellEMC Isilon

3 years agoextattr_get_file(2): clarify RETURN VALUES
ngie [Tue, 8 Dec 2020 04:16:05 +0000 (04:16 +0000)]
extattr_get_file(2): clarify RETURN VALUES

While some of the syscalls' behavior were documented and implied in the
RETURN VALUES section by earlier, e.g., the DESCRIPTION sections, as having
behavior of the other calls (`*_fd` vs `*_file` vs `*_link`), there was a lot
of implied return value behavior in the section prior to this change.

Explicitly document the syscall behavior per the current implementation in
sys/kern/vfs_extattr.c so others can better develop based on its explicit
documented behavior instead of having to digest the context of the manpage to
understand the appropriate behavior.

MFC after: 1 week
MFC with: r368431, r368433, r368434
Sponsored by: DellEMC Isilon

3 years agoextattr_get_file(2): fix more formatting
ngie [Tue, 8 Dec 2020 04:05:19 +0000 (04:05 +0000)]
extattr_get_file(2): fix more formatting

- Remove an unnecessary trailing comma separating a two-item clause.
- Sort more function calls alphabetically (in the same vein as r368433).

MFC after: 1 week
Sponsored by: DellEMC Isilon

3 years agoextattr_get_file(2): sort syscalls alphabetically
ngie [Tue, 8 Dec 2020 04:01:03 +0000 (04:01 +0000)]
extattr_get_file(2): sort syscalls alphabetically

Although some sections of the manpage sort the syscalls alphabetically, many
core areas of the manpage do not. Sort the syscalls so it is easier to pick out
functional changes and to improve manpage readability.

This formatting change is also being done to make future functional changes
easier to spot.

MFC after: 1 week
Sponsored by: DellEMC Isilon

3 years agolio_listio(2): fix manlint error
ngie [Tue, 8 Dec 2020 03:48:05 +0000 (03:48 +0000)]
lio_listio(2): fix manlint error

The date with .Dd prior to this change isn't canonically spelled out: it
should have been "December", not "Dec".

MFC after: 1 week
Sponsored by: DellEMC Isilon

3 years agoextattr_get_fd(2): fix manlint errors
ngie [Tue, 8 Dec 2020 03:43:00 +0000 (03:43 +0000)]
extattr_get_fd(2): fix manlint errors

- The CAVEATS section was misspelled as "CAVEAT".
- The CAVEATS section should come before the "BUGS" section and after
  other existing sections by convention.

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

3 years agoIn ext2fs, BA_CLRBUF is used in ext2_balloc() not UFS_BALLOC().
mckusick [Tue, 8 Dec 2020 00:49:31 +0000 (00:49 +0000)]
In ext2fs, BA_CLRBUF is used in ext2_balloc() not UFS_BALLOC().

Noted by:     kib
MFC after:    3 days
Sponsored by: Netflix

3 years agorelease: don't checksum images if there are none
mhorne [Tue, 8 Dec 2020 00:48:50 +0000 (00:48 +0000)]
release: don't checksum images if there are none

For platforms that don't have any of the memstick, cdrom, or dvdrom
release images (i.e. riscv64), the release-install target will trip up
when invoking md5(1) on the non-existent image files. Skipping this
allows the install to complete successfully.

3 years agoRISC-V release confs
mhorne [Tue, 8 Dec 2020 00:42:03 +0000 (00:42 +0000)]
RISC-V release confs

Add two release flavors for RISC-V. First, the traditional "big-iron"
images, capable of generating distribution sets and VM images. Installer
images won't be built yet, but can be trivially enabled in the future
with the addition of riscv/make-memstick.sh.

Second, a GENERICSD embedded image. I've opted for this instead of
board-specific SD card images as it allows users to just dd the u-boot
they want. The RISC-V hardware ecosystem is still young, so a
configuration for e.g. the new PolarFire SoC Icicle Kit would likely see
very few users.

Reviewed by: gjb
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D27045

3 years agoriscv: allow building virtual machine images
mhorne [Tue, 8 Dec 2020 00:37:11 +0000 (00:37 +0000)]
riscv: allow building virtual machine images

RISC-V has the same booting requirements as arm64 (loader.efi, no legacy
boot options), so generated images for both architectures have the same
partition layout.

Reviewed by: gjb
Differential Revision: https://reviews.freebsd.org/D27044

3 years agorelease.sh: add support for RISC-V embedded builds
mhorne [Tue, 8 Dec 2020 00:35:13 +0000 (00:35 +0000)]
release.sh: add support for RISC-V embedded builds

Since the few existing RISC-V hardware platforms are single board
computers, we can piggyback off of arm/arm64's embedded build support
for generating SD card images.

I don't see a pressing need to change the naming in this file at this
time.

Reviewed by: gjb, manu
Differential Revision: https://reviews.freebsd.org/D27043

3 years agoBump __FreeBSD_version for removal of crypto fd's in r368005.
jhb [Mon, 7 Dec 2020 18:58:08 +0000 (18:58 +0000)]
Bump __FreeBSD_version for removal of crypto fd's in r368005.

Requested by: swills
Sponsored by: Chelsio Communications

3 years agoEnsure the boot CPU is CPU 0 on arm64
andrew [Mon, 7 Dec 2020 17:54:49 +0000 (17:54 +0000)]
Ensure the boot CPU is CPU 0 on arm64

We assume the boot CPU is always CPU 0 on arm64. To allow for this reserve
cpuid 0 for the boot CPU in the ACPI and FDT cases but otherwise start the
CPU as normal. We then check for the boot CPU in start_cpu and return as if
it was started.

While here extract the FDT CPU init code into a new function to simplify
cpu_mp_start and return FALSE from start_cpu when the CPU fails to start.

Reviewed by: mmel
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D27497

3 years agoProperly define the bool type in the BSD kernel shim.
hselasky [Mon, 7 Dec 2020 16:08:31 +0000 (16:08 +0000)]
Properly define the bool type in the BSD kernel shim.

MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoarm: Let the GDB stub write to SP, LR and GP registers
markj [Mon, 7 Dec 2020 15:09:28 +0000 (15:09 +0000)]
arm: Let the GDB stub write to SP, LR and GP registers

This can be handy if gdb's stack unwinder fails, for example because of
a bug in kgdb's trap frame unwinder.

PR: 251463
Submitted by: Dmitry Salychev <dsl@mcusim.org>
MFC after: 1 week

3 years agoAdd missing refcount.9 MLINKS
markj [Mon, 7 Dec 2020 14:53:34 +0000 (14:53 +0000)]
Add missing refcount.9 MLINKS

3 years agoiflib: Avoid leaking the freelist bitmaps upon driver detach
markj [Mon, 7 Dec 2020 14:53:14 +0000 (14:53 +0000)]
iflib: Avoid leaking the freelist bitmaps upon driver detach

Submitted by: Sai Rajesh Tallamraju <stallamr@netapp.com>
MFC after: 2 weeks
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D27342

3 years agoiflib: Detach tasks upon device registration failure
markj [Mon, 7 Dec 2020 14:52:57 +0000 (14:52 +0000)]
iflib: Detach tasks upon device registration failure

In some error paths we would fail to detach from the iflib taskqueue
groups.  Also move the detach code into its own subroutine instead of
duplicating it.

Submitted by: Sai Rajesh Tallamraju <stallamr@netapp.com>
MFC after: 2 weeks
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D27342

3 years agoloader: xdr_array is missing count
tsoome [Mon, 7 Dec 2020 11:25:18 +0000 (11:25 +0000)]
loader: xdr_array is missing count

The integer arrays are encoded in nvlist as counted array <count, i0, i1...>,
loader xdr_array() is missing the count. This will affect the pool import when
there are hole devices in pool.

Also fix the new data add and print functions.

3 years agoFix compilation after r368397.
hselasky [Mon, 7 Dec 2020 11:18:51 +0000 (11:18 +0000)]
Fix compilation after r368397.

MFC after: 3 days
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoAdd missing busdma prototypes for load and unload and implement dummy sync
hselasky [Mon, 7 Dec 2020 10:51:19 +0000 (10:51 +0000)]
Add missing busdma prototypes for load and unload and implement dummy sync
function for kernel bootloader shim code.

MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoTidy up code a bit. Add missing section comments.
hselasky [Mon, 7 Dec 2020 10:21:01 +0000 (10:21 +0000)]
Tidy up code a bit. Add missing section comments.
No functional change.

MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoPrefer using the MIN() function macro over the min() inline function
hselasky [Mon, 7 Dec 2020 09:48:06 +0000 (09:48 +0000)]
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".

MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoAllow sys/refcount.h to be used by standalone builds.
hselasky [Mon, 7 Dec 2020 09:21:06 +0000 (09:21 +0000)]
Allow sys/refcount.h to be used by standalone builds.
No functional change.

MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoFix the source directory when installing the results. The install
hrs [Mon, 7 Dec 2020 04:45:29 +0000 (04:45 +0000)]
Fix the source directory when installing the results.  The install
target did not install them actually.

Spotted by: Thomas Munro, bapt, yuripv

3 years agouma: Make uma_zone_set_maxcache() work better with small limits
markj [Sun, 6 Dec 2020 22:45:50 +0000 (22:45 +0000)]
uma: Make uma_zone_set_maxcache() work better with small limits

The old implementation chose the largest bucket zone such that if the
per-CPU caches are fully populated, the total number of items cached is
no larger than the specified limit.  If no such zone existed, UMA would
not do any caching.

We can now use uz_bucket_size_max to set a precise limit on the number
of items in a zone's bucket, so the total size of per-CPU caches can be
bounded more easily.  Implement a new policy in uma_zone_set_maxcache():
choose a bucket size such that up to half of the limit can be cached in
per-CPU caches, with the rest going to the full bucket cache.  This
fixes a problem with the kstack_cache zone: the limit of 4 * mp_ncpus
items meant that the zone would not do any caching, defeating the whole
purpose of the zone.  That's because the smallest bucket size holds up
to 2 items and we may cache up to 3 full buckets per CPU, and
2 * 3 * mp_ncpus > 4 * mp_ncpus.

Reported by: mjg
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27168

3 years agouma: Enforce the use of uz_bucket_size_max in the free path
markj [Sun, 6 Dec 2020 22:45:39 +0000 (22:45 +0000)]
uma: Enforce the use of uz_bucket_size_max in the free path

uz_bucket_size_max is the maximum permitted bucket size.  When filling a
new bucket to satisfy uma_zalloc(), the bucket is populated with at most
uz_bucket_size_max items.  The maximum number of entries in the bucket
may be larger.  When freeing items, however, we will fill per-CPPU
buckets up to their maximum number of entries, potentially exceeding
uz_bucket_size_max.  This makes it difficult to precisely limit the
number of items that may be cached in a zone.  For example, if one wants
to limit buckets to 1 entry for a particular zone, that's not possible
since the smallest bucket holds up to 2 entries.

Try to solve the problem by using uz_bucket_size_max to limit the number
of entries in a bucket.  Note that the ub_entries field is initialized
upon every bucket allocation.  Most zones are not affected since they do
not impose any specific limit on the maximum bucket size.

While here, remove the UMA_ZONE_MINBUCKET flag.  It was unused and we
now have uma_zone_set_maxcache() to control the zone's cache size more
precisely.

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