]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agoxen: allow limiting the amount of duplicated pending xenstore watches
Roger Pau Monné [Wed, 25 Nov 2020 11:34:38 +0000 (12:34 +0100)]
xen: allow limiting the amount of duplicated pending xenstore watches

Xenstore watches received are queued in a list and processed in a
deferred thread. Such queuing was done without any checking, so a
guest could potentially trigger a resource starvation against the
FreeBSD kernel if such kernel is watching any user-controlled xenstore
path.

Allowing limiting the amount of pending events a watch can accumulate
to prevent a remote guest from triggering this resource starvation
issue.

For the PV device backends and frontends this limitation is only
applied to the other end /state node, which is limited to 1 pending
event, the rest of the watched paths can still have unlimited pending
watches because they are either local or controlled by a privileged
domain.

The xenstore user-space device gets special treatment as it's not
possible for the kernel to know whether the paths being watched by
user-space processes are controlled by a guest domain. For this reason
watches set by the xenstore user-space device are limited to 1000
pending events. Note this can be modified using the
max_pending_watch_events sysctl of the device.

This is XSA-349.

Sponsored by: Citrix Systems R&D
MFC after: 3 days

(cherry picked from commit 4e4e43dc9e1afc863670a031cc5cc75eb5e668d6)

3 years agoxen/xenstore: remove unused functions
Roger Pau Monné [Thu, 26 Nov 2020 08:57:47 +0000 (09:57 +0100)]
xen/xenstore: remove unused functions

Those helpers are not used, so remove them. No functional change.

Sponsored by: Citrix Systems R&D
MFC after: 3 days

(cherry picked from commit 2ae75536d370c238f77ad09e5e994d2b8bdf010c)

3 years agoarm64: fix early devmap assertion
Mitchell Horne [Wed, 13 Jan 2021 18:30:50 +0000 (14:30 -0400)]
arm64: fix early devmap assertion

PR: 25241
Reported by: gbe
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 818390ce0ca539300dd15d7a817784f1e3f7a9b8)

3 years agolibthr malloc: support recursion on thr_malloc_umtx.
Konstantin Belousov [Tue, 12 Jan 2021 09:02:37 +0000 (11:02 +0200)]
libthr malloc: support recursion on thr_malloc_umtx.

PR: 252579

(cherry picked from commit 85d028223bc2768651f4d44881644ceb5dc2a664)

3 years agolibthr: wrap pdfork(2), same as fork(2).
Konstantin Belousov [Sun, 10 Jan 2021 19:22:49 +0000 (21:22 +0200)]
libthr: wrap pdfork(2), same as fork(2).

(cherry picked from commit 21f749da82e755aafab127618affeffb86cff9a5)

3 years agosbin/camcontrol: use calloc/strlcpy where appropriate.
Xin LI [Mon, 4 Jan 2021 06:52:28 +0000 (22:52 -0800)]
sbin/camcontrol: use calloc/strlcpy where appropriate.

MFC after: 2 weeks

(cherry picked from commit fd340a122259d44a7d01a72890ff40411f87d79c)

3 years agore: netmap: enable/disable krings on interface reinit
Vincenzo Maffione [Sun, 10 Jan 2021 15:09:05 +0000 (15:09 +0000)]
re: netmap: enable/disable krings on interface reinit

This prevents krings from being used during an interface
reset, and notifies the active applications.
See also 1d238b07d5d4d9660ae0.

MFC after:      1 week

(cherry picked from commit 54bbcca4f9790e012e0a0f1512d9c879a48d5293)

3 years agonetmap: vtnet: stop krings during interface reset
Vincenzo Maffione [Sat, 9 Jan 2021 22:34:10 +0000 (22:34 +0000)]
netmap: vtnet: stop krings during interface reset

Similarly to what done for iflib in 1d238b07d5d4d9660ae0e,
this patch prevents access to the krings during the interface
reset triggered by netmap_register().

MFC after: 1 week

(cherry picked from commit 9ac59d42c0b4b6cd9c36a5dace7f49753c2e175a)

netmap: vtnet: enable/disable krings on any interface reinit

See 3d65fd97e85ab807f3b for a detailed explanation.

PR:             252453
MFC after:      1 week

(cherry picked from commit bb714db6d39583a9fbf5d11849c5e2365e7c0d80)

netmap: vtnet: fix RX initialization after netmap_reset()

At device reset, we must not publish those netmap receive buffers
that are owned by userspace (nm_kr_rxspace).

MFC after: 1 week

(cherry picked from commit 3005e10ddbfbec3ecf46a080607bb0d85986eee5)

3 years agonetmap: iflib: stop krings during interface reset
Vincenzo Maffione [Sat, 9 Jan 2021 20:54:11 +0000 (20:54 +0000)]
netmap: iflib: stop krings during interface reset

When different processes open separate subsets of the
available rings of a same netmap interface, a device
reset may be performed while one of the processes
is actively using some rings (e.g., caused by another
process executing a nmport_open()).
With this patch, such situation will cause the
active process to get a POLLERR, so that it can
have a chance to detect the situation.
We also guarantee that no process is running a txsync
or rxsync (ioctl or poll) while an iflib device reset
is in progress.

PR:     252453
MFC after:  1 week

(cherry picked from commit 1d238b07d5d4d9660ae0e08daede6da7e91c7853)

netmap: iflib: fix asserts in netmap_fl_refill()

When netmap_fl_refill() is called at initialization time (e.g.,
during netmap_iflib_register()), nic_i must be 0, since the
free list is reinitialized. At the end of the refill cycle, nic_i
must still be zero, because exactly N descriptors (N is the ring size)
are refilled.
This patch therefore fixes the assertions to check on nic_i rather
than on nm_i. The current netmap_reset() may in fact cause nm_i
to be != 0 while the device is resetting: this may happen when
multiple non-cooperating processes open different subsets of the
available netmap rings.

PR:     252518
MFC after:  1 week

(cherry picked from commit 3189ba61673af5bd3ed2ee9e33be92bc0b9995ba)

netmap: refactor netmap_reset

The netmap_reset() function is meant to be called by the driver
when they initialize (or re-initialize) a hardware ring.
However, since the introduction of support for opening (in
netmap mode) a subset of the available rings, netmap_reset()
may be called multiple times on actively used rings, causing
both kring and netmap ring to transition to an inconsistent
state.
This changes improves the situation by resetting all the
indices fields of the kring to 0, as expected after the
reinitialization of a hardware ring.

PR:     252518
MFC after:  1 week

(cherry picked from commit 7ba6ecf216fb15e8b147db268b91d9b82c5a0682)

netmap: iflib: enable/disable krings on any interface reinit

Since 1d238b07d5d4d9660ae0e0, krings are disabled before
a reinit cycle triggered by iflib_netmap_register.
However, this operation is actually necessary also for
any interface reinit triggered by other causes (i.e.,
ifconfig commands).
We achieve this goal by moving the krings enable/disable
operation inside iflib_stop() and iflib_init_locked().

Once here, this change also removes some redundant operations
from iflib_netmap_register(), that are already performed by
iflib_stop().

PR: 252453
MFC after: 1 week

(cherry picked from commit 3d65fd97e85ab807f3baa62aa979ae527914a3ea)

iflib: fix build failure in case DEV_NETMAP is not defined

This addresses the build failure introduced by
3d65fd97e85ab807f3baa62.

MFC with: 3d65fd97e85ab807f3baa62

(cherry picked from commit 8aa8484cbf06bb26ad87177fe4aebcaf1519f138)

