freebsd.git
2 years agobhyve nvme: Fix Identify Namespace, NSID=ffffffff
Chuck Tuffli [Sun, 30 Jan 2022 07:11:14 +0000 (23:11 -0800)]
bhyve nvme: Fix Identify Namespace, NSID=ffffffff

If the NVMe Controller doesn't support Namespace Management, it should
return "Invalid Namespace or Format" when the Host request Identify
Namespace with the global NSID value.

Fixes UNH IOL 16.0 Test 9.1, Case 6

Reviewed by: imp, allanjude
Tested by:      jason@tubnor.net
MFC after:      1 month
Differential Revision: https://reviews.freebsd.org/D33578

2 years agobhyve nvme: Fix Set Features, AEN
Chuck Tuffli [Sun, 30 Jan 2022 07:10:59 +0000 (23:10 -0800)]
bhyve nvme: Fix Set Features, AEN

NVMe Controllers which do not support Endurance Groups must return an
error when the Endurance Group Event Aggregate Log Change Notices bit is
set in Set Features, Asynchronous Event Configuration.

Fixes UNH IOL Test 3.12, Case 8

Tested by:      jason@tubnor.net
MFC after:      1 month
Differential Revision: https://reviews.freebsd.org/D33577

2 years agobhyve nvme: Fix reported VWC value
Chuck Tuffli [Sun, 30 Jan 2022 07:10:42 +0000 (23:10 -0800)]
bhyve nvme: Fix reported VWC value

v1.4 and later NVMe Controllers report "Flush all Namespaces" support
differently.

Fixes UNH IOL 16.0 Test 2.6, Case 3

Reviewed by: imp, allanjude
Tested by:      jason@tubnor.net
MFC after:      1 month
Differential Revision: https://reviews.freebsd.org/D33576

2 years agobhyve nvme: Fix LBA out-of-range calculation
Chuck Tuffli [Sun, 30 Jan 2022 07:09:57 +0000 (23:09 -0800)]
bhyve nvme: Fix LBA out-of-range calculation

The function which checks for a valid LBA range mistakenly named an
input value as NLB ("Number of Logical Blocks") instead of "number of
blocks". The NVMe specification defines NLB as a zero-based value (i.e.
NLB=0x0 represents 1 block, 0x1 is 2 blocks, etc.), but the passed
parameter is a 1's-based value.

Fix is to rename the variable to avoid future confusion.

While in the neighborhood, also check that the starting LBA is less than
the size of the backing storage to avoid an integer overflow.

Reviewed by: imp, allanjude, jhb
Tested by:      jason@tubnor.net
MFC after:      1 month
Differential Revision: https://reviews.freebsd.org/D33575

2 years agobhyve nvme: Add Select support to Get Features
Chuck Tuffli [Sun, 30 Jan 2022 07:09:35 +0000 (23:09 -0800)]
bhyve nvme: Add Select support to Get Features

Implement basic support for the SEL field of Get Features. This returns
information about Namespace Specific features.

Fixes UNH ILO 16.0 Test 1.2, Case 13

Reviewed by: imp, allanjude
Tested by:      jason@tubnor.net
MFC after:      1 month
Differential Revision: https://reviews.freebsd.org/D33574

2 years agobhyve nvme: Update v1.4 Identify Controller data
Chuck Tuffli [Sun, 30 Jan 2022 07:09:10 +0000 (23:09 -0800)]
bhyve nvme: Update v1.4 Identify Controller data

Compliant v1.4 Controllers must report a Controller Type (CNTRLTYPE).
Also, do not advertise secure erase functionality in the Format NVM
Attributes field of the Identify Controller data structure as the
Controller does not implement secure erase.

Fixes UNH ILO Test 1.1, Case 2

Reviewed by: imp, allanjude
Tested by:      jason@tubnor.net
MFC after:      1 month
Differential Revision: https://reviews.freebsd.org/D33573

2 years agobhyve nvme: Add Temperature Threshold support
Chuck Tuffli [Sun, 30 Jan 2022 07:08:47 +0000 (23:08 -0800)]
bhyve nvme: Add Temperature Threshold support

This adds the ability for a guest OS to send Set / Get Feature,
Temperature Threshold commands. The implementation assumes a constant
temperature and will generate an Asynchronous Event Notification if the
specified threshold is above/below this value. Although the
specification allows 9 temperature values, this implementation only
implements the Composite Temperature.

While in the neighborhood, move the clear of the CSTS register in the
reset function after all other cleanup. This avoids a race with the
guest thinking the reset is complete (i.e. CSTS.RDY = 0) before the NVMe
emulation is actually complete with the reset.

Fixes UNH IOL 16.0 Test 1.7, cases 1, 2, and 4.

Tested by:      jason@tubnor.net
MFC after:      1 month
Differential Revision: https://reviews.freebsd.org/D33572

2 years agobhyve nvme: Fix Set Features
Chuck Tuffli [Sun, 30 Jan 2022 07:07:44 +0000 (23:07 -0800)]
bhyve nvme: Fix Set Features

Be more conservative and only support the Features mandatory for an I/O
Controller.

Avoids a "hang" in UNH test 1.2.10 associated with Predictable Latency
Mode Configuration and Host Behavior Support features.

Tested by:      jason@tubnor.net
MFC after:      1 month
Differential Revision: https://reviews.freebsd.org/D33571

2 years agobhyve nvme: Remove redundant AER Limit checks
Chuck Tuffli [Sun, 30 Jan 2022 07:07:29 +0000 (23:07 -0800)]
bhyve nvme: Remove redundant AER Limit checks

The NVMe emulation checked if the Asynchronous Event Request Limit
(a.k.a AERL) would be exceeded in pci_nvme_aer_add(), but this function
is only called from nvme_opc_async_event_req() which also checks for
exceeding the AERL.

Reviewed by: imp, allanjude
Tested by:      jason@tubnor.net
MFC after:      1 month
Differential Revision: https://reviews.freebsd.org/D33570

2 years agobhyve nvme: Add missing Admin opcodes
Chuck Tuffli [Sun, 30 Jan 2022 07:07:04 +0000 (23:07 -0800)]
bhyve nvme: Add missing Admin opcodes

Don't treat unsupported Admin commands as Invalid Opcode. Instead return
the proper Invalid Field in Command.

Fixes UNH IOL test 1.17.2

Reviewed by: imp, allanjude
Tested by:      jason@tubnor.net
MFC after:      1 month
Differential Revision: https://reviews.freebsd.org/D33569

