Commit graph

138607 commits

Author SHA1 Message Date
Mike Karels
cdae3f501d kernel: deprecate Internet Class A/B/C
Hide historical Class A/B/C macros unless IN_HISTORICAL_NETS is defined;
define it for user level.  Define IN_MULTICAST separately from IN_CLASSD,
and use it in pf instead of IN_CLASSD.  Stop using class for setting
default masks when not specified; instead, define new default mask
(24 bits).  Warn when an Internet address is set without a mask.

(cherry picked from commit 20d5940396)
2021-12-10 10:24:15 -06:00
Andriy Gapon
5f24d2a82c iflib_stop: drain rx tasks to prevent any data races
iflib_stop modifies iflib data structures that are used by _task_fn_rx,
most prominently the free lists.  So, iflib_stop has to ensure that the
rx task threads are not active.

This should help to fix a crash seen when iflib_if_ioctl (e.g.,
SIOCSIFCAP) is called while there is already traffic flowing.

The crash has been seen on VMWare guests with vmxnet3 driver.

My guess is that on physical hardware the couple of 1ms delays that
iflib_stop has after disabling interrupts are enough for the queued work
to be completed before any iflib state is touched.

But on busy hypervisors the guests might not get enough CPU time to
complete the work, thus there can be a race between the taskqueue
threads and the work done to handle an ioctl, specifically in iflib_stop
and iflib_init_locked.

PR:		259458

(cherry picked from commit 1bfdb812c7)
2021-12-10 14:32:37 +02:00
Andriy Gapon
0f048f199e twsi: unify error handling, explicitly handle more conditions
twsi_error() is a new function that stops the current transfer and sets
up softc when an error condition is detected.
TWSI_STATUS_DATA_WR_NACK, TWSI_STATUS_BUS_ERROR and
TWSI_STATUS_ARBITRATION_LOST are now handled explicitly rather than
via the catch-all unknown status.

Also, twsi_intr() now calls wakeup() in a single place when the
transfer is finished.

(cherry picked from commit a4fe892208)
2021-12-10 14:30:12 +02:00
Andriy Gapon
22989451b4 twsi: improve a handful of debug messages
- use 0x prefix for hex values
- print indexes and counts as decimals
- break too long lines

(cherry picked from commit 578707ed4e)
2021-12-10 14:30:12 +02:00
Andriy Gapon
5efa75707b twsi: do not attempt transfer if bus is not idle
(cherry picked from commit cb167e1ae9)
2021-12-10 14:30:12 +02:00
Andriy Gapon
bb8fac1ee1 twsi: remove redundant enabling of the controller
(cherry picked from commit bc02583c4d)
2021-12-10 14:30:12 +02:00
Andriy Gapon
109000c32d twsi: protect interaction between twsi_transfer and twsi_intr
All accesses to softc are now done under a mutex to prevent data races
between the open context and the interrupt handler.
Additionally, the wait time in twsi_transfer is bounded now.
Previously we could get stuck there forever if an interrupt got lost.

(cherry picked from commit 69cfa60ddd)
2021-12-10 14:30:12 +02:00
Michael Tuexen
42cb69e147 Hyper-V: hn: Enter network epoch when required
PR:				254695
(cherry picked from commit 26d79d40a7)
2021-12-10 11:50:01 +01:00
Michael Tuexen
c5f3adcce3 sctp: unbreak NOINET6 builds.
PR:		260119
Reported by:	kostikbel
MFC after:	1 week

(cherry picked from commit 54912d47b6)
2021-12-10 11:41:44 +01:00
Michael Tuexen
89bbc84988 sctp: inherit IP level socket options from listening socket
Ensure that TTL and TOS values set on a listener get inheritet
to the accepted sockets.

PR:		260119
MFC after:	1 week

(cherry picked from commit d79676fb13)
2021-12-10 11:40:59 +01:00
Michael Tuexen
7a49fc8439 sctp: use the correct traffic class when sending SCTP/IPv6 packets
When sending packets the stcb was used to access the inp and then
access the endpoint specific IPv6 level options. This fails when
there exists an inp, but no stcb yet. This is the case for sending
an INIT-ACK in response to an INIT when no association already
exists. Fix this by just providing the inp instead of the stcb.

PR:		260120
MFC after:	1 week

(cherry picked from commit f32357be53)
2021-12-10 11:39:44 +01:00
Michael Tuexen
70d91ea04c sctp: improve handling of assoc ids in socket options
For socket options related to local and remote addresses providing
generic association ids does not make sense. Report EINVAL in this
case.

MFC after:	1 week

(cherry picked from commit 13c196a41e)
2021-12-10 11:29:43 +01:00
Michael Tuexen
6f7ab8ac9e sctp: cleanup, no functional change intended.
MFC after:	1 week