netmap: restore hwofs and support it in iflib

Restore the hwofs functionality temporarily disabled by
7ba6ecf216fb15e8b147db2 to prevent issues with iflib.
This patch brings the necessary changes to iflib to
enable howfs to allow interface restarts without
disrupting netmap applications actively using its
rings.
After this change, it becomes possible for multiple
non-cooperating netmap applications to use non-overlapping
subsets of the available netmap rings without clashing
with each other.

PR: 252453
MFC after: 1 week

(cherry picked from commit 55f0ad5fdee1a779d6889481ba591a819081b9ca)

3 years agobectl(8): sync man page and help text
Robert Wing [Wed, 6 Jan 2021 19:38:25 +0000 (10:38 -0900)]
bectl(8): sync man page and help text

Sync man page with behavior of bectl(8).

Sync help text with man page.

PR:             246697
Reported by: olgeni
Submitted by:   olgeni (with changes)
Reviewed by:    kevans, olgeni
Approved by:    kevans (mentor)
Differential Revision: https://reviews.freebsd.org/D27482

(cherry picked from commit b1ea63e2e3c92d1346af067f5cf609e3e062f8b9)

3 years agotmpfs: make M_TMPFSMNT static to tmpfs_vfsops.c
Konstantin Belousov [Tue, 5 Jan 2021 18:52:42 +0000 (20:52 +0200)]
tmpfs: make M_TMPFSMNT static to tmpfs_vfsops.c

(cherry picked from commit 42bebbda9ed13d12d0454b676aa81f34b39e496f)

3 years agoissignal(): when handling STOP-like signals, drop sigacts mutex earlier.
Konstantin Belousov [Thu, 31 Dec 2020 01:45:12 +0000 (03:45 +0200)]
issignal(): when handling STOP-like signals, drop sigacts mutex earlier.

(cherry picked from commit e0d83cd3e49f0b9e16bc82ced7bd3b0ef9aa6a71)

3 years agotty_wait_background: improve locking.
Konstantin Belousov [Thu, 31 Dec 2020 13:45:06 +0000 (15:45 +0200)]
tty_wait_background: improve locking.

(cherry picked from commit a008bdeda3b8278fe600cf83ecf44acd1ccb30b6)

3 years agotmpfs_free_tmp(): explicitly assert that tmp is locked
Konstantin Belousov [Tue, 5 Jan 2021 18:53:45 +0000 (20:53 +0200)]
tmpfs_free_tmp(): explicitly assert that tmp is locked

(cherry picked from commit 9f200bc47b5d8445d91d51f6dfd6af0f1fbbe354)

3 years agotmpfs_reclaim: style
Konstantin Belousov [Wed, 13 Jan 2021 06:55:38 +0000 (08:55 +0200)]
tmpfs_reclaim: style

(cherry picked from commit 685265ecfbd8e929d7c6988a99b708d3a3a5cbf4)

3 years agolibc: implement rtld_get_stack_prot() for real
Konstantin Belousov [Sun, 10 Jan 2021 03:05:42 +0000 (05:05 +0200)]
libc: implement rtld_get_stack_prot() for real

(cherry picked from commit 81b3a0a34145ee6c855f50c8035728f76d63c3f0)

3 years agox86: Add rdtscp32() into cpufunc.h.
Konstantin Belousov [Sat, 9 Jan 2021 20:39:19 +0000 (22:39 +0200)]
x86: Add rdtscp32() into cpufunc.h.

(cherry picked from commit 45974de8fb23710873417f1d2ca513761da6cacc)

3 years agox86 budma_bounce: style.
Konstantin Belousov [Mon, 11 Jan 2021 23:42:04 +0000 (01:42 +0200)]
x86 budma_bounce: style.

(cherry picked from commit 895ad33784e00fc9d601fd51f0571e0e02d9d146)

3 years agotcgetwinsize(3): provide man page
Konstantin Belousov [Fri, 1 Jan 2021 22:28:42 +0000 (00:28 +0200)]
tcgetwinsize(3): provide man page

(cherry picked from commit 4e0c81c5fafb5b72cabc342f640aff6cac445853)

3 years agoAdd tcgetwinsize(3) and tcsetwinsize(3) to termios
Konstantin Belousov [Thu, 24 Dec 2020 23:05:31 +0000 (01:05 +0200)]
Add tcgetwinsize(3) and tcsetwinsize(3) to termios

(cherry picked from commit 7d7fad7bd969fb464f64d34932234060cee112af)

3 years agonetmap: pkt-gen: fix offset hex formatting
Vincenzo Maffione [Tue, 12 Jan 2021 22:02:28 +0000 (22:02 +0000)]
netmap: pkt-gen: fix offset hex formatting

PR: 252594
Reported by: brpoole@vt.edu
MFC after: 3 days

3 years agocmp: fix -s (silent) when used with skip offsets
Ed Maste [Mon, 11 Jan 2021 00:02:56 +0000 (19:02 -0500)]
cmp: fix -s (silent) when used with skip offsets

-s causes cmp to print nothing for differing files, for use when only
the exit status is of interest.

-z compares the file size first, for regular files, and fails the
comparison early if they do not match.

Prior to this change -s implied -z as an optimization, but this is not
valid when file offsets are specified.  Now, enable the -z optimization
for -s only if both skip arguments are not provided / 0.

Note that using -z with differing skip values will currently always
fail.  We may want to compare size1 - skip1 with size2 - skip2 instaead,
and in any case the man page should be clarified.

PR: 252542
Fixes: 3e6902efc802ab57fc4e9bf798f2d271b152e7f9
Reported by: William Ahern
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28071

(cherry picked from commit 80445b7a3f738e0b0a33ee7a11905a275346a6de)

3 years agocmp: use C99 bool for flags
Ed Maste [Mon, 11 Jan 2021 00:02:55 +0000 (19:02 -0500)]
cmp: use C99 bool for flags

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28072

(cherry picked from commit 1f7661742de650bcb6b9124ee3da7e94c8650c4b)

3 years agodiff: honour flags with -q
Ed Maste [Sat, 9 Jan 2021 16:22:28 +0000 (11:22 -0500)]
diff: honour flags with -q

Previously -q (just print a line when files differ) ignored flags like
-w (ignore whitespace).  Avoid the D_BRIEF short-circuit when flags are
in effect.

PR: 252515
Reported by: Scott Aitken
Reviewed by: kevans
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28064

(cherry picked from commit 12a8d3027d414abd15798de1b6d8b01151bdac50)

3 years agolibc: fix undefined behavior from signed overflow in strstr and memmem
Ed Maste [Thu, 19 Nov 2020 00:03:15 +0000 (00:03 +0000)]
libc: fix undefined behavior from signed overflow in strstr and memmem

unsigned char promotes to int, which can overflow when shifted left by
24 bits or more. this has been reported multiple times but then
forgotten. it's expected to be benign UB, but can trap when built with
explicit overflow catching (ubsan or similar). fix it now.

note that promotion to uint32_t is safe and portable even outside of
the assumptions usually made in musl, since either uint32_t has rank
at least unsigned int, so that no further default promotions happen,
or int is wide enough that the shift can't overflow. this is a
desirable property to have in case someone wants to reuse the code
elsewhere.

musl commit: 593caa456309714402ca4cb77c3770f4c24da9da

Obtained from: musl

(cherry picked from commit 33482dae89c26158a22ccb3b7f2ca6e6652f29b4)