2 years agobhyve nvme: Implement Log Page Offset
Chuck Tuffli [Sun, 30 Jan 2022 07:06:46 +0000 (23:06 -0800)]
bhyve nvme: Implement Log Page Offset

Modify the Get Log Page command to parse the Log Page Offset fields to
support more recent versions of the NVMe specification.

Fixes various tests for UNH Test 1.3.*

Reviewed by: imp, allanjude
Tested by:      jason@tubnor.net
MFC after:      1 month
Differential Revision: https://reviews.freebsd.org/D33568

2 years agobhyve nvme: Fix Namespace Specific Set Features
Chuck Tuffli [Sun, 30 Jan 2022 07:06:23 +0000 (23:06 -0800)]
bhyve nvme: Fix Namespace Specific Set Features

Return an error if the feature specified in Set Features is Namespace
specific but the Namespace ID uses the Global Namespace tag.

Fixes UNH Test 1.2.7

Reviewed by: imp, allanjude
Tested by:      jason@tubnor.net
MFC after:      1 month
Differential Revision: https://reviews.freebsd.org/D33566

2 years agobhyve nvme: Fix NVM Format completion status
Chuck Tuffli [Sun, 30 Jan 2022 07:05:58 +0000 (23:05 -0800)]
bhyve nvme: Fix NVM Format completion status

The NVM Format command is unique among the Admin commands in that it
needs to finish asynchronously. For this reason, the emulation code
invented a synthetic completion status (NVME_NO_STATUS) to indicate that
the command was still in progress and the command processing loop should
not generate a completion message. The implementation used the value
0xffff for the synthetic value as this set both the Status Code and
Status Code Type fields to reserved values.

Format initialized the completion status to this value and expected
error cases to override it with a status code/type appropriate to the
situation. The macros used to set the NVMe status are careful not to
modify bit 0 (i.e. the phase bit), which with the synthetic completion
status, causes the phase bit to get out of sync. When running tests in a
guest with illegal NVM Format commands, Admin commands would eventually
hang because it appeared there were no completions due to the incorrect
phase bit value.

Fix is to only set NVME_NO_STATUS if the blockif delete command
succeeds. While in the neighborhood, add a missing break statement when
NVM Format is not supported.

Reviewed by: imp, allanjude
Tested by:      jason@tubnor.net
MFC after:      1 month
Differential Revision: https://reviews.freebsd.org/D33565

2 years agobhyve nvme: Advertise v1.4 support
Chuck Tuffli [Sun, 30 Jan 2022 07:04:25 +0000 (23:04 -0800)]
bhyve nvme: Advertise v1.4 support

Bump advertised NVMe support from v1.3 to v1.4

Reviewed by: allanjude
Tested by:      jason@tubnor.net
MFC after:      1 month
Differential Revision: https://reviews.freebsd.org/D33564

2 years agoApply llvm fix for assertion failure compiling recent libc++
Dimitry Andric [Sat, 29 Jan 2022 21:28:12 +0000 (22:28 +0100)]
Apply llvm fix for assertion failure compiling recent libc++

Merge commit c7c84b90879f from llvm git (by Adrian Prantl):

  [DwarfDebug] Refuse to emit DW_OP_LLVM_arg values wider than 64 bits

  DwarfExpression::addUnsignedConstant(const APInt &Value) only supports
  wider-than-64-bit values when it is used to emit a top-level DWARF
  expression representing the location of a variable. Before this change,
  it was possible to call addUnsignedConstant on >64 bit values within a
  subexpression when substituting DW_OP_LLVM_arg values.

  This can trigger an assertion failure (e.g. PR52584, PR52333) when it
  happens in a fragment (DW_OP_LLVM_fragment) expression, as
  addUnsignedConstant on >64 bit values splits the constant into separate
  DW_OP_pieces, which modifies DwarfExpression::OffsetInBits.

  This change papers over the assertion errors by bailing on overly wide
  DW_OP_LLVM_arg values. A more comprehensive fix might be to be to split
  wide values into pointer-sized fragments.

  [0] https://github.com/llvm/llvm-project/blob/e71fa03/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp#L799-L805

  Patch by Ricky Zhou!

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

MFC after: 3 days

2 years agostyle.mdoc.5: Document the conventions for -width
Mateusz Piotrowski [Sat, 29 Jan 2022 21:23:49 +0000 (22:23 +0100)]
style.mdoc.5: Document the conventions for -width

Reviewed by: debdrup
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D33394

2 years agoipheth.4: Simplify output filtering example
Mateusz Piotrowski [Sat, 29 Jan 2022 21:16:50 +0000 (22:16 +0100)]
ipheth.4: Simplify output filtering example

MFC after: 2 weeks

2 years agoipheth.4: Fix examples
Mateusz Piotrowski [Sat, 29 Jan 2022 21:13:42 +0000 (22:13 +0100)]
ipheth.4: Fix examples

It is now necessary to use the -d flag for some of the usbconfig(8)
invocations.

MFC after: 2 weeks

2 years agousbconfig.8: Sort flags according to style(9)
Mateusz Piotrowski [Sat, 29 Jan 2022 21:10:21 +0000 (22:10 +0100)]
usbconfig.8: Sort flags according to style(9)

MFC after: 2 weeks

2 years agousbconfig.8: Improve style and fix examples
Mateusz Piotrowski [Sat, 29 Jan 2022 20:59:29 +0000 (21:59 +0100)]
usbconfig.8: Improve style and fix examples

- Use Ar macros for arguments
- Stylize the argument synopsis to the -d flag
- Change the width of the list to one of the actual tags in the list
- Stylize "ugen" and "/dev/ugen" with Cm as those are constant strings,
  which are usually treated as command modifiers.
- Break long lines to reduce the number of warnings from linters
- Fix examples; the -d flag is now required when specifying the unit and
  the address with the "dot notation".

MFC after: 2 weeks

2 years agoapply.1: Use Ar for arguments
Mateusz Piotrowski [Fri, 28 Jan 2022 19:38:07 +0000 (20:38 +0100)]
apply.1: Use Ar for arguments

2 years agoifconfig: remove debug printf introduced in 779fd0534466
Alexander V. Chernikov [Sat, 29 Jan 2022 11:18:13 +0000 (11:18 +0000)]
ifconfig: remove debug printf introduced in 779fd0534466

Reported by: jhb