(cherry picked from commit a01b8859cb)
2021-12-10 11:23:42 +01:00
Konstantin Belousov
dea036bd15 swap_pager.c: Remove MPSAFE and ARGSUSED annotations
(cherry picked from commit 6df359449f)
2021-12-10 04:32:18 +02:00
Konstantin Belousov
9e75c46527 imgact_aout.c: some style
(cherry picked from commit 290e05dde0)
2021-12-10 04:32:18 +02:00
Konstantin Belousov
aa1d548128 imgact_aout.c: We do not expect the aout support to be ported
(cherry picked from commit 9da5257e1c)
2021-12-10 04:32:18 +02:00
Rick Macklem
8e74cc2b4e nfsd: Add checks for layout errors in LayoutReturn
For a LayoutReturn when using the Flexible File Layout,
error reports may be provided in the request.
Sanity check the size of these error reports and
check that they exist before calling nfsrv_flexlayouterr().

PR:	260012

(cherry picked from commit bdd57cbb1b)
2021-12-09 16:55:47 -08:00
Rick Macklem
815a7affac nfscl: Sanity check irdcnt in nfsrpc_createsession
PR:	259996

(cherry picked from commit 22f7bcb523)
2021-12-09 16:54:18 -08:00
Cy Schubert
fdf2f69042 ipfilter: Avoid more null if-then-else blocks
As in 73db3b64f1, when WITHOUT_INET6 is selected, null if-then-else
blocks are generated because #if statements are incorrectly placed.
Moving the #if statements reduces unnecessary runtime comparisons or
compiler optimizations.

(cherry picked from commit 130df64793)
2021-12-09 10:50:22 -08:00
Cy Schubert
2d120650d3 ipfilter: Correct a comment and add notation
Correct a comment to accurately reflect what is being done. While
we're at it document the next step in the process.

(cherry picked from commit 1ca73c39a5)
2021-12-09 10:50:22 -08:00
Cy Schubert
7e63bbe7d6 ipfilter: Correct function description
As of 874b1a3548, ip_proxy_check() return codes have been simplified.
The original comment was also incorrect in the first place.

(cherry picked from commit 06b96a4bd6)
2021-12-09 10:50:22 -08:00
Cy Schubert
bc942a227a ipfilter: Add DTrace SDT probe
Add an SDT probe, using the newly created DT5 macro, in similar vein
to DEBUG_PARSE printf for when FTP junk is anticipated and ok. This
will assist in debugging port (active) FTP proxy issues.

(cherry picked from commit 106f42596e)
2021-12-09 10:50:22 -08:00
Cy Schubert
a0ff553e01 ipfilter: New DT5 DTrace macro
Define a new DT5 DTrace macro used to call DTRACE_PROBE5, for use with
SDT probes with five arguments.

(cherry picked from commit ca8bf28e1e)
2021-12-09 10:50:22 -08:00
Cy Schubert
cf9dd263f8 ipfilter: Whitespace cleanup
Clean up whitespace from compaction of DTn macro definitions.

(cherry picked from commit fca9c3871d)
2021-12-09 10:50:22 -08:00
Cy Schubert
b993b91b05 ipfilter: Compat and simplify DTrace macro definitions
Use a compound #if to simplify and compact DTn DTRACE_PROBEn macros
used by ipfilter.

(cherry picked from commit 2d74fed5be)
2021-12-09 10:50:21 -08:00
Cy Schubert
d6110110bb ipfilter: Save a word of stack space
Rather than save the return code into an intermediate variable, which BTW
is optimized out anyway, explicitly remove the return code from the stack.

(cherry picked from commit b7f127b6e5)
2021-12-09 10:50:21 -08:00
Alexander Motin
f8aedfec5d ig4: Add PCI IDs for Intel Alder Lake I2C controller.
Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after:	2 weeks

(cherry picked from commit e8e8d2290e)
2021-12-08 20:37:28 -05:00
Alexander Motin
447d2569d6 APEI: Fix Generic Error Data Entry revision 3.0 handling.
Since revision 3.0 this structure grown another field, breaking access
to the following data structures.  This change fixes the PCIe errors
decoding on newer systems.

MFC after:	2 weeks

(cherry picked from commit ba83762a62)
2021-12-08 20:35:21 -05:00
Mark Johnston
c4c2d50242 vm_fault: Factor out per-object operations into vm_fault_object()
No functional change intended.

Obtained from:	jeff (object_concurrency patches)
Reviewed by:	kib

(cherry picked from commit d47d3a94bb)
2021-12-08 08:41:30 -05:00
Mark Johnston
e01ba31b9d vm_fault: Introduce a fault_status enum for internal return types
Rather than overloading the meanings of the Mach statuses, introduce a
new set for use internally in the fault code.  This makes the control
flow easier to follow and provides some extra error checking when a
fault status variable is used in a switch statement.