3 years agolibc: optimize memmem two-way bad character shift
Ed Maste [Thu, 19 Nov 2020 00:02:12 +0000 (00:02 +0000)]
libc: optimize memmem two-way bad character shift

first, the condition (mem && k < p) is redundant, because mem being
nonzero implies the needle is periodic with period exactly p, in which
case any byte that appears in the needle must appear in the last p
bytes of the needle, bounding the shift (k) by p.

second, the whole point of replacing the shift k by mem (=l-p) is to
prevent shifting by less than mem when discarding the memory on shift,
in which case linear time could not be guaranteed. but as written, the
check also replaced shifts greater than mem by mem, reducing the
benefit of the shift. there is no possible benefit to this reduction of
the shift; since mem is being cleared, the full shift is valid and
more optimal. so only replace the shift by mem when it would be less
than mem.

musl commits:
8f5a820d147da36bcdbddd201b35d293699dacd8
122d67f846cb0be2c9e1c3880db9eb9545bbe38c

Obtained from: musl

(cherry picked from commit 7dbcd06e63101d51e6a777f7315cfde794411e53)

3 years agoclang-format libc string functions imported from musl
Ed Maste [Wed, 18 Nov 2020 22:01:34 +0000 (22:01 +0000)]
clang-format libc string functions imported from musl

We have adopted these and don't consider them 'contrib' code, so bring
them closer to style(9).  This is a followon to r315467 and r351700.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 4874ddfd373c582d9cd7fe915d2259295d75d1e5)

3 years agolinuxkpi: handle ARI
Konstantin Belousov [Mon, 4 Jan 2021 21:41:12 +0000 (23:41 +0200)]
linuxkpi: handle ARI

(cherry picked from commit de27805fee0bbe3b714615b1df4cf0b8ebbc39b9)

3 years agopfctl: Call ifa_load() before ifa_grouplookup()
Kristof Provost [Sun, 19 Apr 2020 15:37:13 +0000 (15:37 +0000)]
pfctl: Call ifa_load() before ifa_grouplookup()

ifa_grouplookup() uses the data loaded in ifa_load() (through is_a_group()), so
we must call ifa_load() before we can rely on any of the data it populates.

Submitted by: Nick Rogers
MFC after: 1 week
Sponsored by: RG Nets

(cherry picked from commit 8fd675d8a0538544a85483f7a9bed2bd48382926)

3 years agopfctl: Another set skip <group> fix
Kristof Provost [Mon, 11 Jan 2021 13:09:08 +0000 (14:09 +0100)]
pfctl: Another set skip <group> fix

When retrieving the list of group members we cannot simply use
ifa_lookup(), because it expects the interface to have an IP (v4 or v6)
address. This means that interfaces with no address are not found.
This presents as interfacing being alternately marked as skip and not
whenever the rules are re-loaded.

Happily we only need to fix ifa_grouplookup(). Teach it to also accept
AF_LINK (i.e. interface) node_hosts.

PR:      250994
MFC after: 3 days

(cherry picked from commit 0c156a3c32cd0d9168570da5686ddc96abcbbc5a)

3 years agotsc: use u_int for return type for prototype, same as in definitions.
Konstantin Belousov [Tue, 5 Jan 2021 20:44:10 +0000 (22:44 +0200)]
tsc: use u_int for return type for prototype, same as in definitions.

(cherry picked from commit 826fc3cc3d59c1d0af4caf3a08888e168bfe22b2)

3 years agox86 identcpu.c: fix formatting of the comment.
Konstantin Belousov [Wed, 6 Jan 2021 14:52:27 +0000 (16:52 +0200)]
x86 identcpu.c: fix formatting of the comment.

(cherry picked from commit aa9450e44b5f017bb132ab5a00df68c9d7aa1d94)

3 years agoStyle. Improve some KASSERTs messages.
Konstantin Belousov [Thu, 31 Dec 2020 00:45:47 +0000 (02:45 +0200)]
Style.  Improve some KASSERTs messages.

(cherry picked from commit 993a1699b1948d30c4903440e8d8b23a7d5fc6c5)

3 years agoMFC ea0efc370416:
Hans Petter Selasky [Thu, 7 Jan 2021 14:34:26 +0000 (15:34 +0100)]
MFC ea0efc370416:
Add support for PL2303HXN to uplcom(4).

Code changes in this commit were obtained from straight from OpenBSD's
uplcom.c with almost no modification, the list of chip names and USB
IDs was obtained from Linux.

Differential Revision: https://reviews.freebsd.org/D27952
Submitted by: tomli_tomli.me (Yifeng Li)
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoMFC c834f30a0c16:
Hans Petter Selasky [Thu, 7 Jan 2021 14:27:24 +0000 (15:27 +0100)]
MFC c834f30a0c16:
Add new PCI ID for XHCI(4).

Submitted by: Dmitry Luhtionov <dmitryluhtionov@gmail.com>
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoMFC 9e7fa1e66c1e:
Hans Petter Selasky [Mon, 12 Oct 2020 08:18:48 +0000 (10:18 +0200)]
MFC 9e7fa1e66c1e:
Collect statistics from all rate-limit queues in mlx5en(4).

Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoMFC aca12148b113:
Hans Petter Selasky [Wed, 9 Dec 2020 12:59:01 +0000 (13:59 +0100)]
MFC aca12148b113:
Improve error message printing in krping.
Don't print completion queue flush as an error.

Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoMFC 1622a498525b:
Hans Petter Selasky [Wed, 23 Dec 2020 10:54:42 +0000 (11:54 +0100)]
MFC 1622a498525b:
No need to stop XHCI endpoints in disabled state.

Some AMD XHCI implementations apparently assert a permanent
internal failure if this happens.

Submitted by: ali.abdallah@suse.com
PR: 251503
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoMFC ddce63fcb6d0:
Hans Petter Selasky [Wed, 23 Dec 2020 10:37:44 +0000 (11:37 +0100)]
MFC ddce63fcb6d0:
Remove not needed variable initialization.
And switch from int to bool while at it.

Reviewed by: melifaro@
Differential Revision: https://reviews.freebsd.org/D27725
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoMFC 19ecb5e8dabe:
Hans Petter Selasky [Tue, 29 Dec 2020 16:34:01 +0000 (17:34 +0100)]
MFC 19ecb5e8dabe:
Fix for IPoIB over lagg(4).

Need to update both link layer address and broadcast address when active link changes for IP over infiniband.
This is because the broadcast address contains the so-called P-key, which is interface dependent.

Reviewed by: kib @
Differential Revision: https://reviews.freebsd.org/D27658
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoMFC ec52ff6d1411 and 747feea146d8:
Hans Petter Selasky [Tue, 29 Dec 2020 17:01:57 +0000 (18:01 +0100)]
MFC ec52ff6d1411 and 747feea146d8:
Streamline the infiniband code according to the ethernet code.

Specifically implement the if_requestencap callback function for infiniband.
Most of the changes are simply a cut and paste of the equivalent ethernet part.

Reviewed by: melifaro @
Differential Revision: https://reviews.freebsd.org/D27631
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoFix newvers.sh to no longer print an outdated SVN rev
Ulrich Spörlein [Wed, 23 Dec 2020 21:29:34 +0000 (22:29 +0100)]
Fix newvers.sh to no longer print an outdated SVN rev

We have stopped using SVN, so the notes containing the old SVN revisions
are no longer populated, so fall back to purely counting the number of
commits (currently at about 255337).