2 years agogeom_gate: Distinguish between classes of errors
Peter Jeremy [Sat, 29 Jan 2022 10:15:51 +0000 (21:15 +1100)]
geom_gate: Distinguish between classes of errors

The geom_gate API provides 2 distinct paths for exchanging error
details between the kernel and the userland client: Including an error
code in the g_gate_ctl_io structure passed in the ioctl(2) call or
having the ioctl(2) call return -1 with an error code in errno. The
latter reflects errors in the ioctl(2) call itself whilst the former
reflects errors within the geom_gate instance.

The G_GATE_CMD_START ioctl blocks waiting for an I/O request to be
directed to the geom_gate instance and the wait can fail
(necessitating an error return) if the geom_gate instance is destroyed
or if the msleep(9) fails. The code previously treated both error
cases indentically: Returning ECANCELED as a geom_gate instance error
(which the ggatec treats as a fatal error).  Whilst this is the correct
behaviour if the geom_gate instance is destroyed, a msleep(9) failure
is unrelated to the geom_gate instance itself and should be reported
as an ioctl(2) "failure".  The distinction is important because
msleep(9) can return ERESTART, which means the system call should be
retried (and this will occur automatically as part of the generic
syscall return processing).

This change alters the msleep(9) handling to directly return the error
code from msleep(9), which ensures ERESTART is correctly handled,
rather than being treated as a fatal error.

Reviewed by:    Johannes Totz <jo@bruelltuete.com>
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D33996

2 years agou3g: Add support Quectel EM12-G modem.
Alexander V. Chernikov [Sat, 29 Jan 2022 09:53:38 +0000 (09:53 +0000)]
u3g: Add support Quectel EM12-G modem.

Submitted by: <tda.77793 at gmail.com>
PR: 260218
MFC after: 2 weeks

2 years agosystat: Display seconds in vmstat mode
Peter Jeremy [Sat, 29 Jan 2022 09:41:19 +0000 (20:41 +1100)]
systat: Display seconds in vmstat mode

Providing a timestamp with seconds granularity helps make it obvious
that the display is updating.

Reviewed by:    mckusick
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D29181

2 years agolocate statistics: show number of longest path in database
Wolfram Schneider [Sat, 29 Jan 2022 07:13:28 +0000 (07:13 +0000)]
locate statistics: show number of longest path in database

2 years agosync improvements from concatdb.sh
Wolfram Schneider [Sat, 29 Jan 2022 07:10:18 +0000 (07:10 +0000)]
sync improvements from concatdb.sh

- stop on first error
- improve awk script: print the last two characters for bigram -  not the second word
- remove unnecessary checks
- use mktemp
- refactor

2 years agodummynet: dn_dequeue() may return NULL
Kristof Provost [Fri, 28 Jan 2022 10:10:04 +0000 (11:10 +0100)]
dummynet: dn_dequeue() may return NULL

If there are no more entries, or if we fail to restore the rcvif of a
queued mbuf dn_dequeue() can return NULL.
Cope with this.

Reviewed by: glebius
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D34078

2 years agombuf: do not restore dying interfaces
Kristof Provost [Thu, 27 Jan 2022 21:01:09 +0000 (22:01 +0100)]
mbuf: do not restore dying interfaces

When we remove an interface it is first removed from the interface list
V_ifnet (by if_unlink_ifnet()) and marked as IFF_DYING. We then wait for
any possible references to stop being used (i.e.
epoch_wait/epoch_drain_callbacks) before we tear it fully down.

However, the index in ifindex_table is not removed, so m_rcvif_restore()
can still find the (now dying) interface.

This results in panics, for example when dummynet restores the rcvif
pointer and passes a packet to ip6_input() we can panic because the
AF_INET6 domain has already been removed (so we end up dereferencing a
NULL pointer there).

Check that the interface is not dying before we restore it, which is
equivalent to checking its presence in V_ifnet, and thus ensures that
future accesses (while in NET_EPOCH) are safe.

Reviewed by: glebius
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D34076

2 years agodma: exit if invoked with invalid (zero) argc
Ed Maste [Fri, 28 Jan 2022 22:15:02 +0000 (17:15 -0500)]
dma: exit if invoked with invalid (zero) argc

This was prompted by the recent pkexec vulnerability (CVE-2021-4034).
This change is being made on general principle for setuid/setgid
binaries and is not in response to an actual issue.

Reviewed by: kevans, markj (both earlier)
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34087

2 years agosort: Fix message catalogue usage
Mark Johnston [Fri, 28 Jan 2022 17:49:28 +0000 (12:49 -0500)]
sort: Fix message catalogue usage

- Check that catopen() succeeded before calling catclose().  musl will
  crash in the latter if the catalogue descriptor is -1.
- Keep the message catalogue open for most of sort(1)'s actual
  operation.
- Don't use catgets(3) to print error messages if catopen(3) had failed.

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

2 years agoMake <vm/vm_extern.h> more self-contained.
John Baldwin [Fri, 28 Jan 2022 21:14:03 +0000 (13:14 -0800)]
Make <vm/vm_extern.h> more self-contained.

Add a nested include of <sys/systm.h> for recently added assertions.
Without this, existing code (such as in drm-kmod) needs to be patched
to add the newly required header.

While here, rewrite the assertions using KASSERT().

Reviewed by: dougm, alc, imp, kib
Differential Revision: https://reviews.freebsd.org/D34070

2 years agoiscsi: Allocate a dummy PDU for the internal nexus reset task.
John Baldwin [Fri, 28 Jan 2022 21:07:04 +0000 (13:07 -0800)]
iscsi: Allocate a dummy PDU for the internal nexus reset task.

When an iSCSI target session is terminated, an internal nexus reset
task is posted to abort existing tasks belonging to the session.
Previously, the ctl_io for this internal nexus reset stored a pointer
to the session in the slot that normally holds a pointer to the PDU
from the initiator that triggered the I/O request.  The completion
handler then assumed that any nexus reset I/O was due to an internal
request and fetched the session pointer (instead of the PDU pointer)
from the ctl_io.  However, it is possible to trigger a nexus reset via
an on-the-wire task management PDU.  If such a PDU were sent to the
target, then the completion handler would incorrectly treat this
request as an internal request and treat the pointer to the received
PDU as a pointer to the session instead.

To fix, allocate a dummy PDU for the internal reset task and use an
invalid opcode to differentiate internal nexus resets from resets
requested by the initiator.

PR: 260449
Reported by: Robert Morris <rtm@lcs.mit.edu>
Reviewed by: mav
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D34055