vm_fault_lookup() and vm_fault_relookup() continue to use Mach statuses
for now, as there isn't much benefit to converting them and they
effectively pass through a status from vm_map_lookup().

Obtained from:	jeff (object_concurrency patches)
Reviewed by:	kib

(cherry picked from commit f1b642c255)
2021-12-08 08:41:24 -05:00
Mark Johnston
61c3b6832d vm_fault: Move nera into faultstate
This makes it easier to factor out pieces of vm_fault().  No functional
change intended.

Obtained from:	jeff (object_concurrency patches)
Reviewed by:	kib

(cherry picked from commit 45c09a74d6)
2021-12-08 08:39:47 -05:00
Alexander Motin
9e41bccace ichsmb: Add PCI IDs for Intel Alder Lake SMBus controller
Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after:	2 weeks

(cherry picked from commit f29f6b2e1f)
2021-12-07 23:08:51 -05:00
Alexander Motin
916a91bd5e GEOM: Switch g_io_deliver() locking from cp to pp.
Single provider may have multiple consumers, and locking one of consumers
is not sufficient to protect the provider.  Though the only part of the
provider this locking protects now is its statistics.

Reported by:	Arka Sharma <arka.sw1988@gmail.com>
MFC after:	2 weeks

(cherry picked from commit 06bd74e1e3)
2021-12-07 23:06:25 -05:00
Gordon Bergling
c89c8b894c net80211(4): Fix a typo in a sysctl description
- s/travelse/traversal/

(cherry picked from commit a9beea0511)
2021-12-07 19:53:33 +01:00
Gordon Bergling
468495e5be omap4: Fix a few typos in source code comments
- s/addresss/address/

(cherry picked from commit b86066a15e)
2021-12-07 19:52:00 +01:00
Mitchell Horne
1d640e6135 Implement GET_STACK_USAGE on remaining archs
This definition enables callers to estimate remaining space on the
kstack, and take action on it. Notably, it enables optimizations in the
GEOM and netgraph subsystems to directly dispatch work items when there
is sufficient stack space, rather than queuing them for a worker thread.

Implement it for riscv, arm, and mips. Remove the #ifdefs, so it will
not go unimplemented elsewhere.

PR:		259157
Reviewed by:	mav, kib, markj (previous version)
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32580

(cherry picked from commit 0d2224733e)
2021-12-07 14:13:47 -04:00
Mitchell Horne
a8adbe5284 arm64, powerpc: fix calculation of 'used' in GET_STACK_USAGE
We do not consider the space reserved for the pcb to be part of the
total kstack size, so it should not be included in the calculation of
the used stack size.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit b02908b051)
2021-12-07 14:13:47 -04:00
Mitchell Horne
8dba6a2020 i386: take pcb and fpu area into account in GET_STACK_USAGE
On this platform, the pcb and FPU save area are allocated from the top
of each kernel stack, so they should be excluded from the calculation of
the total and used stack sizes.

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

(cherry picked from commit 8bc792b384)
2021-12-07 14:13:46 -04:00
Kristof Provost
3d11fa82c8 pf: remove unused variables
No functional change intended.

Reviewed by:	glebius
MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D33085

(cherry picked from commit c36f90417b)
2021-12-07 09:05:06 +01:00
Alan Somers
7adb46c70f fusefs: Fix a bug during VOP_STRATEGY when the server changes file size
If the FUSE server tells the kernel that a file's size has changed, then
the kernel must invalidate any portion of that file in cache.  But the
kernel can't do that during VOP_STRATEGY, because the file's buffers are
already locked.  Instead, proceed with the write.

PR:		256937
Reported by:	Agata <chogata@moosefs.pro>
Tested by:	Agata <chogata@moosefs.pro>
Reviewed by:	pfg
Differential Revision: https://reviews.freebsd.org/D32332

(cherry picked from commit 032a5bd55b)
2021-12-06 22:14:10 -07:00
Alan Somers
bdd7a3f2a1 fusefs: fix a recurse-on-non-recursive lockmgr panic
fuse_vnop_bmap needs to know the file's size in order to calculate the
optimum amount of readahead.  If the file's size is unknown, it must ask
the FUSE server.  But if the file's data was previously cached and the
server reports that its size has shrunk, fusefs must invalidate the
cached data.  That's not possible during VOP_BMAP because the buffer
object is already locked.

Fix the panic by not querying the FUSE server for the file's size during
VOP_BMAP if we don't need it.  That's also a a slight performance
optimization.

PR:		256937
Reported by:	Agata <chogata@moosefs.pro>
Tested by:	Agata <chogata@moosefs.pro>