Also turn the format more into what git-describe produces, with a name
first, then the number of commits and the hash last. Note that as we
don't tag anything on `main`, git describe will never produce something
useful there and finds the newest vendor tag that was merged in instead.

Sample output:
FreeBSD 13.0-CURRENT #6 main-c255126-gb81783dc98e6-dirty
FreeBSD 12.2-STABLE #0 stable/12-c243035-gd16dac42b641-dirty

MFC after: 3 weeks
Reviewed by: imp, glebius
Differential Revision: https://reviews.freebsd.org/D27751

(cherry picked from commit 8d405efd73d3991fe1647f91a2b7c9989dd5f18f)

3 years agonewvers: append commit count to uname version string
Ed Maste [Thu, 1 Aug 2019 14:13:04 +0000 (14:13 +0000)]
newvers: append commit count to uname version string

In a git world this provides a facsimile of a monotonically increasing
version number.  This might be refined further, but this provides a
starting point for investigation.

Reviewed by: cem
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20462

The "Relnotes" flag in the commit message is removed in cherry-pick as
git repo doesn't affect the stable/11 and stable/12 release.

(cherry picked from commit ecb2bbc081ae906956f4718ec946b9e4fcea241f)

3 years agoFix devinfo typo.
Alexander Motin [Tue, 5 Jan 2021 19:56:23 +0000 (14:56 -0500)]
Fix devinfo typo.

Submitted by: Nick Wolff <darkfiberiru@gmail.com>
Differential Revision: https://reviews.freebsd.org/D27981

(cherry picked from commit 4d86ab429ee9b4b22654b52380512f7b8cee4478)

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

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

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

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

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

(cherry picked from commit f200cc255f8e90b1905d94d0506a22f5dcd467c0)

3 years agompr, mps: Fix a stack buffer overflow in the user passthru ioctl
Mark Johnston [Fri, 8 Jan 2021 18:32:04 +0000 (13:32 -0500)]
mpr, mps: Fix a stack buffer overflow in the user passthru ioctl

Previously we copied in the request into a stack-allocated structure
that could be smaller than the request size.  Furthermore, we checked
the request size only after doing the copyin.

Fix this by allocating a buffer to hold the request, then copying the
buffer's contents into a command descriptor.  This is a bit heavy-handed
but I expect the overhead will not be noticeable.  The approach of
coping the header in first is susceptible to TOCTOU problems.

Reviewed by: imp
Reported by: maxpl0it@protonmail.com
Differential Revision: https://reviews.freebsd.org/D27963

(cherry picked from commit de828a91db29fb20440e0d92f3d3136b314a9584)

3 years agompr, mps: Fix an off-by-one bug in the BTDH_MAPPING ioctl
Mark Johnston [Fri, 8 Jan 2021 18:32:05 +0000 (13:32 -0500)]
mpr, mps: Fix an off-by-one bug in the BTDH_MAPPING ioctl

The device mapping table contains sc->max_devices entries, so only
indices in [0, sc->max_devices) are valid.

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

(cherry picked from commit adc0dcc352bb9f5a67a054d95c6959ea5aa26d91)

3 years agosafexcel: Fix a race around unblocking of crypto ops
Mark Johnston [Fri, 8 Jan 2021 18:32:04 +0000 (13:32 -0500)]
safexcel: Fix a race around unblocking of crypto ops

safexcel_ring_intr() could fail to observed that sc_blocked is set after
completing all outstanding ops for a ring, in which case blocked ops
would be deferred forever.

Request structures are managed by individual rings, so move the
"blocked" flag into the per-ring state block and use the ring lock to
synchronize with safexcel_process().  Remove sc_mtx since it is now
unused.

(cherry picked from commit 092cf8d63f9fb9153c677f5793135926edc101d7)

3 years agosafexcel: Stop using a stack buffer for the ring lock name
Mark Johnston [Fri, 8 Jan 2021 18:32:04 +0000 (13:32 -0500)]
safexcel: Stop using a stack buffer for the ring lock name

mtx_init() does not make a copy of the name so the buffer must be valid
for the lifetime of the driver instance.  Store each ring's lock's name
in the ring structure.

(cherry picked from commit 8ba6acbbe6995efcd12c375e1826d55e35a8bdc9)

3 years agoigmp: Avoid leaking mbuf when source validation fails
Mark Johnston [Fri, 8 Jan 2021 18:32:04 +0000 (13:32 -0500)]
igmp: Avoid leaking mbuf when source validation fails

PR: 252504
Submitted by: Panagiotis Tsolakos <panagiotis.tsolakos@gmail.com>

(cherry picked from commit 501159696cb5204d94d03393e4bc5d82f2e348e6)

3 years agocontrib/libarchive: Import libarchive 3.5.1
Martin Matuska [Sun, 27 Dec 2020 23:34:06 +0000 (00:34 +0100)]
contrib/libarchive: Import libarchive 3.5.1

(cherry picked from commit 69a18c5826c9633a6d77e18f9f34e02c83d22717)

3 years agobsdcat,cpio,tar: derive version string from archive.h
Xin LI [Tue, 29 Dec 2020 21:38:47 +0000 (13:38 -0800)]
bsdcat,cpio,tar: derive version string from archive.h

(cherry picked from commit 2ff66a915526b6509ca57f2046bc7b20b0de8a61)

3 years agofortune(6): Add EXIT STATUS and HISTORY sections
Gordon Bergling [Sun, 3 Jan 2021 22:50:18 +0000 (23:50 +0100)]
fortune(6): Add EXIT STATUS and HISTORY sections

Obtained from: OpenBSD
Differential Revision: https://reviews.freebsd.org/D27941

(cherry picked from commit c949ba1d202c6e939e71f1cb555958b8de3dd048)

3 years agonetmap: bridge: fix NS_MOREFRAG support
Vincenzo Maffione [Thu, 7 Jan 2021 07:00:43 +0000 (07:00 +0000)]
netmap: bridge: fix NS_MOREFRAG support

Support for NS_MOREFRAG is broken, as NS_MOREFRAG is copied from
the TX slot to the RX slot rather than the other way around.
Also, the NS_MOREFRAG must be copied also in case of packet
copy (no zerocopy).

Reported by: rajesh1.kumar_amd.com
Differential Revision: https://reviews.freebsd.org/D27980

(cherry picked from commit 163f4f15733f82584a967538cf2340bf1b6a245f)

3 years agosyscons: scrnmaps: appease -Wmissing-variable-declarations
Kyle Evans [Fri, 1 Jan 2021 17:53:47 +0000 (11:53 -0600)]
syscons: scrnmaps: appease -Wmissing-variable-declarations

scrmap is only used in the one compilation unit in all cases, make it static
rather than extern'ing it. There's little benefit, but it's easy to do.

It's unclear how this hasn't failed many builds before now, since it should
have cropped up sometime around deeper hierarchies getting a default WARNS.

(cherry picked from commit fb6bc290fb342864f5362ab9cef7dd214df05cf3)

3 years agokern: efirt: correct configuration table entry size
Kyle Evans [Sun, 27 Dec 2020 17:26:45 +0000 (11:26 -0600)]
kern: efirt: correct configuration table entry size

Each entry actually stores a native pointer, not a uint64_t quantity. While
we're here, go ahead and export the pointer as-is rather than converting it
to KVA. This may be more useful as consumers can map /dev/mem and observe
the entry.

For reference, see: sys/contrib/edk2/Include/Uefi/UefiSpec.h

(cherry picked from commit ee938b20335d26ca652deac4a1a063e90cafa303)