2 years agohwpmc: remove mips event definitions
Mitchell Horne [Fri, 28 Jan 2022 20:34:52 +0000 (16:34 -0400)]
hwpmc: remove mips event definitions

Reviewed by: imp, emaste
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34084

2 years agolibpmc: remove mips support
Mitchell Horne [Fri, 28 Jan 2022 20:34:36 +0000 (16:34 -0400)]
libpmc: remove mips support

Bye bye!

Reviewed by: imp, emaste
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34083

2 years agoglabel: Set G_CF_DIRECT_SEND/RECEIVE for taste consumer.
Alexander Motin [Fri, 28 Jan 2022 19:22:41 +0000 (14:22 -0500)]
glabel: Set G_CF_DIRECT_SEND/RECEIVE for taste consumer.

All I/O requests through the taste consumer are synchronous, done
with g_read_data() and without any locks held.  It makes no sense
to delegate the I/O to g_down/g_up threads.

This removes many of context switches during disk retaste.

MFC after: 2 weeks

2 years agoGEOM: Relax direct dispatch for GEOM threads.
Alexander Motin [Fri, 28 Jan 2022 19:12:29 +0000 (14:12 -0500)]
GEOM: Relax direct dispatch for GEOM threads.

The only cases when direct dispatch does not make sense is for I/O
submission from down thread and for completion from up thread.  In
all other cases, if both consumer and producer are OK about it, we
can save on context switches.

MFC after: 2 weeks

2 years agoifnet: garbage collect unused function ifaddr_byindex().
Gleb Smirnoff [Fri, 28 Jan 2022 17:51:52 +0000 (09:51 -0800)]
ifnet: garbage collect unused function ifaddr_byindex().

Last use was removed in 5adea417d49.

2 years agograid: Set G_CF_DIRECT_SEND for task consumer.
Alexander Motin [Fri, 28 Jan 2022 16:09:30 +0000 (11:09 -0500)]
graid: Set G_CF_DIRECT_SEND for task consumer.

Unlike normal consumers all taste consumer I/O is synchronous, done
with g_read_data() and without any locks held.  It makes no sense to
delegate I/O submission to g_down thread.

This should remove number of context switches during disk retaste.

MFC after: 2 weeks

2 years agodma: limit lines to 998 characters
Ed Maste [Fri, 28 Jan 2022 14:57:44 +0000 (09:57 -0500)]
dma: limit lines to 998 characters

Per RFC2822 the maximum transmitted line length is "998 characters...
excluding the CRLF."  In a file the maximum is 999 with the \n included.

Previously mail containing a line with exactly 999 characters would
bounce.

PR: 208261
Reported by: Helge Oldach
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

2 years agosctp(4): Fix a typo in an INVARIANTS panic message
Gordon Bergling [Fri, 28 Jan 2022 12:20:52 +0000 (13:20 +0100)]
sctp(4): Fix a typo in an INVARIANTS panic message

- s/failes/fails/

MFC after: 1 week

2 years agolinux: Provide dummy seccomp(2)
Edward Tomasz Napierala [Fri, 28 Jan 2022 10:55:11 +0000 (10:55 +0000)]
linux: Provide dummy seccomp(2)

Don't emit messages; this isn't any different from a Linux kernel
built without OPTIONS_SECCOMP, so the userspace already needs to know
how to deal with it.  This is also similar with how we handle seccomp
in linux_prctl().

Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D33808

2 years agostress2: Added a regresson test
Peter Holm [Fri, 28 Jan 2022 11:23:22 +0000 (12:23 +0100)]
stress2: Added a regresson test

Submitted by: Andriy Gapon <avg@FreeBSD.org>

2 years agodisextract: eliminate last use of __DECONST
Baptiste Daroussin [Fri, 28 Jan 2022 09:09:08 +0000 (10:09 +0100)]
disextract: eliminate last use of __DECONST

2 years agodistextract: simply code by using strsep(3)
Baptiste Daroussin [Fri, 28 Jan 2022 09:06:55 +0000 (10:06 +0100)]
distextract: simply code by using strsep(3)

2 years agobsddialog: import version 0.1
Alfonso Siciliano [Fri, 28 Jan 2022 08:25:38 +0000 (09:25 +0100)]
bsddialog: import version 0.1

Import bsddialog 0.1 Utility and Library, fully refatorized, API stable,
manuals completed, easier to maintain and improve.

Update deps for new API:
add mixedgauge consts, delete __DECONST and add bsddialog_geterror()
info to avoid silent errors

* tzsetup
* kbdmap
* distextract

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

2 years agobsddialog: import version 0.1
Alfonso Siciliano [Fri, 28 Jan 2022 08:14:55 +0000 (09:14 +0100)]
bsddialog: import version 0.1

2 years agoufs: handle LoR between snap lock and vnode lock
Kirk McKusick [Fri, 28 Jan 2022 07:00:51 +0000 (23:00 -0800)]
ufs: handle LoR between snap lock and vnode lock

When a filesystem is mounted all of its associated snapshots must
be activated. It first allocates a snapshot lock (snaplk) that will
be shared by all the snapshot vnodes associated with the filesystem.
As part of each snapshot file activation, it must replace its own
ufs vnode lock with the snaplk. In this way acquiring the snaplk
gives exclusive access to all the snapshots for the filesystem.

A write to a ufs vnode first acquires the ufs vnode lock for the
file to be written then acquires the snaplk. Once it has the snaplk,
it can check all the snapshots to see if any of them needs to make
a copy of the block that is about to be written. This ffs_copyonwrite()
code path establishes the ufs vnode followed by snaplk locking
order.

When a filesystem is unmounted it has to release all of its snapshot
vnodes. Part of doing the release is to revert the snapshot vnode
from using the snaplk to using its original vnode lock. While holding
the snaplk, the vnode lock has to be acquired, the vnode updated
to reference it, then the snaplk released. Acquiring the vnode lock
while holding the snaplk violates the ufs vnode then snaplk order.
Because the vnode lock is unused, using LK_EXCLUSIVE | LK_NOWAIT
to acquire it will always succeed and the LK_NOWAIT prevents the
reverse lock order from being recorded.

This change was made in January 2021 (173779b98f) to avoid an LOR
violation in ffs_snapshot_unmount(). The same LOR issue was recently
found again when removing a snapshot in ffs_snapremove() which must
also revert the snaplk to the original vnode lock as part of freeing it.