(cherry picked from commit 7430017b99)
2021-12-06 22:08:32 -07:00
Alan Somers
94b01af1e5 fusefs: quiet some cache-related warnings
If the FUSE server does something that would make our cache incoherent,
we should print a warning to the user.  However, we previously warned in
some situations when we shouldn't, such as if the file's size changed on
the server _after_ our own attribute cache had expired.  This change
suppresses the warning in cases like that.  It also moves the warning
logic to a single place within the code.

PR:		256936
Reported by:	Agata <chogata@moosefs.pro>
Tested by:	Agata <chogata@moosefs.pro>, jSML4ThWwBID69YC@protonmail.com

(cherry picked from commit 5d94aaacb5)
2021-12-06 22:04:44 -07:00
Alan Somers
dfb3365aa1 fusefs: implement FUSE_NO_OPEN_SUPPORT and FUSE_NO_OPENDIR_SUPPORT
For file systems that allow it, fusefs will skip FUSE_OPEN,
FUSE_RELEASE, FUSE_OPENDIR, and FUSE_RELEASEDIR operations, a minor
optimization.

Reviewed by:	pfg
Differential Revision: https://reviews.freebsd.org/D32141

(cherry picked from commit 7124d2bc3a)
2021-12-06 21:51:55 -07:00
Alan Somers
8254f96698 fusefs: diff reduction in fuse_kernel.h
Synchronize formatting and documentation in fuse_kernel.h with upstream
sources.

Reviewed by:	pfg
Differential Revision:	https://reviews.freebsd.org/D32141

(cherry picked from commit a3a1ce3794)
2021-12-06 21:50:01 -07:00
Jessica Clarke
d08adc0e1c mips: Fix build of kernel.tramp.bin after upstream merge
Since the upstream merge we end up with the compiler generating calls to
memcpy (and it appears upstream LLVM does too, so this will probably
also be a problem upstream when the LLVM 13 import is finished). Like
the kernel we should just compile this file with -ffreestanding to avoid
such surprises.

Note that elf_trampoline.c does actually provide a memcpy, but it's
static. That's a bit weird, and means by the time the memcpy calls are
generated by the compiler the explicit ones have already been inlined
and the function itself GC'ed, but since using -ffreestanding is the
right thing to do for this kind of code anyway, that doesn't actually
matter.

Obtained from:	https://github.com/CTSRD-CHERI/cheribsd/commit/219ddb6293c

(cherry picked from commit a2fa290024)
2021-12-06 17:30:10 +01:00
Warner Losh
3f82687cdf headers: Implement _ISOC11_SOURCES macro when __POSIX_C_SOURCE defined
When _ISOC11_SOURCES is defined for glibc at the same time
__POSIX_C_SOURCE is defined, it extends the __POSIX_C_SOURCE definition
by exaclty what C11 adds to the spec for each system header.  We follow
both OpenBSD's and glibc's convention by also C11 or higher compliation
mode is selected.

The Open Group is working on issuing a new version of the POSIX standard
that will realign the standard from C99 to a newer version of C. This
commit is a stop-gap measure for greater compatibility until that
environment has been standardized.

Reviewed by:		brooks@, arichards@, Olivier Certne
			(comments tweaked before commit)
PR:			255290
Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D29902

(cherry picked from commit a709a4f0d4)
2021-12-06 08:56:00 -07:00
Warner Losh
de8bb30885 mpr: fix freeze / release mismatch in timeout code
So, if we're processing a timeout, and we've sent an ABORT to the
firmware for that timeout, but not yet received the response from the
firmware, AND we get another timeout, we queue the timeout and freeze
the queue. However, when we've finally processed them all, we only
release the queue once. This causes all I/O to halt as the devq remains
frozen forever.

Instead, only freeze the queue when we start the process (eg set INRESET
on the target). This will allow the release when all the timed out I/Os
have finished ABORTing.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D33054

(cherry picked from commit a8837c77ef)
2021-12-06 08:56:00 -07:00
Warner Losh
f15ade6c12 sys/uuid.h: Include sys/types.h
Change the include of sys/cdefs.h to sys/types.h to pick up all the
types. sys/types.h includes cdefs.h.

Sponsored by:		Netflix

(cherry picked from commit 00dbcdbe0a)
2021-12-06 08:56:00 -07:00
Warner Losh
d9aec0ab85 sys/backlight.h: include sys/types.h
Sponsored by:		Netflix

(cherry picked from commit 9be3985f65)
2021-12-06 08:55:59 -07:00
Warner Losh
2b986e4efa sys/ata.h: Include sys/types.h
This file needs types defined by sys/types.h, and there's no reason not
to include sys/types.h here.

Sponsored by:		Netflix

(cherry picked from commit d69b6fa5b4)
2021-12-06 08:55:59 -07:00