3 years agokern: efirt: enter runtime environment to deref efi_cfgtbl
Kyle Evans [Sun, 27 Dec 2020 17:28:32 +0000 (11:28 -0600)]
kern: efirt: enter runtime environment to deref efi_cfgtbl

This fixes an insta-panic when EFIIOC_GET_TABLE is used.

(cherry picked from commit 0861c7d3e048556841fa5085173660dceadc5646)

3 years agonfs server: improve use of the VFS KPI
Konstantin Belousov [Fri, 1 Jan 2021 15:35:44 +0000 (17:35 +0200)]
nfs server: improve use of the VFS KPI

(cherry picked from commit 51a9b978e75021415fdced616b4e4bc373a20a8a)

3 years agodump(8): clarify the recommended use of cache and snapshots
Guangyuan Yang [Mon, 28 Dec 2020 21:54:36 +0000 (21:54 +0000)]
dump(8): clarify the recommended use of cache and snapshots

PR: 131626
Submitted by: Andrew Hamilton-Wright <andrew@qemg.org>
Reviewed by: bcr
Differential Revision: https://reviews.freebsd.org/D27775

(cherry picked from commit 70a2e109bd486f97e6fa5f969be9d90e404de016)

3 years agortld: call close(2) after errno is saved
Konstantin Belousov [Fri, 1 Jan 2021 22:24:46 +0000 (00:24 +0200)]
rtld: call close(2) after errno is saved

(cherry picked from commit 741d78126b5584e860811c78f87f51597e375592)

3 years agoMFC llvm fixes for building ceph on powerpc
Dimitry Andric [Fri, 8 Jan 2021 16:35:18 +0000 (17:35 +0100)]
MFC llvm fixes for building ceph on powerpc