The unwind in ffs_snapremove() deals with the case in which the
snaplk is held as a recursive lock holding multiple references.
Specifically an equal number of references are made on the vnode
lock. This change factors out the lock reversion operations into a
new function revert_snaplock() which handles both the recursive
locks and avoids the LOR. The new revert_snaplock() function is
then used in both ffs_snapshot_unmount() and in ffs_snapremove().

Reviewed by:  kib
Tested by:    Peter Holm
MFC after:    2 weeks
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D33946

2 years agoefitable(8): Add missing `-u` in the manpage
Trond Endrestol [Fri, 28 Jan 2022 01:04:38 +0000 (03:04 +0200)]
efitable(8): Add missing `-u` in the manpage

PR: 261524
MFC after: 3 days

2 years agonfsclient: Delete unused function nfscl_getcookie()
Rick Macklem [Thu, 27 Jan 2022 23:30:26 +0000 (15:30 -0800)]
nfsclient: Delete unused function nfscl_getcookie()

The function nfscl_getcookie(), which is essentially the
same as ncl_getcookie(), is never called, so delete it.
This is probably cruft left over from the port of the
NFSv4 code to FreeBSD several years ago.

Found while modifying the code to better use the
directory offset cookies.

MFC after: 2 weeks

2 years agostdio: add test for 86a16ada1ea608408cec370: fflush() handling of errors
Konstantin Belousov [Tue, 25 Jan 2022 21:56:08 +0000 (23:56 +0200)]
stdio: add test for 86a16ada1ea608408cec370: fflush() handling of errors

PR: 76398
Reviewed by: emaste, markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D34044

2 years agortld: Fix assertion I broke.
John Baldwin [Thu, 27 Jan 2022 22:42:40 +0000 (14:42 -0800)]
rtld: Fix assertion I broke.

textrel is a bool, not a pointer.

Pointy hat to: jhb
Reported by: kevans
Fixes: 6a2d75d24857 rtld: Trim a few more MIPS #ifdefs.

2 years agoChange the return value of _Unwind_GetCFA in include/unwind.h.
John Baldwin [Thu, 27 Jan 2022 22:42:40 +0000 (14:42 -0800)]
Change the return value of _Unwind_GetCFA in include/unwind.h.

I tested the original commit as part of a series that culminates in
removing this header and installing LLVM libunwind's unwind.h in its
place so missed updating this header as was done in b84693501af6.

Pointy hat to: jhb
Reported by: kevans
Fixes: 3a502289d316 Use uintptr_t for return type of _Unwind_GetCFA.

2 years agoar: Avoid overwriting the stdout file stream pointer
Mark Johnston [Thu, 27 Jan 2022 22:10:17 +0000 (17:10 -0500)]
ar: Avoid overwriting the stdout file stream pointer

This doesn't work with musl, which defines stdout as FILE * const.
Instead, explicitly pass the desired output stream to ar_read_archive().

No functional change intended.

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

2 years agodma: update to 2022-01-27 snapshot
Ed Maste [Thu, 27 Jan 2022 19:30:58 +0000 (14:30 -0500)]
dma: update to 2022-01-27 snapshot

2 years agodma: import 2022-01-27 git snapshot edb7c61b6463
Ed Maste [Thu, 27 Jan 2022 19:06:22 +0000 (14:06 -0500)]
dma: import 2022-01-27 git snapshot edb7c61b6463

Obtained from: https://github.com/corecode/dma edb7c61b6463

2 years agoRemove terasic drivers used on the Cambridge BERI tablet.
John Baldwin [Thu, 27 Jan 2022 19:00:48 +0000 (11:00 -0800)]
Remove terasic drivers used on the Cambridge BERI tablet.

Reviewed by: brooks
Sponsored by: The University of Cambridge, Google Inc.
Differential Revision: https://reviews.freebsd.org/D34057

2 years agortld: Trim a few more MIPS #ifdefs.
John Baldwin [Thu, 27 Jan 2022 19:00:24 +0000 (11:00 -0800)]
rtld: Trim a few more MIPS #ifdefs.

Reviewed by: imp, kib
Sponsored by: The University of Cambridge, Google Inc.
Differential Revision: https://reviews.freebsd.org/D34052

2 years agoUse uintptr_t for return type of _Unwind_GetCFA.
John Baldwin [Thu, 27 Jan 2022 18:53:21 +0000 (10:53 -0800)]
Use uintptr_t for return type of _Unwind_GetCFA.

This matches the type in other unwind headers.

Reviewed by: dim, emaste
Differential Revision: https://reviews.freebsd.org/D34050

2 years agoUse an unsigned 64-bit integer for exception class.
John Baldwin [Thu, 27 Jan 2022 18:34:35 +0000 (10:34 -0800)]
Use an unsigned 64-bit integer for exception class.

This matches the type in other unwind headers (LLVM libunwind,
libcxxrt, glibc).

NB: include/unwind.h is not installed but is only used by libthr

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

2 years agotcp: Tidying up the conditionals for unwinding a spurious RTO
Richard Scheffenegger [Thu, 27 Jan 2022 17:59:21 +0000 (18:59 +0100)]
tcp: Tidying up the conditionals for unwinding a spurious RTO

- Use the semantically correct TSTMP_xx macro when comparing
  timestamps. (No functional change)