Merge commit 8f5e3c74b from llvm git (by Teresa Johnson):

  [PowerPC] Fix compile time issue in recursive CTR analysis code

  Summary:
  Avoid re-examining operands on recursive walk looking for CTR.
  This was causing huge compile time after some earlier optimization
  created a large expression.

  The start of the expression (created by IndVarSimplify) looked like:

  %469 = lshr i64 trunc (i128 xor (i128 udiv (i128 mul (i128 zext (i64 add (i64 trunc (i128 xor (i128 lshr (i128 mul (i128 zext (i64 add (i64 trunc (i128 xor (i128 lshr (i128 mul (i128 zext (i64 add (i64 trunc (i128 xor (i128 lshr (i128 mul (i128 zext (i64 add (i64 trunc (i128 xor (i128 lshr (i128 mul (i128 zext (i64 add (i64 trunc (i128 xor (i128 lshr (i128 mul (i128 zext (i64 add (i64 trunc (i128 xor (i128 lshr (i128 mul (i128 zext (i64 add (i64 trunc (i128 xor (i128 lshr (i128 mul (i128 zext (i64 add (i64 trunc (i128 xor (i128 lshr (i128 mul (i128 zext (i64 add (i64 trunc (i128 xor (i128 lshr (i128 mul (i128 zext (i64 add (i64 trunc (i128 xor (i128 lshr (i128 mul (i128 zext (i64 add (i64 trunc (i128 xor (i128 lshr (i128 mul (i128 zext (i64 add (i64 trunc (i128 xor (i128 lshr (i128 mul (i128 zext (i64 add (i64 trunc (i128 xor (i128 lshr (i128 mul (i128 zext (i64 add (i64 trunc (i128 xor (i128 lshr (i128 mul (i128 zext (i64 add (i64 trunc (i128 xor (i128 lshr (i128 mul (i128 zext (i64 add (i64 trunc (i128 xor (i128 lshr (i128 mul (i128 zext (i64 add (i64 trunc (i128 xor (i128 lshr (i128 mul (i128 zext (i64 add (i64 trunc (i128 xor (i128 lshr (i128 mul (i128 zext (i64 add (i64 trunc (i128 xor (i128 lshr (i128 mul (i128 zext (i64 add (i64 trunc (i128 xor (i128 lshr (i128 mul (i128 zext (i64 add (i64 trunc (i128 xor (i128 lshr (i128 mul (i128 zext (i64 add (i64 trunc (i128 xor (i128 lshr (i128 mul (i128 zext (i64 add (i64 trunc (i128 xor (i128 lshr (i128 mul (i128 zext (i64 add (i64 trunc (i128 xor (i128 lshr (i128 mul (i128 zext (i64 add (i64 trunc (i128 xor (i128 lshr (i128 mul (i128 zext (i64 add (i64 trunc (i128 xor (i128 lshr (i128 mul (i128 zext (i64 add (i64 ptrtoint (i8 @_ZN4absl13hash_internal13CityHashState5kSeedE to i64), i64 120) to i128), i128 8192506886679785011), i128 64), i128 mul (i128 zext (i64 add (i64 ptrtoint (i8 @_ZN4absl13hash_internal13CityHashState5kSeedE to i64), i64 120) to i128), i128 8192506886679785011)) to i64), i64 45) to i128), i128 8192506886679785011), i128 64), i128 mul (i128 zext (i64 add (i64 trunc (i128 xor (i128 lshr (i128 mul (i128 zext (i64 add (i64 ptrtoint (i8 @_ZN4absl13hash_internal13CityHashState5kSeedE to i64), i64 120) to i128), i128 8192506886679785011), i128 64), i128 mul (i128 zext (i64 add (i64 ptrtoint (i8 @_ZN4absl13hash_internal13CityHashState5kSeedE to i64), i64 120) to i128), i128 8192506886679785011)) to i64), i64 45) to i128), ...

  with the _ZN4absl13hash_internal13CityHashState5kSeedE referenced many times.

  Reviewers: hfinkel

  Subscribers: nemanjai, hiraditya, kbarton, jsji, shchenz, llvm-commits

  Tags: #llvm

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

Merge commit 4f568fbd2 from llvm git (by Nemanja Ivanovic):

  [PowerPC] Do not emit HW loop when TLS var accessed in PHI of loop exit

  If any PHI nodes in loop exit blocks have incoming values from the
  loop that are accesses of TLS variables with local dynamic or general
  dynamic TLS model, the address will be computed inside the loop. Since
  this includes a call to __tls_get_addr, this will in turn cause the
  CTR loops verifier to complain.
  Disable CTR loops in such cases.

Fixes: https://bugs.llvm.org/show_bug.cgi?id=48527
This should fix building ceph 12.2.12 on powerpc64, powerpc, powerpcspe
and powerpc64le.

Requested by: pkubaj

(cherry picked from commit 543478be758fdfbf050eca5b58b7c74ba51b9175)

3 years agoo In iflib_txq_drain():
Marius Strobl [Wed, 26 Jun 2019 15:28:21 +0000 (15:28 +0000)]
o In iflib_txq_drain():
  - Remove desc_used, which is only ever written to.
  - Remove a dead store to reclaimed.
  - Don't recycle avail.
  - Sort variables according to style(9).
  These changes will make a subsequent commit easier to read.
o In iflib_tx_credits_update(), don't bother checking whether the
  ift_txd_credits_update method pointer is NULL; _iflib_pre_assert()
  asserts upfront that this method has been assigned and functions
  like iflib_{fast_intr_rxtx,netmap_timer_adjust,txq_can_drain}()
  and _task_fn_tx() were already unconditionally relying on the
  method being callable.

(cherry picked from commit c2c5d1e7874dd2928bc5e85912e59541741f74a3)

3 years agoV_ip6_forwarding and V_ipforwarding have been defined in ip6_var.h /
Marko Zec [Wed, 19 Jun 2019 08:49:24 +0000 (08:49 +0000)]
V_ip6_forwarding and V_ipforwarding have been defined in ip6_var.h /
ip_var.h since at least 2008, so make use of those definitions here.

(cherry picked from commit 188adcb7e471a228398a6d879c65ca5e65333c1c)

3 years agoEvaluating htons() at compile time is more efficient than doing ntohs()
Marko Zec [Wed, 19 Jun 2019 08:39:19 +0000 (08:39 +0000)]
Evaluating htons() at compile time is more efficient than doing ntohs()
at runtime.  This change removes a dependency on a barrel shifter pass
before branch resolution, while reducing the instruction stream size
by 9 bytes on amd64.

(cherry picked from commit 6aee0bfa85685017dbc5050ce36793f7dcd80f82)

3 years agoEnsure that dirent's d_off field is initialized
Mark Johnston [Sun, 3 Jan 2021 16:32:30 +0000 (11:32 -0500)]
Ensure that dirent's d_off field is initialized

We have the d_off field in struct dirent for providing the seek offset
of the next directory entry.  Several filesystems were not initializing
the field, which ends up being copied out to userland.

Reported by: Syed Faraz Abrar <faraz@elttam.com>
Reviewed by: kib

(cherry picked from commit 90f580b954090e669da234f6c8e8d0379ff9d8bc)

3 years agomsdosfs: Fix a leak of dirent padding bytes
Mark Johnston [Sun, 27 Dec 2020 21:52:30 +0000 (16:52 -0500)]
msdosfs: Fix a leak of dirent padding bytes

This was missed in r340856 / commit
6d2e2df764199f0a15fd743e79599391959cc17d.  Three bytes from the kernel
stack may be leaked when reading directory entries.

Reported by: Syed Faraz Abrar <faraz@elttam.com>

(cherry picked from commit 599f90446376370eb365a0fde857ea2b5766873a)

3 years agoqatfw: Fix firmware autoloading for qat_c2xxx devices
Mark Johnston [Wed, 23 Dec 2020 16:31:47 +0000 (11:31 -0500)]
qatfw: Fix firmware autoloading for qat_c2xxx devices

r368193 was suppsed to rename the MOF firmware image, but the
qat_c2xxxfw makefile defined the two images in the wrong order so the
MMP image was renamed instead.

(cherry picked from commit 3b216bfb6cce24aa84519315138be8d23ac5d613)

3 years agoffs: Avoid out-of-bounds accesses in the fs_active bitmap
Mark Johnston [Wed, 23 Dec 2020 16:13:00 +0000 (11:13 -0500)]
ffs: Avoid out-of-bounds accesses in the fs_active bitmap

We use a bitmap to track which cylinder groups have changed between
snapshot creation and filesystem suspension.  The "legs" of the bitmap
are four bytes wide (see ACTIVESET()) so we must round up the allocation
size to a multiple of four bytes.

I believe this bug is harmless since UMA/kmem_* will both pad the
allocation and zero the full allocation.  Note that malloc() does inline
zeroing when the allocation size is known at compile-time.

Reported by: pho (using KASAN)
Reviewed by: kib, mckusick

(cherry picked from commit ace3d9475ceecd9bcb766bb82a1c8f87e8f560be)

3 years agonetgraph: Fix ng_ether's shutdown handing
Mark Johnston [Wed, 23 Dec 2020 05:11:16 +0000 (00:11 -0500)]
netgraph: Fix ng_ether's shutdown handing

When tearing down a VNET, netgraph sends shutdown messages to all of the
nodes before detaching interfaces (SI_SUB_NETGRAPH comes before
SI_SUB_INIT_IF in teardown order).  ng_ether nodes handle this by
destroying themselves without detaching from the parent ifnet.  Then,
when ifnets go away they detach their ng_ether nodes again, triggering a
use-after-free.

Handle this by modifying ng_ether_shutdown() to detach from the ifnet.
If the shutdown was triggered by an ifnet being destroyed, we will clear
priv->ifp in the ng_ether detach callback, so priv->ifp may be NULL.

Also get rid of the printf in vnet_netgraph_uninit().  It can be
triggered trivially by ng_ether since ng_ether_shutdown() persists the
node unless NG_REALLY_DIE is set.

PR: 233622
Reviewed by: afedorov, kp, Lutz Donnerhacke

(cherry picked from commit cd698c51790e956fed0975f451d3dfc361dc7c24)

3 years agoacpi: Ensure that adjacent memory affinity table entries are coalesced
Mark Johnston [Fri, 18 Dec 2020 16:04:48 +0000 (16:04 +0000)]
acpi: Ensure that adjacent memory affinity table entries are coalesced

The SRAT may contain multiple distinct entries that together describe a
contiguous region of physical memory.  In this case we were not
coalescing the corresponding entries in the memory affinity table, which
led to fragmented phys_avail[] entries.  Since r338431 the vm_phys_segs[]
entries derived from phys_avail[] will be coalesced, resulting in a
situation where vm_phys_segs[] entries do not have a covering
phys_avail[] entry.  vm_page_startup() will not add such segments to the
physical memory allocator, leaving them unused.

Reported by: Don Morris <dgmorris@earthlink.net>
Reviewed by: kib, vangyzen

(cherry picked from commit 0f8b212a1e41d6eabf2a17442bcbe4f128f023f8)

3 years agoixl: quiet -Wunused-function
Ryan Libby [Tue, 5 Jan 2021 20:51:40 +0000 (12:51 -0800)]
ixl: quiet -Wunused-function

Direct commit to stable/12.

svn r363876 / git 2bba796c66ede62803ed5da3d83e7efb70c5e9bc MFC'd head
svn r361992 / git b4a7ce0690aedd9763b3b47ee7fcdb421f0434c7.  These two
prototypes were brought back, but the definitions were not.  The
definitions had been introduced earlier for unrelated work, in svn
r353503 / git ba76aa63573f4aeb8fbea6dc85548660cc6d083b, which has not
been MFC'd.

Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D27817

3 years agoPerform kernel linker ifunc test only for builds
Ed Maste [Sun, 27 Dec 2020 00:34:24 +0000 (19:34 -0500)]
Perform kernel linker ifunc test only for builds

dvl reported that "make installkernel" failed with "amd64/arm64/i386
kernel requires linker ifunc support."  This test should apply to builds
only; the linker is not used at install time.

I think the same (ifunc-supporting) linker used to build the kernel
should be detected at install time in usual cases (and so not trigger
this error).  However, there is no reason to disallow the install, if
for some reason the expected linker isn't the one tested at install
time.

PR: 251580
Reported by: dvl
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 581ade97d561e136dbb7cf7a413128c343a23199)

3 years agoFix typo in an_initator_name.
Alexander Motin [Tue, 29 Dec 2020 18:41:56 +0000 (13:41 -0500)]
Fix typo in an_initator_name.

(cherry picked from commit bdbc2a6fc2d8c524d2059e3124f81be08f025a65)

3 years agoFix typo in ap_initator_portal.
Alexander Motin [Tue, 29 Dec 2020 18:32:05 +0000 (13:32 -0500)]
Fix typo in ap_initator_portal.

(cherry picked from commit a3434cdc6b01f23a6a2184923c4367c098ae084d)

3 years agoUFS2: Fix DoS due to corrupted extattrfile
Conrad Meyer [Fri, 30 Oct 2020 19:00:42 +0000 (19:00 +0000)]
UFS2: Fix DoS due to corrupted extattrfile

Prior versions of FreeBSD (11.x) may have produced a corrupt extattr file.
(Specifically, r312416 accidentally fixed this defect by removing a strcpy.)
CURRENT FreeBSD supports disk images from those prior versions of FreeBSD.
Validate the internal structure as soon as we read it in from disk, to
prevent these extattr files from causing invariants violations and DoS.

Attempting to access the extattr portion of these files results in
EINTEGRITY.  At this time, the only way to repair files damaged in this way
is to copy the contents to another file and move it over the original.

PR: 244089
Reported by: Andrea Venturoli <ml AT netfence.it>
Reviewed by: kib
Discussed with: mckusick (earlier draft)

(cherry picked from commit e6790841f749b3cc1ac7d338181d9358aae04d0b)

3 years agogdb(4) fix x86 signal reporting
Mitchell Horne [Wed, 23 Dec 2020 19:36:17 +0000 (15:36 -0400)]
gdb(4) fix x86 signal reporting

The existing values correspond to x86 exception vector numbers, but the
trap numbers used in the kernel do not match these 1-to-1. Prefer the
definitions from x86/trap.h, as they are what actually get passed to
kdb_trap(). This is of little consequence, as gdb_cpu_signal() only
reports the trap reason (signal number) to the gdb client.

This is limited to the subset of trap values for which kdb_trap() is
reachable.

Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.

(cherry picked from commit 962c06c5a32deb9357851d5aca060defc79e6e90)

3 years agogdb(4): allow bulk write of registers
Mitchell Horne [Wed, 23 Dec 2020 18:37:05 +0000 (14:37 -0400)]
gdb(4): allow bulk write of registers

Add support for the remote 'G' packet. This is not widely used by gdb
when 'P' is supported, but is technically required by any remote gdb
stub implementation [1].

[1] https://sourceware.org/gdb/current/onlinedocs/gdb/Overview.html

Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.

(cherry picked from commit 3f3cc995a35a3e9136204a98af0af5808c11047f)

3 years agogdb(4): handle single register read packets
Mitchell Horne [Wed, 23 Dec 2020 18:36:08 +0000 (14:36 -0400)]
gdb(4): handle single register read packets

We support bulk reads of the register set, but not reading specific
registers via the 'p' packet. This is useful at least for the 'call'
command in gdb.

Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.

(cherry picked from commit fd29833d9a7d8355ce21743ed8c706b72ba03363)

3 years agoamd64: use register macros for gdb_cpu_getreg()
Mitchell Horne [Fri, 18 Dec 2020 16:16:03 +0000 (16:16 +0000)]
amd64: use register macros for gdb_cpu_getreg()

Prefer these newly-added definitions to bare values.

Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.

(cherry picked from commit 72939459bdfa930348d0b3397db5d947593ad348)

3 years agoamd64: allow gdb(4) to write to most registers
Mitchell Horne [Fri, 18 Dec 2020 16:09:24 +0000 (16:09 +0000)]
amd64: allow gdb(4) to write to most registers

Similar to the recent patch to arm's gdb stub in r368414, allow GDB to
update the contents of most general purpose registers.

Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.

(cherry picked from commit 0ef474de88fdb78e3cb7ac9bc0b1b98e5b49b4e4)

3 years agoFix daily_backup_gpart_exclude in periodic daily 221.backup-gpart
Ed Maste [Sun, 27 Dec 2020 00:24:18 +0000 (19:24 -0500)]
Fix daily_backup_gpart_exclude in periodic daily 221.backup-gpart

Since gpart_devs was not quoted (losing embedded newlines), if
daily_backup_gpart_exclude matched something, gpart_devs was empty.

PR: 251961
Submitted by: Kan Sasaki

(cherry picked from commit 93900fc697992f893e2e69dce0c2f67b1f66a774)

3 years agopf tests: Verify (tcp) checksum modification on unaligned options
Kristof Provost [Sat, 19 Dec 2020 15:06:03 +0000 (16:06 +0100)]
pf tests: Verify (tcp) checksum modification on unaligned options

It turns out pf incorrectly updates the TCP checksum if the TCP option
we're modifying is not 2-byte algined with respect to the start of the
packet.

Create a TCP packet with such an option and throw it through a scrub
rule, which will update timestamps and modify the packet.

PR: 240416
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D27688

(cherry picked from commit 2d3fda5fa1dc99aa8788e5f8d8bb71e682101063)

3 years agopf: Fix unaligned checksum updates
Kristof Provost [Sun, 20 Dec 2020 20:06:32 +0000 (21:06 +0100)]
pf: Fix unaligned checksum updates

The algorithm we use to update checksums only works correctly if the
updated data is aligned on 16-bit boundaries (relative to the start of
the packet).

Import the OpenBSD fix for this issue.

PR: 240416
Obtained from: OpenBSD
MFC after: 1 week
Reviewed by: tuexen (previous version)
Differential Revision: https://reviews.freebsd.org/D27696

(cherry picked from commit c3f69af03ae7acc167cc1151f0c1ecc5e014ce4e)

3 years agoFollow r354121 to fix some python3 errors in sys.netpfil.*
Li-Wen Hsu [Sun, 27 Oct 2019 21:07:50 +0000 (21:07 +0000)]
Follow r354121 to fix some python3 errors in sys.netpfil.*

stderr:

Traceback (most recent call last):
  File "/usr/tests/sys/netpfil/common/pft_ping.py", line 135, in <module>
    main()
  File "/usr/tests/sys/netpfil/common/pft_ping.py", line 124, in main
    ping(args.sendif[0], args.to[0], args)
  File "/usr/tests/sys/netpfil/common/pft_ping.py", line 74, in ping
    raw = sp.raw(str(PAYLOAD_MAGIC))
  File "/usr/local/lib/python3.6/site-packages/scapy/compat.py", line 52, in raw
    return bytes(x)
TypeError: string argument without an encoding

MFC with: r354121
Sponsored by: The FreeBSD Foundation

(cherry picked from commit cfa8b6482740b2be1719d51e927f76b4adec3b92)

3 years agoUpgrade (scapy) py2 tests to work on py3.
Bjoern A. Zeeb [Sat, 26 Oct 2019 21:19:55 +0000 (21:19 +0000)]
Upgrade (scapy) py2 tests to work on py3.

In order to move python2 out of the test framework to avoid py2 vs. py3
confusions upgrade the remaining test cases using scapy to work with py3.
That means only one version of scapy needs to be installed in the CI system.
It also gives a path forward for testing i386 issues observed in the CI
system with some of these tests.

Fixes are:
- Use default python from environment (which is 3.x these days).
- properly ident some lines as common for the rest of the file to avoid
  errors.
- cast the calculated offset to an int as the division result is considered
  a float which is not accepted input.
- when comparing payload to a magic number make sure we always add the
  payload properly to the packet and do not try to compare string in
  the result but convert the data payload back into an integer.
- fix print formating.

Discussed with: lwhsu, kp (taking it off his todo :)
MFC after: 2 weeks

(cherry picked from commit f0297f121aee3ff9ae6de9d445fc4a7981385d05)

3 years agoFix path issues after r351212
Li-Wen Hsu [Thu, 22 Aug 2019 12:08:35 +0000 (12:08 +0000)]
Fix path issues after r351212

This fixes sys.netpfil.pf.forward.v4 and sys.netpfil.pf.icmp.cve_2019_5598
failures in CI system.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit cdac716946b14572d8c5c764a99617fe5a176da2)

3 years agonetpfil tests: Move pft_ping.py and sniffer.py to the common test directory
Kristof Provost [Mon, 19 Aug 2019 10:48:27 +0000 (10:48 +0000)]
netpfil tests: Move pft_ping.py and sniffer.py to the common test directory

The pft_ping.py and sniffer.py tool is moved from tests/sys/netpfil/pf to
tests/sys/netpfil/common directory because these tools are to be used in
common for all the firewalls.

Submitted by: Ahsan Barkati
Reviewed by: kp, thj
Sponsored by: Google, Inc. (GSoC 2019)
Differential Revision: https://reviews.freebsd.org/D21276

(cherry picked from commit 9531253098a1b889520b49a98af0bb81a2373ac0)

3 years agopf tests: Fix accidental duplication of content
Mateusz Piotrowski [Thu, 15 Aug 2019 12:00:59 +0000 (12:00 +0000)]
pf tests: Fix accidental duplication of content

Some files got their contented duplicated in r345409. Some mistakes where
fixed in r345430. The only file that was left with a duplicated content was
CVE-2019-5598.py.

Reviewed by: kp
Approved by: src (kp)
Differential Revision: https://reviews.freebsd.org/D21267

(cherry picked from commit 03d8a4b7d39af6da7ceaaf07211cf0fde1e623ed)

3 years agopf tests: Fix accidental duplication of content
Kristof Provost [Sat, 23 Mar 2019 01:07:51 +0000 (01:07 +0000)]
pf tests: Fix accidental duplication of content

Also use the correct name for the scapy test script.

(cherry picked from commit dcccc93ae404ab8ead535efc4ddcd0fe9e3ee612)

3 years agopf tests: Test CVE-2019-5598
Kristof Provost [Fri, 22 Mar 2019 07:39:28 +0000 (07:39 +0000)]
pf tests: Test CVE-2019-5598

Verify that pf correctly drops inconsistent ICMP packets (i.e. where the
IP src/dst do not match the IP src/dst in the ICMP packet.

(cherry picked from commit 7de4bd92b8a1f510c88ea3b5af0bcb106af6ba11)

3 years agopf tests: Move Sniffer to its own file
Kristof Provost [Thu, 21 Mar 2019 08:15:46 +0000 (08:15 +0000)]
pf tests: Move Sniffer to its own file

Make it easier to re-use the sniffer class in other test support
scripts.

(cherry picked from commit d1805f60afc3f3c65f5d2bb360ed1ab55ea705da)

3 years agopf tests: Add a defer mode test for pfsync
Kristof Provost [Wed, 5 Dec 2018 19:53:09 +0000 (19:53 +0000)]
pf tests: Add a defer mode test for pfsync

Repeat the pfsync test, this time with the 'defer' option enabled. This
exercises slightly different code paths.

(cherry picked from commit 369d9a2c153e45e2645bc78cdc3a8cdc42f45b7b)

3 years agoMFC r368804: ipfw(8): Fix a few mandoc related issues
Gordon Bergling [Sat, 19 Dec 2020 12:47:40 +0000 (12:47 +0000)]
MFC r368804: ipfw(8): Fix a few mandoc related issues

- no blank before trailing delimiter
- missing section argument: Xr inet_pton
- skipping paragraph macro: Pp before Ss
- unusual Xr order: syslogd after sysrc
- tab in filled text

There were a few multiline NAT examples which used the .Dl macro with
tabs. I converted them to .Bd, which is a more suitable macro for that case.

(cherry picked from commit bae74ca92238e7df070c22f4b53dab12f60d82ef)

3 years agoMFC r366402: ipfw(8): Bugfixes for some issues reported by mandoc
Gordon Bergling [Sat, 3 Oct 2020 18:30:01 +0000 (18:30 +0000)]
MFC r366402: ipfw(8): Bugfixes for some issues reported by mandoc

- whitespace at end of input line
- new sentence, new line
- skipping paragraph macro: Pp before Pp

(cherry picked from commit 8636dd5703dbacff4e8f88385f98c9251526b751)

3 years agoMFC r364459 (by fernape): ipfw(8): Fix typo in man page
Fernando Apesteguía [Fri, 21 Aug 2020 17:45:17 +0000 (17:45 +0000)]
MFC r364459 (by fernape): ipfw(8): Fix typo in man page

s/exmaple/example

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

(cherry picked from commit 71230912a70c5a64c02005603bf077d1d4b767cd)

3 years agoMFC r365628 by ae: Fix compatibility regression after r364117.
Andrey V. Elsukov [Fri, 11 Sep 2020 10:07:09 +0000 (10:07 +0000)]
MFC r365628 by ae: Fix compatibility regression after r364117.

Properly handle the case, when some opcode keywords follow after
the `frag` opcode without additional options.

Reported by: Evgeniy Khramtsov <evgeniy at khramtsov org>
Approved by: glebius

(cherry picked from commit b876085f5589f4e6d531d97ad902c5730ec55339)

3 years agoMFC r364117 by glebius:
Gleb Smirnoff [Tue, 11 Aug 2020 15:46:22 +0000 (15:46 +0000)]
MFC r364117 by glebius:

ipfw: make the "frag" keyword accept additional options "mf",
"df", "rf" and "offset".  This allows to match on specific
bits of ip_off field.

For compatibility reasons lack of keyword means "offset".

Reviewed by: ae
Approved by: glebius
Differential Revision: https://reviews.freebsd.org/D26021

(cherry picked from commit 825398f946221045c565363a0349f68d054d6455)

3 years agopf: Use counter(9) for pf_state byte/packet tracking
Kristof Provost [Wed, 23 Dec 2020 08:37:59 +0000 (09:37 +0100)]
pf: Use counter(9) for pf_state byte/packet tracking

This improves cache behaviour by not writing to the same variable from
multiple cores simultaneously.

pf_state is only used in the kernel, so can be safely modified.

Reviewed by: Lutz Donnerhacke, philip
MFC after: 1 week
Sponsed by: Orange Business Services
Differential Revision: https://reviews.freebsd.org/D27661

(cherry picked from commit 1c00efe98ed7d103b9684ff692ffd5e3b64d0237)

3 years ago81720dba:
Guangyuan Yang [Sun, 3 Jan 2021 00:11:49 +0000 (00:11 +0000)]
81720dba:
mmap(2): Fix a typo

PR:             252097
Reported by:    Nick Frampton <nick.frampton@akips.com>

a1d78367:
mmap(2): Update .Dd missed in the last commit

(cherry picked from commit 81720dbab2a84669ec719149501b75ae78c3d4ee)
(cherry picked from commit a1d783675213798620550f4af137340458abe6c5)

3 years agoMFC r368802: nvmecontrol(8): Fix a few mandoc related issues and add a SEE ALSO section
Gordon Bergling [Sat, 19 Dec 2020 11:47:38 +0000 (11:47 +0000)]
MFC r368802: nvmecontrol(8): Fix a few mandoc related issues and add a SEE ALSO section

- inserting missing end of block: Ss breaks Bl
- skipping paragraph macro: Pp before Ss
- referenced manual not found: Xr nvme 4 (2 times)
- unknown standard specifier: St The

The macro .St can only be used for standards known by mdoc(7). So add a
SEE ALSO section and add a reference to the NVM Express Base Specification.

(cherry picked from commit 9bca273d8496a078787ffbff18b9ae925e25cc36)