- check for bad retransmits only when TSopt is present in ACK
  (don't assume there will be a valid TSopt in the TCP options struct)
- exclude tsecr == 0, since that most likely indicates an
  invalid ts echo return (tsecr) value.

Reviewed By: tuexen, #transport
MFC after:   3 days
Sponsored by:        NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D34062

2 years agotcp: Rewind erraneous RTO only while performing RTO retransmissions
Richard Scheffenegger [Thu, 27 Jan 2022 17:35:47 +0000 (18:35 +0100)]
tcp: Rewind erraneous RTO only while performing RTO retransmissions

Under rare circumstances, a spurious retranmission is
incorrectly detected and rewound, messing up various tcpcb values,
which can lead to a panic when SACK is in use.

Reviewed By: tuexen, chengc_netapp.com, #transport
MFC after:   3 days
Sponsored by:        NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D33979

2 years agocp: fix some cases with infinite recursion
Kyle Evans [Thu, 27 Jan 2022 18:02:17 +0000 (12:02 -0600)]
cp: fix some cases with infinite recursion

As noted in the PR, cp -R has some surprising behavior.  Typically, when
you `cp -R foo bar` where both foo and bar exist, foo is cleanly copied
to foo/bar.  When you `cp -R foo foo` (where foo clearly exists), cp(1)
goes a little off the rails as it creates foo/foo, then discovers that
and creates foo/foo/foo, so on and so forth, until it eventually fails.

POSIX doesn't seem to disallow this behavior, but it isn't very useful.
GNU cp(1) will detect the recursion and squash it, but emit a message in
the process that it has done so.

This change seemingly follows the GNU behavior, but it currently doesn't
warn about the situation -- the author feels that the final product is
about what one might expect from doing this and thus, doesn't need a
warning.  The author doesn't feel strongly about this.

PR: 235438
Reviewed by: bapt
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D33944

2 years agortsock: always set m_pkthdr.rcvif when queueing on netisr
Gleb Smirnoff [Thu, 27 Jan 2022 17:41:31 +0000 (09:41 -0800)]
rtsock: always set m_pkthdr.rcvif when queueing on netisr

netisr uses global workstreams and after dequeueing an mbuf it
uses rcvif to get the VNET of the mbuf.  Of course, this is not
needed when kernel is compiled without VIMAGE.  It came out that
routing socket does not set rcvif if compiled without VIMAGE.
Make this assignment not depending on VIMAGE option.

Fixes: 6871de9363e5

2 years agombuf: make M_ASSERT_NO_SND_TAG() as strict as other similar asserts
Gleb Smirnoff [Thu, 27 Jan 2022 17:41:31 +0000 (09:41 -0800)]
mbuf: make M_ASSERT_NO_SND_TAG() as strict as other similar asserts

Fixes: 17cbcf33c3b6

2 years agoRemove SMALL conditionals from gzip
Tom Jones [Thu, 27 Jan 2022 17:24:45 +0000 (17:24 +0000)]
Remove SMALL conditionals from gzip

gzip has SMALL conditionals which enable building a reduced size version
of the binary. These exist as part of the introduction of BSD licensed
gzip in 2004 in NetBSD and appear to have been required to reach a size
for inclusion in their install media. For more information see commits
to gzip in the NetBSD tree on the 28th of March 2004.

SMALL doesn't appear to be hooked up to our build system and
complicates gzip quite a bit.

Reviewed by: kevans, imp
Sponsored by: Klara Inc.
Differential Revision: https://reviews.freebsd.org/D34047

2 years agotests: fix posix_spawnp_enoexec_fallback_null_argv0
Kyle Evans [Thu, 27 Jan 2022 17:22:49 +0000 (11:22 -0600)]
tests: fix posix_spawnp_enoexec_fallback_null_argv0

This test was written because execvp was found to improperly handle the
argc == 0 case when it falls back from an ENOEXEC.  We could probably
mostly revert it now, but let's just fix the test for the time being and
circle back later to decide if we want to simplify execvp.  The test
will likely remain either way just to make sure execvp isn't working
around the newly enforced restriction with the fallback.

Fixes: 301cb491ea41 ("execvp: fix up the ENOEXEC fallback")
Reported by: jenkins via lwhsu@

2 years agoFix test output when gzip is run with -tlv
Tom Jones [Thu, 27 Jan 2022 17:17:13 +0000 (17:17 +0000)]
Fix test output when gzip is run with -tlv

When run with test, verbose and list we need to parse the file otherwise
the test output is "NOT OK" even for the file is valid.

Reviewed by: kevans, allanjude, imp
Sponsored by: Klara Inc.
Differential Revision: https://reviews.freebsd.org/D34046

2 years agobsdinstall: Add quotes around error message argument
Tom Jones [Thu, 27 Jan 2022 17:10:06 +0000 (17:10 +0000)]
bsdinstall: Add quotes around error message argument

When error is called with a message with spaces (and probably multiple
lines) these are passed into dialog unquoted and an error message was
presented, wrap with quotes.

Reviewed by: bapt, allanjude
Sponsored by:   Ampere Computing LLC
Sponsored by:   Klara Inc.
Differential Revision: https://reviews.freebsd.org/D33918

2 years agommc_da: create disk(9) for pre-2.0 SD cards
Andriy Gapon [Thu, 27 Jan 2022 16:49:27 +0000 (18:49 +0200)]
mmc_da: create disk(9) for pre-2.0 SD cards

It does not look like there is anything in mmc_da code that actually
requires protocol 2.0 or later.  dev/mmc code also does not have such a
restriction.

Tested with a very old 2GB mini-SD card.  Prior to this change mmc_da
would claim the card but would not expose it to GEOM.

Without MMCCAM:
 mmc0: <MMC/SD bus> on sdhci_pci0
 mmc0: Probing bus
 mmc0: SD probe: OK (OCR: 0x00ff8000)
 mmc0: Current OCR: 0x00ff8000
 mmc0: CMD8 failed, RESULT: 1
 mmc0: Probing cards
 mmc0: New card detected (CID 1c53565344432020100002982e007600)
 mmc0: New card detected (CSD 005e00325f5a83d02db7ffbf96800000)
 mmc0: Card at relative address 0xb368 added:
 mmc0:  card: SD SDC   1.0 SN 0002982E MFG 06/2007 by 28 SV
 mmc0:  quirks: 0
 mmc0:  bus: 4bit, 50MHz (high speed timing)
 mmc0:  memory: 3998720 blocks, erase sector 256 blocks
 mmc0: setting transfer rate to 50.000MHz (high speed timing)
 GEOM: new disk mmcsd0
 mmcsd0: 2GB <SD SDC   1.0 SN 0002982E MFG 06/2007 by 28 SV> at mmc0 50.0MHz/4bit/65535-block
 mmc0: setting bus width to 4 bits high speed timing

With MMCCAM and this change:
 sdda0 at sdhci_slot0 bus 0 scbus2 target 0 lun 0
 sdda0: Relative addr: 0000b368
 Card features: <Memory>
 sdda0: Serial Number 0002982E
 sdda0: SD SDC   1.0 SN 0002982E MFG 06/2007 by 28 SV
 GEOM: new disk sdda0

Reviewed by: manu
MFC after: 3 weeks

2 years agoRevert b58ca5df0bb7 ("vfs: remove the now unused insmntque1")
Mateusz Guzik [Thu, 27 Jan 2022 16:24:32 +0000 (16:24 +0000)]
Revert b58ca5df0bb7 ("vfs: remove the now unused insmntque1")

I was somehow convinced that insmntque calls insmntque1 with a NULL
destructor. Unfortunately this worked well enough to not immediately
blow up in simple testing.

Keep not using the destructor in previously patched filesystems though
as it avoids unnecessary casts.

Noted by: kib
Reported by: pho

2 years agotcp: fix leaks in tcp_chg_pacing_rate error paths
Andrew Gallatin [Thu, 27 Jan 2022 15:35:03 +0000 (10:35 -0500)]
tcp: fix leaks in tcp_chg_pacing_rate error paths

tcp_chg_pacing_rate() is expected to release the hw rate limit table,
but failed to do so in several error cases, leading to ever
increasing counts of flows using the rate.

This patch was mostly done by rrs

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D34058
Reviewed by: hselasky, rrs,  jhb (inital version, outside of Differential)

2 years agoFix a memory leak when ip_output_send() returns EAGAIN due to send tag issues
Andrew Gallatin [Thu, 27 Jan 2022 15:28:15 +0000 (10:28 -0500)]
Fix a memory leak when ip_output_send() returns EAGAIN due to send tag issues

When ip_output_send() returns EAGAIN due to issues with send tags (route
change, lagg failover, etc), it must free the mbuf. This is because
ip_output_send() was written as a wrapper/replacement for a direct
call to  if_output(), and the contract with if_output() has
historically been that it owns the mbufs once called. When
ip_output_send() failed to free mbufs, it violated this assumption
and lead to leaked mbufs.

This was noticed when using NIC TLS in combination with hardware
rate-limited connections. When seeing lots of NIC output drops
triggered ratelimit send tag changes, we noticed we were leaking
ktls_sessions, send tags and mbufs. This was due ip_output_send()
leaking mbufs which held references to ktls_sessions, which in
turn held references to send tags.

Many thanks to jbh, rrs, hselasky and markj for their help in
debugging this.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D34054
Reviewed by: hselasky, jhb, rrs
MFC after: 2 weeks

2 years agogeom: Assert that BIO_SPEEDUP BIOs have bio_data set to NULL
Mark Johnston [Thu, 27 Jan 2022 14:58:19 +0000 (09:58 -0500)]
geom: Assert that BIO_SPEEDUP BIOs have bio_data set to NULL

Like BIO_FLUSH, there is no reason for consumers to pass a BIO_SPEEDUP
request with non-NULL bio_data, so assert this.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

2 years agoshsec: Allocate data blocks only for BIO_READ/WRITE requests
Mark Johnston [Thu, 27 Jan 2022 14:53:02 +0000 (09:53 -0500)]
shsec: Allocate data blocks only for BIO_READ/WRITE requests

In particular, there is no need to allocate a data block when passing
BIO_FLUSH requests to child providers, and g_io_request() asserts that
bp->bio_data == NULL for such requests.

PR: 255131
Reported and tested by: nvass@gmx.com
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

2 years agoAdd PT_GETREGSET
Andrew Turner [Mon, 24 Jan 2022 11:24:17 +0000 (11:24 +0000)]
Add PT_GETREGSET

This adds the PT_GETREGSET and PT_SETREGSET ptrace types. These can be
used to access all the registers from a specified core dump note type.
The NT_PRSTATUS and NT_FPREGSET notes are initially supported. Other
machine-dependant types are expected to be added in the future.

The ptrace addr points to a struct iovec pointing at memory to hold the
registers along with its length. On success the length in the iovec is
updated to tell userspace the actual length the kernel wrote or, if the
base address is NULL, the length the kernel would have written.

Because the data field is an int the arguments are backwards when
compared to the Linux PTRACE_GETREGSET call.

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

2 years agog_mirror: don't fail reads while losing next-to-last disk
Andriy Gapon [Thu, 27 Jan 2022 10:49:04 +0000 (12:49 +0200)]
g_mirror: don't fail reads while losing next-to-last disk

I observed a situation where some read requests failed when a 2-way geom
mirror lost one disk.  The problem appears to be in the logic that skips
retrying a failed request when a mirror has only one active disk.
Generally, that makes sense.  But during a transition from two disks to
one it is possible that the request failed on the failing disk before it
was inactivated and, so, the remaining active disk is the disk that
should be tried.

This change adds an additional check to ensure that it was the (only)
active disk that was already tried.

Reviewed by: mav
MFC after: 3 weeks

2 years agonetpfil tests: re-enable dummynet tests
Kristof Provost [Thu, 27 Jan 2022 09:16:21 +0000 (10:16 +0100)]
netpfil tests: re-enable dummynet tests

These had been disabled due to panics with queued packets keeping
pointers (in m->m_pkthdr.rcvif) to removed interfaces.
This issue has been resolved in 165746f4e4, so the tests can be run
again.

Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years agonetpfil tests: test removing interfaces with pending dummynet packets
Kristof Provost [Fri, 19 Nov 2021 22:05:48 +0000 (23:05 +0100)]
netpfil tests: test removing interfaces with pending dummynet packets

Dummynet queues packets with an associated struct ifnet pointer. Ensure
that things do not explode if that interface goes away with packets
still in the queue.

Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D33065

2 years agolibpfctl: fix creatorid endianness
Kristof Provost [Fri, 21 Jan 2022 16:50:15 +0000 (17:50 +0100)]
libpfctl: fix creatorid endianness

We provide the hostid (which is the state creatorid) to the kernel as a
big endian number (see pfctl/pfctl.c pfctl_set_hostid()), so convert it
back to system endianness when we get it from the kernel.

This avoids a confusing mismatch between the value the user configures
and the value displayed in the state.

MFC after: 3 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D33989

2 years agopfctl: improve error reporting for routehost
Kristof Provost [Wed, 5 Jan 2022 20:31:02 +0000 (21:31 +0100)]
pfctl: improve error reporting for routehost

If an invalid (i.e. overly long) interface name is specified error out
immediately, rather than in expand_rule() so we point at the incorrect
line.

PR: 260958
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D34008

2 years agonetisr: serialize/restore m_pkthdr.rcvif when queueing mbufs
Gleb Smirnoff [Thu, 27 Jan 2022 05:58:50 +0000 (21:58 -0800)]
netisr: serialize/restore m_pkthdr.rcvif when queueing mbufs

Reviewed by: kp
Differential revision: https://reviews.freebsd.org/D33268

2 years agodummynet: use m_rcvif_serialize/restore when queueing packets
Gleb Smirnoff [Thu, 27 Jan 2022 05:58:50 +0000 (21:58 -0800)]
dummynet: use m_rcvif_serialize/restore when queueing packets

This fixed panic with interface being removed while packet
was sitting on a queue.  This allows to pass all dummynet
tests including forthcoming dummynet:ipfw_interface_removal
and dummynet:pf_interface_removal and demonstrates use of
m_rcvif_serialize() and m_rcvif_restore().

Reviewed by: kp
Differential revision: https://reviews.freebsd.org/D33267

2 years agoifnet/mbuf: provide KPI to serialize/restore m->m_pkthdr.rcvif
Gleb Smirnoff [Thu, 27 Jan 2022 05:58:50 +0000 (21:58 -0800)]
ifnet/mbuf: provide KPI to serialize/restore m->m_pkthdr.rcvif

Supplement ifindex table with generation count and use it to
serialize & restore an ifnet pointer.

Reviewed by: kp
Differential revision: https://reviews.freebsd.org/D33266
Fun note: git show e6abef09187a

2 years agoifnet: make if_index global
Gleb Smirnoff [Thu, 27 Jan 2022 05:58:44 +0000 (21:58 -0800)]
ifnet: make if_index global

Now that ifindex is static to if.c we can unvirtualize it.  For lifetime
of an ifnet its index never changes.  To avoid leaking foreign interfaces
the net.link.generic.system.ifcount sysctl and the ifnet_byindex() KPI
filter their returned value on curvnet.  Since if_vmove() no longer
changes the if_index, inline ifindex_alloc() and ifindex_free() into
if_alloc() and if_free() respectively.

API wise the only change is that now minimum interface index can be
greater than 1.  The holes in interface indexes were always allowed.

Reviewed by: kp
Differential revision: https://reviews.freebsd.org/D33672

2 years agotests/sys/net/routing: remove bandaid against old epair(4) panic
Gleb Smirnoff [Thu, 27 Jan 2022 05:58:43 +0000 (21:58 -0800)]
tests/sys/net/routing: remove bandaid against old epair(4) panic

2 years agotests/sys/net/epair: don't leak the interface after the test
Gleb Smirnoff [Thu, 27 Jan 2022 05:08:50 +0000 (21:08 -0800)]
tests/sys/net/epair: don't leak the interface after the test

2 years agonullfs: ansify fs/nullfs/null_subr.c
Mateusz Guzik [Sat, 18 Sep 2021 10:25:40 +0000 (12:25 +0200)]
nullfs: ansify fs/nullfs/null_subr.c

2 years agovfs: remove the now unused insmntque1
Mateusz Guzik [Thu, 27 Jan 2022 00:00:24 +0000 (01:00 +0100)]
vfs: remove the now unused insmntque1

Bump __FreeBSD_version to 1400052.

2 years agounionfs: stop using insmntque1
Mateusz Guzik [Wed, 26 Jan 2022 23:57:32 +0000 (00:57 +0100)]
unionfs: stop using insmntque1

It adds nothing of value over insmntque.

2 years agotmpfs: stop using insmntque1
Mateusz Guzik [Wed, 26 Jan 2022 23:56:12 +0000 (00:56 +0100)]
tmpfs: stop using insmntque1

It adds nothing of value over insmntque.

2 years agonullfs: stop using insmntque1
Mateusz Guzik [Wed, 26 Jan 2022 23:53:59 +0000 (00:53 +0100)]
nullfs: stop using insmntque1

It adds nothing of value over insmntque.

2 years agofdescfs: stop using insmntque1
Mateusz Guzik [Wed, 26 Jan 2022 23:52:16 +0000 (00:52 +0100)]
fdescfs: stop using insmntque1

It adds nothing of value over insmntque.

2 years agodevfs: stop using insmntque1
Mateusz Guzik [Wed, 26 Jan 2022 23:51:41 +0000 (00:51 +0100)]
devfs: stop using insmntque1

It adds nothing of value over insmntque.

2 years agoFix test of ses(4) when there is no SES device exists
Li-Wen Hsu [Wed, 26 Jan 2022 23:11:17 +0000 (07:11 +0800)]
Fix test of ses(4) when there is no SES device exists

glob(3) returns GLOB_NOMATCH if GLOB_NOCHECK or GLOB_NOMAGIC flag is not
passed so ATF_REQUIRE_EQ(r, 0) will cause a precondition check failure if no
/dev/ses* exists.

Remove calling of atf_tc_skip() in ATF_TC_CLEANUP() because it would let
the clean up procedure unfinish.

While here, fix a set-but-not-used warning.

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

2 years agoRevert "LinuxKPI: Allow wake_up to be executed within a critical section"
Vladimir Kondratyev [Wed, 26 Jan 2022 22:27:01 +0000 (01:27 +0300)]
Revert "LinuxKPI: Allow wake_up to be executed within a critical section"

This change was based on currently reverted commit 7dea0c9e6eba.

This reverts commit 89889ab470b9f1a1cd36913dd219b78efbf484df.

2 years agoRevert "LinuxKPI: Allow spin_lock_irqsave to be called within a critical section"
Vladimir Kondratyev [Wed, 26 Jan 2022 22:27:01 +0000 (01:27 +0300)]
Revert "LinuxKPI: Allow spin_lock_irqsave to be called within a critical section"

This change results in deadlocks on UP systems

This reverts commit 7dea0c9e6eba4dc127cd67667c81fa2c250f1024.

Requested by: kib, hselasky

2 years agosh: Don't add something to a null pointer
Jilles Tjoelker [Sun, 23 Jan 2022 21:15:57 +0000 (22:15 +0100)]
sh: Don't add something to a null pointer

Pointer arithmetic on a null pointer is undefined behavior.

The bug can be reproduced by running bin/sh/tests/builtins/wait6.0 with
UBSAN.

Reported by: Mark Millard
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D34011

2 years agotools/build: Fix the error message used when a host tool is not present
Mark Johnston [Wed, 26 Jan 2022 20:23:44 +0000 (15:23 -0500)]
tools/build: Fix the error message used when a host tool is not present

MFC after: 1 week

2 years agotests: add a basic test for argc == 0
Kyle Evans [Wed, 26 Jan 2022 01:22:03 +0000 (19:22 -0600)]
tests: add a basic test for argc == 0

The kernel should reject such exec()s now, early on. Instead of adding
the needed boilerplate to write a test in C, just add an -n argument for
"(n)ull argv" to the execve helper and exec this other helper that just
exits silently with argv count.

Reviewed by: emaste, kib, markj (all previous version)
Differential Revision: https://reviews.freebsd.org/D34045