]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agoloader: unload command should reset tg_kernel_supported in gfx_state
Toomas Soome [Thu, 28 Jan 2021 07:45:47 +0000 (09:45 +0200)]
loader: unload command should reset tg_kernel_supported in gfx_state

While loading kernel, we check if vt/vbe backend support is included in
kernel and set the tg_kernel_supported flag in gfx_state. unload
command needs to reset this flag to allow next load to perform
this check with new kernel.

Reported by: jhb

(cherry picked from commit 9b388ac30375ad4e0259b264a006753edcb2bd3c)

3 years agoFix loader detection of vbefb support on !amd64
Dimitry Andric [Wed, 27 Jan 2021 21:28:43 +0000 (22:28 +0100)]
Fix loader detection of vbefb support on !amd64

On i386, after 6c7a932d0b8baaaee16eca0ba061bfa6e0e57bfd, the vbefb vt
driver was no longer detected by the loader, if any kernel module was
loaded after the kernel itself.

This was caused by the parse_vt_drv_set() function being called multiple
times, resetting the detection flag. (It was called multiple times,
becuase i386 .ko files are shared objects like the kernel proper, while
this is not the case on amd64.)

Fix this by skipping the set_vt_drv_set lookup if vbefb was already
detected.

Reviewed by: tsoome
(cherry picked from commit 6e26189be406a9a3799074b16925e6cd63cc703b)

3 years agoloader: start kernel in text mode when there is no vbefb vt driver
Toomas Soome [Tue, 26 Jan 2021 22:47:56 +0000 (00:47 +0200)]
loader: start kernel in text mode when there is no vbefb vt driver

If kernel is built without VT vbefb driver, make sure
we start kernel in text mode.

(cherry picked from commit 6c7a932d0b8baaaee16eca0ba061bfa6e0e57bfd)

3 years agolinux: Update the i386/linux vdso deinitialization routine
Mark Johnston [Tue, 16 Feb 2021 22:06:20 +0000 (17:06 -0500)]
linux: Update the i386/linux vdso deinitialization routine

This was missed in commit 0fc8a796722 ("linux: Unmap the VDSO page when
unloading").

Reported by: Mark Millard
MFC with: 0fc8a796722

(cherry picked from commit aa5fef60bf663d31cddf53d7a8c6856d5e4672c0)

3 years agolinux: Unmap the VDSO page when unloading
Mark Johnston [Tue, 16 Feb 2021 14:30:21 +0000 (09:30 -0500)]
linux: Unmap the VDSO page when unloading

linux_shared_page_init() creates an object and grabs and maps a single
page to back the VDSO.  When destroying the VDSO object, we failed to
destroy the mapping and free KVA.  Fix this.

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

(cherry picked from commit 0fc8a796722846d0d676548aa0f5cc660199db73)

3 years agoxen-blkback: fix leak of grant maps on ring setup failure
Roger Pau Monné [Wed, 20 Jan 2021 18:40:51 +0000 (19:40 +0100)]
xen-blkback: fix leak of grant maps on ring setup failure

Multi page rings are mapped using a single hypercall that gets passed
an array of grants to map. One of the grants in the array failing to
map would lead to the failure of the whole ring setup operation, but
there was no cleanup of the rest of the grant maps in the array that
could have likely been created as a result of the hypercall.

Add proper cleanup on the failure path during ring setup to unmap any
grants that could have been created.

This is part of XSA-361.

Sponsored by: Citrix Systems R&D

(cherry picked from commit 808d4aad1022a2a33d222663b0c9badde30b9d45)

3 years agoExclude reserved iSCSI Initiator Task Tag.
Alexander Motin [Sun, 24 Jan 2021 19:23:04 +0000 (14:23 -0500)]
Exclude reserved iSCSI Initiator Task Tag.

RFC 7143 (11.2.1.8):
   An ITT value of 0xffffffff is reserved and MUST NOT be assigned for a
   task by the initiator.  The only instance in which it may be seen on
   the wire is in a target-initiated NOP-In PDU (Section 11.19) and in
   the initiator response to that PDU, if necessary.

MFC after: 1 month

3 years agoExclude reserved iSCSI Target Transfer Tag.
Alexander Motin [Sun, 24 Jan 2021 18:58:29 +0000 (13:58 -0500)]
Exclude reserved iSCSI Target Transfer Tag.

RFC 7143 (11.7.4):
   The Target Transfer Tag values are not specified by this protocol,
   except that the value 0xffffffff is reserved and means that the
   Target Transfer Tag is not supplied.

MFC after: 1 month

3 years agocxgbe(4): Save proper zone index on low memory in refill_fl().
Alexander Motin [Wed, 17 Feb 2021 02:15:28 +0000 (21:15 -0500)]
cxgbe(4): Save proper zone index on low memory in refill_fl().

When refill_fl() fails to allocate large (9/16KB) mbuf cluster, it
falls back to safe (4KB) ones.  But it still saved into sd->zidx
the original fl->zidx instead of fl->safe_zidx.  It caused problems
with the later use of that cluster, including memory and/or data
corruption.

While there, make refill_fl() to use the safe zone for all following
clusters for the call, since it is unlikely that large succeed.

MFC after: 3 days
Sponsored by: iXsystems, Inc.
Reviewed by: np, jhb
Differential Revision: https://reviews.freebsd.org/D28716

(cherry picked from commit 294e62bebf36f873fd083d2fe8edd78919dda4e8)

3 years agoloader_lua: consider userboot console as serial
Toomas Soome [Sun, 14 Feb 2021 08:28:29 +0000 (10:28 +0200)]
loader_lua: consider userboot console as serial

We use ascii box chars with serial console because we do not know
if terminal can draw unixode box chars. Same problem is about userboot
console.

(cherry picked from commit 5d8c062fe3ee7b2d6aed0b46d22f62c7771c0af8)

3 years agozfs: restore FreeBSD resource usage accounting
Martin Matuska [Mon, 22 Feb 2021 20:57:22 +0000 (21:57 +0100)]
zfs: restore FreeBSD resource usage accounting

With the switch to OpenZFS 2.0 the platform-dependent resource
usage accounting code got missing.

Patch author: Ryan Moeller <freqlabs@FreeBSD.org>

Obtained from: openzfs/zfs@64e0fe14fff465604952d576051ca80c2f1be898
MFS after: 3 days

(direct commit)

3 years agolex: Do not let input() return 0 when end-of-file is reached
Jung-uk Kim [Wed, 17 Feb 2021 07:22:47 +0000 (02:22 -0500)]
lex: Do not let input() return 0 when end-of-file is reached

Importing flex 2.6.4 has introduced a regression: input() now returns 0
instead of EOF to indicate that the end of input was reached, just like
traditional AT&T and POSIX lex.  Note the behavior contradicts flex(1).
See "INCOMPATIBILITIES WITH LEX AND POSIX" section for information.
This incompatibility traces back to the original version and documented
in its manual page by the Vern Paxson.

Apparently, it has been reported in a few places, e.g.,

https://github.com/westes/flex/issues/448
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=911415

Unfortunately, this also breaks the scanner used by libdtrace and
dtrace is unable to resolve some probe argument types as a result.  See
PR253440 for more information.

Note the regression was introduced by the following upstream commit
without any explanation or documentation change:

https://github.com/westes/flex/commit/f863c9490e6912ffcaeb12965fb3a567a10745ff

Now we restore the traditional flex behavior unless lex-compatibility
mode is set with "-l" option because I believe the author originally
wanted to make it more lex and POSIX compatible.

PR: 253440
Reported by: markj

(cherry picked from commit 6b7e592c215fb76ea027f25030ddc9a697184fbe)

3 years agozfs: disable use of hardware crypto offload drivers
Martin Matuska [Mon, 22 Feb 2021 17:37:47 +0000 (18:37 +0100)]
zfs: disable use of hardware crypto offload drivers

From openzfs-master e7adccf7f commit message:
  First, the crypto request completion handler contains a bug in that it
  fails to reset fs_done correctly after the request is completed.  This
  is only a problem for asynchronous drivers.  Second, some hardware
  drivers have input constraints which ZFS does not satisfy.  For
  instance, ccp(4) apparently requires the AAD length for AES-GCM to be a
  multiple of the cipher block size, and with qat(4) the AES-GCM AAD
  length may not be longer than 240 bytes.  FreeBSD's generic crypto
  framework doesn't have a mechanism to automatically fall back to a
  software implementation if a hardware driver cannot process a request,
  and ZFS does not tolerate such errors.

Patch Author: Mark Johnston <markj@freebsd.org>

Obtained from: openzfs/zfs@e7adccf7f537a4d07281a2b74b360154bae367bc
PR: 252981, 253595
MFS after: 3 days

(direct commit)

3 years agozfs: fix panic if scrubbing after removing a slog device
Martin Matuska [Mon, 22 Feb 2021 17:05:07 +0000 (18:05 +0100)]
zfs: fix panic if scrubbing after removing a slog device

From openzfs-master 11f2e9a4 commit message:
  vdev_ops: don't try to call vdev_op_hold or vdev_op_rele when NULL

  This prevents a panic after a SLOG add/removal on the root pool followed
  by a zpool scrub.

  When a SLOG is removed, a hole takes its place - the vdev_ops for a hole
  is vdev_hole_ops, which defines the handler functions of vdev_op_hold
  and vdev_op_rele as NULL.

Patch Author: Patrick Mooney <pmooney@pfmooney.com>

Obtained from: openzfs/zfs@11f2e9a491baa2ae3fc00f6b8b892fa91a852ca1
PR: 252396
MFS after: 3 days

(direct commit)

3 years agoMFC 1c808fcd859f: Allocate BAR for ENA MSIx vector table
Michal Krawczyk [Thu, 18 Feb 2021 09:00:58 +0000 (10:00 +0100)]
MFC 1c808fcd859f: Allocate BAR for ENA MSIx vector table

In the new ENA-based instances like c6gn, the vector table moved to a
new PCIe bar - BAR1. Previously it was always located on the BAR0, so
the resources were already allocated together with the registers.

As the FreeBSD isn't doing any resource allocation behind the scenes,
the driver is responsible to allocate them explicitly, before other
parts of the OS (like the PCI code allocating MSIx) will be able to
access them.

To determine dynamically BAR on which the MSIx vector table is present
the pci_msix_table_bar() is being used and the new BAR is allocated if
needed.

Submitted by: Michal Krawczyk <mk@semihalf.com>
Obtained from: Semihalf
Sponsored by: Amazon, Inc

(cherry picked from commit 1c808fcd859f5ce24132a903a4c7c9996e0513b1)

3 years agobc: Upgrade to version 3.3.0
Stefan Eßer [Wed, 17 Feb 2021 21:56:16 +0000 (22:56 +0100)]
bc: Upgrade to version 3.3.0

This update changes the behavior of "-e" or "-f" in BC_ENV_ARGS:

Use of these options on the command line makes bc exit after executing
the given commands. These options will not cause bc to exit when
passed via the environment (but EOF in STDIN or -e or -f on the
command line will make bc exit as before).

The same applies to DC_ENV_ARGS with regard to the dc program.

(cherry picked from commit 9a995fe186257315e7b3d01e24c55d86bb18fd32)

3 years agong_bridge.4: Use more suitable mandoc macros
Lutz Donnerhacke [Fri, 5 Feb 2021 21:24:06 +0000 (22:24 +0100)]
ng_bridge.4: Use more suitable mandoc macros

yuripv@ suggested to replace inappropriate macros by better ones.

Reviewed by: philip
Differential Revision: https://reviews.freebsd.org/D28510

(cherry picked from commit 689561d4032233bc171cff30d6756c3cf3b22720)

3 years agonetgraph/ng_bridge: Add counters for the first link, too
Lutz Donnerhacke [Wed, 10 Feb 2021 10:47:38 +0000 (11:47 +0100)]
netgraph/ng_bridge: Add counters for the first link, too

For broadcast, multicast and unknown unicast, the replication loop
sends a copy of the packet to each link, beside the first one. This
special path is handled later, but the counters are not updated.
Factor out the common send and count actions as a function.

Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D28537

(cherry picked from commit 3c958f5fdfc01b7579ea0fbfc3f15f8a85bebee9)

3 years agonetgraph/ng_bridge: Document staleness in multithreaded operation
Lutz Donnerhacke [Tue, 9 Feb 2021 11:32:46 +0000 (12:32 +0100)]
netgraph/ng_bridge: Document staleness in multithreaded operation

In the data path of ng_bridge(4), the only value of the host struct,
which needs to be modified, is the staleness, which is reset every
time a frame is received.  It's save to leave the code as it is.

This patch is part of a series to make ng_bridge(4) multithreaded.

Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D28546

(cherry picked from commit 011b7317dbb5038a95b9b4fca050325a62f3991e)

3 years agonetgraph/ng_bridge: Merge internal structures
Lutz Donnerhacke [Mon, 8 Feb 2021 21:36:46 +0000 (22:36 +0100)]
netgraph/ng_bridge: Merge internal structures

In a earlier version of ng_bridge(4) the exernal visible host entry
structure was a strict subset of the internal one.  So internal view
was a direct annotation of the external structure.  This strict
inheritance was lost many versions ago.  There is no need to
encapsulate a part of the internal represntation as a separate
structure.

This patch is a preparation to make the internal structure read only
in the data path in order to make ng_bridge(4) multithreaded.

Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D28545

(cherry picked from commit ccf4cd2e7830394467d5f6cf546ab453f9657b69)

3 years agonetgraph/ng_bridge: Make simple internal functions read-only
Lutz Donnerhacke [Wed, 13 Jan 2021 22:18:55 +0000 (23:18 +0100)]
netgraph/ng_bridge: Make simple internal functions read-only

The data path in netgraph is designed to work on an read only state of
the whole netgraph network.  Currently this is achived by convention,
there is no technical enforcment.  In the case of NETGRAPH_DEBUG all
nodes can be annotated for debugging purposes, so the strict
enforcment needs to be lifted for this purpose.

This patch is part of a series to make ng_bridge multithreaded, which
is done by rewrite the data path to operate on const.

Reviewed By: kp
Differential Revision: https://reviews.freebsd.org/D28141

(cherry picked from commit 6117aa58fa4f5891badf58b13c759976983f4f04)

3 years agonetgraph/ng_bridge: switch stats to counter framework
Lutz Donnerhacke [Wed, 13 Jan 2021 06:16:34 +0000 (07:16 +0100)]
netgraph/ng_bridge: switch stats to counter framework

This is the first patch of a series of necessary steps
to make ng_bridge(4) multithreaded.

Reviewed by: melifaro (network), afedorov
Differential Revision: https://reviews.freebsd.org/D28125

(cherry picked from commit 66c72859f66dc6c852234589f3508ce5d36d0336)

3 years agonetgraph/ng_bridge: Derive forwarding mode from first attached hook
Lutz Donnerhacke [Sat, 6 Feb 2021 10:25:04 +0000 (11:25 +0100)]
netgraph/ng_bridge: Derive forwarding mode from first attached hook

Handling of unknown MACs on an bridge with incomplete learning
capabilites (aka uplink ports) can be defined in different ways.

The classical approach is to broadcast unicast frames send to an
unknown MAC, because the unknown devices can be everywhere. This mode
is default for ng_bridge(4).

In the case of dedicated uplink ports, which prohibit learning of MAC
addresses in order to save memory and CPU cycles, the broadcast
approach is dangerous. All traffic to the uplink port is broadcasted
to every downlink port, too. In this case, it's better to restrict the
distribution of frames to unknown MAC to the uplink ports only.

In order to keep the chance small and the handling as natural as
possible, the first attached link is used to determine the behaviour
of the bridge: If it is an "uplink" port, then the bridge switch from
classical mode to restricted mode.

Reviewed By: kp
Differential Revision: https://reviews.freebsd.org/D28487

(cherry picked from commit c869d905baa4e329dfd6793e7487b5985248ddb6)

3 years agonetgraph/ng_bridge: Introduce "uplink" ports without MAC learning
Lutz Donnerhacke [Sat, 6 Feb 2021 10:08:24 +0000 (11:08 +0100)]
netgraph/ng_bridge: Introduce "uplink" ports without MAC learning

The ng_bridge(4) node is designed to work in moderately small
environments. Connecting such a node to a larger network rapidly fills
the MAC table for no reason. It even become complicated to obtain data
from the gettable message, because the result is too large to
transmit.

This patch introduces, two new functionality bits on the hooks:
  - Allow or disallow MAC address learning for incoming patckets.
  - Allow or disallow sending unknown MACs through this hook.

Uplinks are characterized by denied learing while sending out
unknowns. Normal links are charaterized by allowed learning and
sending out unknowns.

Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D23963

(cherry picked from commit f961caf2184c94d6f59c8d522207156b3533d977)

3 years agoMFC jail: Change both root and working directories in jail_attach(2)
Jamie Gritton [Fri, 19 Feb 2021 22:13:35 +0000 (14:13 -0800)]
MFC jail: Change both root and working directories in jail_attach(2)

jail_attach(2) performs an internal chroot operation, leaving it up to
the calling process to assure the working directory is inside the jail.

Add a matching internal chdir operation to the jail's root.  Also
ignore kern.chroot_allow_open_directories, and always disallow the
operation if there are any directory descriptors open.

Reported by:    mjg
Approved by:    markj, kib

(cherry picked from commit d4380c0cdd0517dc038403dd5c99242ce78bdeb5)

3 years agopxeboot(8): remove antiquated information
Guangyuan Yang [Mon, 15 Feb 2021 22:03:37 +0000 (22:03 +0000)]
pxeboot(8): remove antiquated information

While I was there:
- Fix some typos
- Fix an excessive argument "indent" reported by mandoc -Tlint
- Replace a dead link with the one suggested by
  https://www.uefi.org/uefi

Submitted by: linimon (in part)
Reviewed by: bcr
Differential Revision: https://reviews.freebsd.org/D27774

(cherry picked from commit c90fb7acf099f1dc982f8d6087aa92809ae43727)

3 years agoMerge libcxxrt master 8049924686b8414d8e652cbd2a52c763b48e8456
Dimitry Andric [Thu, 18 Feb 2021 21:30:27 +0000 (22:30 +0100)]
Merge libcxxrt master 8049924686b8414d8e652cbd2a52c763b48e8456

Interesting fixes:
b3c73ba libelftc_dem_gnu3: Sync with elftoolchain r3877
7b2335c Mostly fix __cxa_demangle after #3

Reported by: arichardson
PR: 253226

(cherry picked from commit 0ee0dbfb0d26cf4bc37f24f12e76c7f532b0f368)

Revert 3c4fd2463bb2 since upstream libcxxrt fixed it in another way

In 0ee0dbfb0d26cf4bc37f24f12e76c7f532b0f368 I imported a more recent
libcxxrt snapshot, which includes an upstream fix for the padding of
struct _Unwind_Exception:

https://github.com/libcxxrt/libcxxrt/commit/e458560b7e22fff59af643dba363544b393bd8db

However, we also had a similar fix in our tree as:
https://cgit.freebsd.org/src/commit/?id=3c4fd2463bb29f65ef1404011fcb31e508cdf2e2

Since having both fixes makes the struct too large again, it leads to
SIGBUSes when throwing exceptions on amd64 (or other LP64 arches). This
is most easily tested by running kyua without any arguments.

It looks like our fix is no longer needed now, so revert it to reduce
diffs against upstream.

PR: 253226
Reviewed by: arichardson, kp
Differential Revision: https://reviews.freebsd.org/D28799

(cherry picked from commit d2b3fadf2db56131376a71b0597876b591a6aee4)

3 years agopf: Fix osfp configuration
Kristof Provost [Thu, 18 Feb 2021 07:36:46 +0000 (08:36 +0100)]
pf: Fix osfp configuration

pf_rule_to_krule() incorrectly converted the rule osfp configuration to
the krule structure.

Reported by: delphij@
MFC after: 3 days

(cherry picked from commit 2ed689a674c380e48245933d5326da4dda65f94d)

3 years agoprocstat: distinguish vm map guards in procstat vm output.
Konstantin Belousov [Sun, 14 Feb 2021 00:37:24 +0000 (02:37 +0200)]
procstat: distinguish vm map guards in procstat vm output.

(cherry picked from commit 25c6318c7906f6f4e0c66ce16f81bdb830ba2e3b)

3 years agonvdimm(4): Export NVDIMM health flags via sysctl
Ravi Pokala [Tue, 16 Feb 2021 08:03:32 +0000 (00:03 -0800)]
nvdimm(4): Export NVDIMM health flags via sysctl

The ACPI NFIT specification defines a set of "NVDIMM State Flags". These
flags are already reported by `acpidump -t', but this change makes them
available on a per-device basis, in a format that is more easily parsed.

To simplify this, introduce acpi_nfit_get_memory_maps_by_dimm(), which
locates the (ACPI_NFIT_MEMORY_MAP)s associated with a given
(nfit_handle_t).

Reviewed by: mav, cem
Tested by: mav, rpokala (version for stable/12)
MFC after: 3 days
Sponsored by: Panasas
Differential Revision: https://reviews.freebsd.org/D28700

(cherry picked from commit bdde49b7c7232c6936525f84ffb90856a7cd8e74)

3 years agoRevert "Revert 3c4fd2463bb2 since upstream libcxxrt fixed it in another way"
Dimitry Andric [Sat, 20 Feb 2021 20:39:43 +0000 (21:39 +0100)]
Revert "Revert 3c4fd2463bb2 since upstream libcxxrt fixed it in another way"

This reverts commit aeb00dca0d03e235c5aaabeef0ada9931d680a80, since I
messed up and didn't merge the earlier libcxxrt changes first.

3 years agoRevert 3c4fd2463bb2 since upstream libcxxrt fixed it in another way
Dimitry Andric [Fri, 19 Feb 2021 18:18:22 +0000 (19:18 +0100)]
Revert 3c4fd2463bb2 since upstream libcxxrt fixed it in another way

In 0ee0dbfb0d26cf4bc37f24f12e76c7f532b0f368 I imported a more recent
libcxxrt snapshot, which includes an upstream fix for the padding of
struct _Unwind_Exception:

https://github.com/libcxxrt/libcxxrt/commit/e458560b7e22fff59af643dba363544b393bd8db

However, we also had a similar fix in our tree as:
https://cgit.freebsd.org/src/commit/?id=3c4fd2463bb29f65ef1404011fcb31e508cdf2e2

Since having both fixes makes the struct too large again, it leads to
SIGBUSes when throwing exceptions on amd64 (or other LP64 arches). This
is most easily tested by running kyua without any arguments.

It looks like our fix is no longer needed now, so revert it to reduce
diffs against upstream.

PR: 253226
Reviewed by: arichardson, kp
Differential Revision: https://reviews.freebsd.org/D28799

(cherry picked from commit d2b3fadf2db56131376a71b0597876b591a6aee4)

3 years agopkg(7): address minor nits (mostly clang-analyze complaints)
Kyle Evans [Fri, 12 Feb 2021 00:58:27 +0000 (18:58 -0600)]
pkg(7): address minor nits (mostly clang-analyze complaints)

- One (1) spurious whitespace.
- One (1) occurrence of "random(3) bad, arc4random(3)" good.
- Three (3) writes that will never be seen.

The latter two points are complaints from clang-analyze. Switching to
arc4random(3) is decidedly a good idea because we weren't doing any kind
of PRNG seeding anyways. The discarded assignments are arguably good
for future-proofing, but it's better to improve the S/N ratio from
clang-analyze.

(cherry picked from commit b2c4ca8d2872bc4410626f2b1ceafa49de5828ce)

3 years agopkg(7): add an -r reponame option for bootstrap and add
Kyle Evans [Fri, 12 Feb 2021 00:58:26 +0000 (18:58 -0600)]
pkg(7): add an -r reponame option for bootstrap and add

This is limited to bootstrap/add because some real pkg(8) commands
have -r flags with an incompatible meaning/usage, e.g., pkg-audit.
pkg(7) will still commence the search as it has, but it will ignore any
repo objects without the given name so that overrides and whatnot still
work as expected.

The use of it for add is noted in the manpage; notably, that the
signature config for that repository will be used over global config if
it's specified. i.e., pkg(7) should assume that the given pkg did come
from that repository and treat it appropriately.

(cherry picked from commit 18418e1936b59c34a9c4a02a1ba5fe0d00dde1b3)

3 years agoarm64: rpi4: gpio: Add brcm,bcm2711-gpio compatible
Emmanuel Vadot [Wed, 17 Feb 2021 12:12:45 +0000 (13:12 +0100)]
arm64: rpi4: gpio: Add brcm,bcm2711-gpio compatible

Looks like we never enabled the main gpio controller on the RPI4 board.
Now gpio are usable.

MFC after: 3 days

(cherry picked from commit 2551d928501fb613dba09b7ffe7e383dba276ca6)

3 years agoarm64: rpi4: firmware: Attach at BUS_PASS_BUS + BUS_PASS_ORDER_LATE
Emmanuel Vadot [Wed, 17 Feb 2021 12:11:36 +0000 (13:11 +0100)]
arm64: rpi4: firmware: Attach at BUS_PASS_BUS + BUS_PASS_ORDER_LATE

The node have now a compatible with simple-mfd so we need to attach
at the same pass so the specific driver will be used.

MFC after: 3 days
PR: 252971

(cherry picked from commit 1cf282363101f5d99b1dadfb0d3250bbe6f482a5)

3 years agolibdtrace: Trivial style fixes to force dt_lex.c to be regenerated
Mark Johnston [Sat, 20 Feb 2021 02:44:20 +0000 (21:44 -0500)]
libdtrace: Trivial style fixes to force dt_lex.c to be regenerated

After commit 8ba333e02e ("libdtrace: Stop relying on lex
compatibility"), there have been several reports of incremental
buildworlds failing since make does not know that dt_lex.c needs to be
regenerated, and I want to avoid this when merging to stable/13.

MFC with: 8ba333e02e

(cherry picked from commit 150fc89a12a7e41b8e7f5777d2ed762f7e40ea92)

3 years agolibdtrace: Stop relying on lex compatibility
Mark Johnston [Wed, 17 Feb 2021 15:49:38 +0000 (10:49 -0500)]
libdtrace: Stop relying on lex compatibility

It does not appear to be required, and as of commit 6b7e592c215f
("lex: Do not let input() return 0 when end-of-file is reached") it
causes input to return 0 instead of EOF when end-of-input is reached.

PR: 253440
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 8ba333e02eaa59337a4e1d5534d4e894344c8226)

3 years agolibpmc: fix linking with C programs
Alan Somers [Mon, 15 Feb 2021 22:51:31 +0000 (15:51 -0700)]
libpmc: fix linking with C programs

Revision r334749 Added some C++ code to libpmc.  It didn't change the ABI,
but it did introduce a dependency on libc++.  Nobody noticed because every
program that in the base system that uses libpmc is also C++.

Reported-by: Dom Dwyer <dom@itsallbroken.com>
Reviewed By: vangyzen
Differential Revision: https://reviews.freebsd.org/D28550

(cherry picked from commit 04e34c0202ea50cea67d5779f54bc612c74e6532)

3 years agoUse iflib_if_init_locked() during media change instead of iflib_init_locked().
Allan Jude [Sun, 14 Feb 2021 18:39:09 +0000 (18:39 +0000)]
Use iflib_if_init_locked() during media change instead of iflib_init_locked().

iflib_init_locked() assumes that iflib_stop() has been called, however,
it is not called for media changes.
iflib_if_init_locked() calls stop then init, so fixes the problem.

PR: 253473
Sponsored by: Juniper Networks, Inc., Klara, Inc.

(cherry picked from commit 922cf8ac43adc9983f9a9e05cfd838306c1ef483)

3 years agotruss: Decode sendfile(2) arguments
Mark Johnston [Fri, 5 Feb 2021 16:28:09 +0000 (11:28 -0500)]
truss: Decode sendfile(2) arguments

(cherry picked from commit 90da2c797bfa7639005ed46ab9173feb8bd85ecd)

3 years agoarm64: if_dwc is also needed by intel stratix10 platform
Emmanuel Vadot [Thu, 4 Feb 2021 16:07:17 +0000 (17:07 +0100)]
arm64: if_dwc is also needed by intel stratix10 platform

MFC after: 3 days

3 years agoarm64: Add a SOC_BRCM_NS2 option
Emmanuel Vadot [Thu, 4 Feb 2021 14:40:54 +0000 (15:40 +0100)]
arm64: Add a SOC_BRCM_NS2 option

Only compile files needed for this platform if the option is enabled in the
kernel config file.
Add the option to GENERIC.

MFC after: 3 days

3 years agoarm64: Make thunderx vnic file depend on soc_cavm_thunderx
Emmanuel Vadot [Thu, 4 Feb 2021 14:31:23 +0000 (15:31 +0100)]
arm64: Make thunderx vnic file depend on soc_cavm_thunderx

MFC after: 3 days

3 years agoarm64: Order sys/conf/files.arm64
Emmanuel Vadot [Thu, 4 Feb 2021 13:54:22 +0000 (14:54 +0100)]
arm64: Order sys/conf/files.arm64

This is now easier to read and see what's compiled-in

No functional changes intended.

MFC after: 3 days

(cherry picked from commit ea3b6abf3f2fd7db11a95ea10cc4b6d136958f8d)

3 years agolastcomm(1): Only install if MK_ACCT is on
Emmanuel Vadot [Sat, 6 Feb 2021 19:41:39 +0000 (20:41 +0100)]
lastcomm(1): Only install if MK_ACCT is on

MFC after: 3 days

(cherry picked from commit 8af54bdfcaecf922f936a14d1d9efcf84076029f)

3 years agoffs_vnops.c: Move opt_*.h includes to the top.
Konstantin Belousov [Thu, 28 Jan 2021 18:30:35 +0000 (20:30 +0200)]
ffs_vnops.c: Move opt_*.h includes to the top.

(cherry picked from commit 0281f88e5dbc8d6f819bf3f22dd11239ff5374ea)

3 years agoVOP_ADVLOCK(9): fix a typo
Guangyuan Yang [Thu, 11 Feb 2021 00:25:58 +0000 (00:25 +0000)]
VOP_ADVLOCK(9): fix a typo

Submitted by: Ka Ho Ng <khng300@gmail.com>
Differential Revision: https://reviews.freebsd.org/D28575

(cherry picked from commit c03ccb991d0e399435c9bbdb6b266ecee93f5b46)

3 years agoMFC jail: Handle a possible race between jail_remove(2) and fork(2)
Jamie Gritton [Tue, 16 Feb 2021 19:19:13 +0000 (11:19 -0800)]
MFC jail: Handle a possible race between jail_remove(2) and fork(2)

jail_remove(2) includes a loop that sends SIGKILL to all processes
in a jail, but skips processes in PRS_NEW state.  Thus it is possible
the a process in mid-fork(2) during jail removal can survive the jail
being removed.

Add a prison flag PR_REMOVE, which is checked before the new process
returns.  If the jail is being removed, the process will then exit.
Also check this flag in jail_attach(2) which has a similar issue.

Reported by:    trasz
Approved by:    kib

(cherry picked from commit cc7b73065302005ebc4a19503188c8d6d5eb923d)

3 years agoUpdate Subversion to 1.14.1 LTS. See contrib/subversion/CHANGES for a
Dimitry Andric [Sat, 13 Feb 2021 13:38:51 +0000 (14:38 +0100)]
Update Subversion to 1.14.1 LTS. See contrib/subversion/CHANGES for a
summary of changes, or for a more thorough overview:

https://subversion.apache.org/docs/release-notes/1.14

NOTE 1: There is no need to dump and reload repositories, and the
working copy format is still the same as Subversion 1.8 through 1.13.

NOTE 2: The upstream release also contains a fix for a security issue in
mod_dav_svn (CVE-2020-17525), but since we do not build or use any
Apache modules, it is not an issue for the FreeBSD base system.

Relnotes: yes

(cherry-picked from 0ff1014944897f4f3ffa4462406cdee920b53400)

3 years agoarch.7: update 11.x to 11.4 as the last FreeBSD 11 release
Ed Maste [Thu, 28 Jan 2021 20:02:24 +0000 (15:02 -0500)]
arch.7: update 11.x to 11.4 as the last FreeBSD 11 release

armeb and pc98 were both discontinued after FreeBSD 11.  FreeBSD 11.4
is now known to be the final 11.x release, so update to the specific
version.

(cherry picked from commit 4f9548640dd1c7e9602f0d01647b112e51792224)

3 years agoreadelf: do not trucate section name with -W
Ed Maste [Tue, 2 Feb 2021 14:35:04 +0000 (09:35 -0500)]
readelf: do not trucate section name with -W

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

(cherry picked from commit 847dfd2803f6c8b077e3ebc68e35adff2c79a65f)

3 years agoFix incorrect hypotl(3) result with subnormal numbers
Dimitry Andric [Wed, 10 Feb 2021 22:28:43 +0000 (23:28 +0100)]
Fix incorrect hypotl(3) result with subnormal numbers

This adjusts the factor used to scale the subnormal numbers, so it
becomes the right value after adjusting its exponent. Thanks to Steve
Kargl for finding the most elegant fix.

Also enable the hypot tests, and add a test case for this bug.

PR: 253313

(cherry picked from commit d3338f3355a612cf385632291f46c5777bba8d18)

Fix lib/msun/test builds on platforms without 80-bit long doubles

After d3338f3355a612cf385632291f46c5777bba8d18, the lib/msun test case
'hypotl_near_underflow' would fail to compile on platforms where long
doubles weren't 80 bit, like on x86. Disable this particular test on
such platforms for now.

PR: 253313

(cherry picked from commit 25120662284466ecef976df8f86e97bafdedf991)

3 years agoMFC 12148d4300db:
Hans Petter Selasky [Sun, 14 Feb 2021 19:29:16 +0000 (20:29 +0100)]
MFC 12148d4300db:
Fix for locking order reversal in USB audio driver, when using mmap().

Locking the second lock which causes the LOR, can be skipped because
the code updating the shared variables is always executing from the
same USB thread.

lock order reversal:
  1st 0xfffff80005cc3840 pcm7:play:dsp7.p0 (pcm play channel, sleep mutex)
@ usb_transfer.c:2342
  2nd 0xfffff80005cc3860 pcm7:record:dsp7.r0 (pcm record channel, sleep mutex)
@ uaudio.c:2317

lock order pcm record channel -> pcm play channel established at:
witness_checkorder+0x461
__mtx_lock_flags+0x98
dsp_mmap_single+0x151
vm_mmap_cdev+0x65
devfs_mmap_f+0x143
kern_mmap_req+0x594
sys_mmap+0x46
amd64_syscall+0x12e
fast_syscall_common+0xf8

lock order pcm play channel -> pcm record channel attempted at:
witness_checkorder+0xd82
__mtx_lock_flags+0x98
uaudio_chan_play_callback+0xeb
usbd_callback_wrapper+0x7ec
usb_command_wrapper+0x7e
usb_callback_proc+0x8e
usb_process+0xf3
fork_exit+0x80
fork_trampoline+0xe

Found by: Stefan Ehmann <shoesoft@gmx.net>
Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 12148d4300dbbd93260bf2801cdb9eda8b3b05a4)

3 years agozfs: Avoid updating the L2ARC device header unnecessarily
Martin Matuska [Mon, 15 Feb 2021 08:10:01 +0000 (09:10 +0100)]
zfs: Avoid updating the L2ARC device header unnecessarily

From openzfs-master 0ae184a6b commit message:
  If we do not write any buffers to the cache device and the evict hand
  has not advanced do not update the cache device header.

Cherry-picked from openzfs 0ae184a6baaf71e155e9b19af81b75474622ff58
Patch Author:   George Amanakis <gamanakis@gmail.com>

Reviewed by:            delphij
Differential Revision:  https://reviews.freebsd.org/D28682

(cherry picked from commit 5dce03847fdc7bc6eb959282c0ae2117b1991746)

3 years agozfs: fix RAIDZ2/3 not healing parity with 2+ bad disks
Martin Matuska [Mon, 15 Feb 2021 07:40:27 +0000 (08:40 +0100)]
zfs: fix RAIDZ2/3 not healing parity with 2+ bad disks

From openzfs-master 62d4287f2 commit message:
  When scrubbing, (non-sequential) resilvering, or correcting a checksum
  error using RAIDZ parity, ZFS should heal any incorrect RAIDZ parity by
  overwriting it.  For example, if P disks are silently corrupted (P being
  the number of failures tolerated; e.g. RAIDZ2 has P=2), `zpool scrub`
  should detect and heal all the bad state on these disks, including
  parity.  This way if there is a subsequent failure we are fully
  protected.

  With RAIDZ2 or RAIDZ3, a block can have silent damage to a parity
  sector, and also damage (silent or known) to a data sector.  In this
  case the parity should be healed but it is not.

Cherry-picked from openzfs 62d4287f279a0d184f8f332475f27af58b7aa87e
Patch Author: Matthew Ahrens <matthew.ahrens@delphix.com>

Reviewed by: delphij
Differential Revision: https://reviews.freebsd.org/D28681

(cherry picked from commit f15e18a642cb3f7ebc747f8e9cdf11274140107d)

3 years agoGiant: move back Giant removal until 14
Warner Losh [Wed, 17 Feb 2021 16:28:41 +0000 (09:28 -0700)]
Giant: move back Giant removal until 14

Update the Giant Lock warning message to FreeBSD 14. It's growing increasling
clear that this won't be done before 13.0.

MFC: Insta (re@'s request)
Approved by: re@ (gjb requested insta-mfc to make release)
(cherry picked from commit 00065c7630c25850298dd3ba6919c2d3628e8ad9)

3 years agoAllow setting alias port ranges in libalias and ipfw.
Neel Chauhan [Tue, 2 Feb 2021 21:24:17 +0000 (13:24 -0800)]
Allow setting alias port ranges in libalias and ipfw.

This will allow a system to be a true RFC 6598 NAT444 setup, where each
network segment (e.g. user, subnet) can have their own dedicated port
aliasing ranges.

Reviewed by: donner, kp
Approved by: 0mp (mentor), donner, kp
Differential Revision: https://reviews.freebsd.org/D23450

(cherry picked from commit a08cdb6cfb1c84b80b5337d46c574b55d0e15c63)

3 years agoWiden ifnet_detach_sxlock coverage
Kristof Provost [Mon, 8 Feb 2021 09:04:27 +0000 (10:04 +0100)]
Widen ifnet_detach_sxlock coverage

Widen the ifnet_detach_sxlock to cover the entire vnet sysuninit code.
This ensures that we can't end up having the vnet_sysuninit free the UDP
pcb while the detach code is running and trying to purge the UDP pcb.

MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D28530

(cherry picked from commit 6d2a10d96fb5d4ee42fd67b0b07a6d098db5d55a)

3 years agopf: Slightly relax pf_rule_addr validation
Kristof Provost [Sat, 13 Feb 2021 15:31:52 +0000 (16:31 +0100)]
pf: Slightly relax pf_rule_addr validation

Ensure we don't reject no-route / urpf-failed addresses.

PR: 253479
Reported by: michal AT microwave.sk
Revied by: donner@
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D28650

(cherry picked from commit 5e42cb139fc17f165c9c93ac97069dc7770490e2)

3 years agousr.sbin/makefs: fix use-after-free in read_mtree_keywords()
Alex Richardson [Wed, 10 Feb 2021 15:23:23 +0000 (15:23 +0000)]
usr.sbin/makefs: fix use-after-free in read_mtree_keywords()

The st variable is used as a shortcut for &node->inode->st, but in one
branch just before the exit we update node->inode without changing st.

Reported by: AddressSanitizer
Reviewed By: emaste

(cherry picked from commit 12ad8bdb34aa990bcc4f3faa92a6e0557385d2b2)

3 years agoOpenSSL: Regen assembly files for OpenSSL 1.1.1j
Jung-uk Kim [Wed, 17 Feb 2021 05:35:11 +0000 (00:35 -0500)]
OpenSSL: Regen assembly files for OpenSSL 1.1.1j

(cherry picked from commit 3396647c8dc40e859609995d8f5415df43504416)

3 years agoOpenSSL: Remove obsolete include directory
Jung-uk Kim [Wed, 17 Feb 2021 03:53:37 +0000 (22:53 -0500)]
OpenSSL: Remove obsolete include directory

This directory was deprecated since OpenSSL 1.1.1e.

https://github.com/openssl/openssl/pull/9681

(cherry picked from commit b84081606110af6b5df764e3568c0271a5699daa)

3 years agoOpenSSL: Regen manual pages for OpenSSL 1.1.1j.
Jung-uk Kim [Tue, 16 Feb 2021 22:05:00 +0000 (17:05 -0500)]
OpenSSL: Regen manual pages for OpenSSL 1.1.1j.

(cherry picked from commit e25db73fea9b641a7dcf29303cf104e0d3847d6c)

3 years agoOpenSSL: Merge OpenSSL 1.1.1j
Jung-uk Kim [Tue, 16 Feb 2021 22:00:27 +0000 (17:00 -0500)]
OpenSSL: Merge OpenSSL 1.1.1j

(cherry picked from commit 88e852c0b5c872b1a3234515623104ae61b60773)

3 years agogic_v3: add message based interrupts support
Cyprien Laplace [Sat, 5 Dec 2020 15:47:33 +0000 (10:47 -0500)]
gic_v3: add message based interrupts support

Pull Request: https://github.com/freebsd/freebsd-src/pull/451

(cherry picked from commit 35ebd8d33ad2f7c2038f6bf9aa02eab21252f689)

3 years agogic_v3: Use 64-bit writes to GICD_IROUTERn
Cyprien Laplace [Thu, 26 Nov 2020 01:17:04 +0000 (20:17 -0500)]
gic_v3: Use 64-bit writes to GICD_IROUTERn

While 32-bit accesses to GICD_IROUTERn are allowed,
this is a 64-bit register.

Pull Request: https://github.com/freebsd/freebsd-src/pull/451

(cherry picked from commit 46ca0b903cad8955574a2c61bed41c2b92aa2273)

3 years agorelease: fix overriding UNAME_r
Glen Barber [Thu, 11 Feb 2021 02:23:58 +0000 (21:23 -0500)]
release: fix overriding UNAME_r

release.sh: fix OSVERSION and UNAME_r overrides

Add PBUILD_FLAGS and UNAME_r overrides to extra_chroot_setup()
to fix building ports for 14-CURRENT builds on 13.x.

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

(cherry picked from commit c511a5ab53ba335dc85f7ac93843872eb5763602)
(cherry picked from commit 6462113b7012025c2d88451c1795368ef0607deb)

3 years agoloader: do not autoselect smaller font than 8x16 with high res display
Toomas Soome [Mon, 8 Feb 2021 22:34:47 +0000 (00:34 +0200)]
loader: do not autoselect smaller font than 8x16 with high res display

The VT screen buffer size is calculated based on our default
built in (8x16) font.

With high-resolution display, we want to use at least 8x16 font,
or we will have large unused areas on screen.

MFC after: 1 week

(cherry picke from commit a26f7358583174f2fe0df3e979f7b8b02069278c)

3 years agoloader: remove BORDER_PIXELS
Toomas Soome [Mon, 8 Feb 2021 18:49:09 +0000 (20:49 +0200)]
loader: remove BORDER_PIXELS

BORDER_PIXELS is left over from picking up the source from illumos
port. Since FreeBSD VT does not use border in terminal size
calculation, there is no reason why should loader use it.

MFC after: 1 week

(cherry picke from commit 96bef2053a87c8d01ce08ea88857e4657489c8e7)

3 years agousr.bin/grep: Fix Address OOB read error
Alex Richardson [Tue, 19 Jan 2021 11:35:07 +0000 (11:35 +0000)]
usr.bin/grep: Fix Address OOB read error

I found this when compiling all the bootstrap tools with -fsanitize=addres:

==65590==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x62d000008400 at pc 0x000000473053 bp 0x7ffc1c7dd910 sp 0x7ffc1c7dd0b8
READ of size 32769 at 0x62d000008400 thread T0
    #0 0x473052 in regexec (/local/scratch/alr48/cheri/build/freebsd-amd64-build/local/scratch/alr48/cheri/freebsd/amd64.amd64/tmp/legacy/bin/grep+0x473052)
    #1 0x4c9cf3 in procline /local/scratch/alr48/cheri/freebsd/usr.bin/grep/util.c:539:8
    #2 0x4c8687 in procfile /local/scratch/alr48/cheri/freebsd/usr.bin/grep/util.c:379:18
    #3 0x4c6596 in main /local/scratch/alr48/cheri/freebsd/usr.bin/grep/grep.c:714:8

0x62d000008400 is located 0 bytes to the right of 32768-byte region [0x62d000000400,0x62d000008400)
allocated by thread T0 here:
    #0 0x493d5d in malloc (/local/scratch/alr48/cheri/build/freebsd-amd64-build/local/scratch/alr48/cheri/freebsd/amd64.amd64/tmp/legacy/bin/grep+0x493d5d)
    #1 0x4cad75 in grep_malloc /local/scratch/alr48/cheri/freebsd/usr.bin/grep/util.c:656:13
    #2 0x4c8129 in procfile /local/scratch/alr48/cheri/freebsd/usr.bin/grep/util.c
    #3 0x4c6596 in main /local/scratch/alr48/cheri/freebsd/usr.bin/grep/grep.c:714:8

SUMMARY: AddressSanitizer: heap-buffer-overflow (/local/scratch/alr48/cheri/build/freebsd-amd64-build/local/scratch/alr48/cheri/freebsd/amd64.amd64/tmp/legacy/bin/grep+0x473052) in regexec

Reviewed By: kevans
MFC after: 1 week

(cherry picked from commit 81c3f64110bb76e24d6062eafd7206c10f676d6f)

3 years agoinetd: fix unix sockaddr's length assignment
Kyle Evans [Fri, 12 Feb 2021 19:19:43 +0000 (13:19 -0600)]
inetd: fix unix sockaddr's length assignment

unsz was always exactly '1' here due to an unfortunate mispositioning
of closing parenthesis. While it's generally irrelevant because bind(2)
is passed the (accurate) sep->se_ctrladdr_size instead, it's not very
helpful for anything locally that wants to use it rather than assuming
that sep->se_ctrladdr_size perfectly fits the end of sun_path.

Just drop unsz entirely and use the result of SUN_LEN() for it.

(cherry picked from commit 1253835121cb38fd93478849e32a4a4c13436fb2)

3 years agofmtree: add a deprecation notice to the manpage
Kyle Evans [Wed, 10 Feb 2021 15:10:52 +0000 (09:10 -0600)]
fmtree: add a deprecation notice to the manpage

Note that this mtree(8) is actually installed as fmtree(8), while
mtree(8) is located in ^/contrib/mtree -- thus, the reference to
mtree(8) makes a lot more sense in the context in which folks would
actually notice it. Shout-out to Ravi for pointing out that this may
not be an obvious fact.

Relnotes: yes

(cherry picked from commit 6fea22cebe5cb1e51e98c894a738bea910b7bc2f)

3 years agoifconfig: fix incorrect wg allowed-ips netmask
Michael Chiu [Mon, 15 Feb 2021 00:38:26 +0000 (00:38 +0000)]
ifconfig: fix incorrect wg allowed-ips netmask

Currently when peer information is displayed with `ifconfig wgN peer ..`
or `ifconfig wgN peer-list`, the netmask of the first `allowed-ips` will
be used as the netmask of all CIDR in `allowed-ips`.  For example, if
the list is `192.168.1.0/24, 172.16.0.0/16`, it will display as
`192.168.1.0/24, 172.16.0.0/24`. While this does not affect the actual
functionality, it is very confusing.

Submitted by:   Michael Chiu <nyan -at- myuji.xyz>
Reviewed by: grehan
Differential Revision: https://reviews.freebsd.org/D28655

(cherry picked from commit be2003ccfa1b12f372fa1329c38c29fe035f232f)

3 years agoMFC 57785538c6e0d7e8ca0f161ab95bae10fd304047 and
Cy Schubert [Sun, 7 Feb 2021 03:22:52 +0000 (19:22 -0800)]
MFC 57785538c6e0d7e8ca0f161ab95bae10fd304047 and
    1e811efbc591699b872bea42b9de419c373199df:

57785538c6e0d7e8ca0f161ab95bae10fd304047:

Simplify the FreeBSD check using __FreeBSD__ compiler macro.

Rather than rely on __FreeBSD_version, defined in sys/param.h, use
__FreeBSD__ defined by the compiler.

Reported by: emaste
MFC after: 1 week

(cherry picked from commit 57785538c6e0d7e8ca0f161ab95bae10fd304047)

1e811efbc591699b872bea42b9de419c373199df:

Fix non-IPv6 build post 57785538c6e0d7e8ca0f161ab95bae10fd304047.

57785538c6e0d7e8ca0f161ab95bae10fd304047 change the test for FreeBSD
from __FreeBSD_version to __FreeBSD__. However this test was performed
before sys/param.h was included, therefore __FreeBSD_version was never
defined. As the test was never true opt_random_ip_id.h was never included.

Submitted by: bdragon
Reported by: bdragon

(cherry picked from commit 1e811efbc591699b872bea42b9de419c373199df)

3 years agoMFC d20f7a5a3da1aa5bccdabb89c181ca0c49385ecd:
Cy Schubert [Sun, 7 Feb 2021 03:15:27 +0000 (19:15 -0800)]
MFC d20f7a5a3da1aa5bccdabb89c181ca0c49385ecd:

Simply FreeBSD check using __FreeBSD__ and remove OpenBSD

(cherry picked from commit d20f7a5a3da1aa5bccdabb89c181ca0c49385ecd)

3 years agoMFC 344f1083e128d8d41ca31853dac513ca3efd9d1f:
Cy Schubert [Fri, 5 Feb 2021 14:26:04 +0000 (06:26 -0800)]
MFC 344f1083e128d8d41ca31853dac513ca3efd9d1f:

ipfilter: Use the softn (NAT softc) host map size in ip_nat6 calculation.

The ipfilter NAT table host map size is a tunable that defaults to
a macro value defined at build time. HOSTMAP_SIZE is saved in softn
(the ipnat softc) at initialization. It can be tuned (changed) at runtime
using the ipf -T command. If the hostmap_size tunable is adjusted the
calculation to determine where to put new entries in the table was
incorrect. Use the tunable in the NAT softc instead of the static build
time value.

(cherry picked from commit 344f1083e128d8d41ca31853dac513ca3efd9d1f)

3 years agoMFC 10990cb46027b4cc4339540b1217117863b2cd15:
Cy Schubert [Wed, 3 Feb 2021 03:24:05 +0000 (19:24 -0800)]
MFC 10990cb46027b4cc4339540b1217117863b2cd15:

Simplify FreeBSD check.

(cherry picked from commit 10990cb46027b4cc4339540b1217117863b2cd15)

3 years agoMFC e673debe7db8ba95e4ee3b549d2570e71d19b596:
Cy Schubert [Wed, 3 Feb 2021 03:18:48 +0000 (19:18 -0800)]
MFC e673debe7db8ba95e4ee3b549d2570e71d19b596:

Simplify BSD macro tests.

All FreeBSD and NetBSD are BSD >= 199306 and have been for a long time.

(cherry picked from commit e673debe7db8ba95e4ee3b549d2570e71d19b596)

3 years agoMFC 0f34c80f376345b98a972940dd4757e58d7beb06:
Cy Schubert [Thu, 28 Jan 2021 05:50:04 +0000 (21:50 -0800)]
MFC 0f34c80f376345b98a972940dd4757e58d7beb06:

Replace the redundant MENTAT macro with SOLARIS.

MENTAT and SOLARIS are synonymous. Remove the extraneous duplicate
macro.

(cherry picked from commit 0f34c80f376345b98a972940dd4757e58d7beb06)

3 years agoMFC 7071734fae6019d1e3e44daf7deb4478582081cc:
Cy Schubert [Wed, 27 Jan 2021 15:25:00 +0000 (07:25 -0800)]
MFC 7071734fae6019d1e3e44daf7deb4478582081cc:

Indentation cleanup resulting from the cleanup of #ifdefs.

The conscious decision was made not to perform any indentation or
whitespace cleanup while cleaning out old redunant #ifdefs. The
reason for this was to avoid confusing future readers of history and
diffs with cosmetic changes, making bisection of any possible bugs
introduced more difficult. This commit cleans up the whitespace
detritus left behind from the previous #ifdef cleanup commits.

(cherry picked from commit 7071734fae6019d1e3e44daf7deb4478582081cc)

3 years agoMFC 4cd1807c7d2a67b633dd0c0bfde15091543a2514:
Cy Schubert [Tue, 26 Jan 2021 06:24:28 +0000 (22:24 -0800)]
MFC 4cd1807c7d2a67b633dd0c0bfde15091543a2514:

Retire the K&R/STD C __P prototype declarations.

In the old days when K&R C and STD C were each in use a workaround
(read hack) was required to allow the same code to work on each
without modification. All C compilers support STD C. We can finally
put the __P prototype to rest.

(cherry picked from commit 4cd1807c7d2a67b633dd0c0bfde15091543a2514)

3 years agoAdding PRR sysctls to tcp(4) man page
Richard Scheffenegger [Fri, 12 Feb 2021 11:32:48 +0000 (12:32 +0100)]
Adding PRR sysctls to tcp(4) man page

Documenting the newly added, and enabled by default,
Proportional Rate Reduction algorithm's governing sysctls.

Reviewed by: kbowling, rgrimes
MFC after: 3 days
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D28568

(cherry picked from commit a78fee8182614593992e841fbb0d4a958f70da0f)

3 years agoktls: Use COUNTER_U64_DEFINE_EARLY
Mark Johnston [Mon, 8 Feb 2021 14:18:51 +0000 (09:18 -0500)]
ktls: Use COUNTER_U64_DEFINE_EARLY

This makes it a bit more straightforward to add new counters when
debugging.  No functional change intended.

Reviewed by: jhb
Sponsored by: Ampere Computing
Submitted by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D28498

(cherry picked from commit 1755b2b9891bb1bfa7a58383ef5126821f7e46e3)

3 years agoktls: Make configuration sysctls available as tunables
Mark Johnston [Mon, 8 Feb 2021 14:19:02 +0000 (09:19 -0500)]
ktls: Make configuration sysctls available as tunables

Reviewed by: gallatin, jhb
Sponsored by: Ampere Computing
Submitted by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D28499

(cherry picked from commit b5aa9ad43aead288dca0eb94fb4621991917f4e1)

3 years agoarmv8crypto: Extract GCM state into a structure
Mark Johnston [Mon, 8 Feb 2021 14:19:10 +0000 (09:19 -0500)]
armv8crypto: Extract GCM state into a structure

This makes it easier to refactor the GCM code to operate on
crypto_buffer_cursors rather than plain contiguous buffers, with the aim
of minimizing the amount of copying and zeroing done today.

No functional change intended.

Reviewed by: jhb
Sponsored by: Ampere Computing
Submitted by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D28500

(cherry picked from commit 7509b677b413b9551c15b483ec2ed9ce655d2455)

3 years agoiflib: Free resources in a consistent order during detach
Sai Rajesh Tallamraju [Mon, 1 Feb 2021 16:13:00 +0000 (11:13 -0500)]
iflib: Free resources in a consistent order during detach

Memory and PCI resources are freed with no particular order.  This could
cause use-after-frees when detaching following a failed attach.  For
instance, iflib_tx_structures_free() frees ctx->ifc_txqs[] but
iflib_tqg_detach() attempts to access this array. Similarly, adapter
queues gets freed by IFDI_QUEUES_FREE() but IFDI_DETACH() attempts to
access adapter queues to free PCI resources.

Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D27634

(cherry picked from commit 38bfc6dee33bedb290e1ea2540f97a86fe3caee0)

3 years agomca: Handle inconsistent CMCI capability reporting
Mark Johnston [Mon, 8 Feb 2021 19:42:54 +0000 (14:42 -0500)]
mca: Handle inconsistent CMCI capability reporting

A BIOS bug may apparently cause the BSP to report that it does not
implement CMCI, with some APs reporting that they do.  In this scenario,
avoid a NULL pointer dereference that occurs in cmci_monitor() because
cmc_state was not allocated by the BSP.

PR: 253272
Reported by: asomers, mmacy
Reviewed by: kib (previous version)

(cherry picked from commit b5770470276268acef21368b3e77a325df883500)

3 years agobinmiscctl: Avoid segfault with "binmiscctl add" and no extra params
Mark Johnston [Mon, 8 Feb 2021 14:20:38 +0000 (09:20 -0500)]
binmiscctl: Avoid segfault with "binmiscctl add" and no extra params

(cherry picked from commit c7fcb36f5670b1d6c1f80c3c29d9d2ba374807f7)

3 years agomlx4, mthca: Silence warnings about no-op alignment operations
Mark Johnston [Thu, 11 Feb 2021 15:16:59 +0000 (10:16 -0500)]
mlx4, mthca: Silence warnings about no-op alignment operations

Since commit 8fa6abb6f4f64f ("Expose clang's alignment builtins and use
them for roundup2/rounddown2"), clang emits warnings for several
alignment operations in these drivers because the operation is a no-op.
The compiler is arguably being too strict here, but in the meantime
let's silence the warnings by conditionally compiling the alignment
operations.

Reviewed by: arichardson, hselasky
Differential Revision: https://reviews.freebsd.org/D28576

(cherry picked from commit 29ed53850e72ab1b470b978d150561281addc0fc)

3 years agoFix incorrect powf(3) result with x near 1 and |y| much larger than 1
Steve Kargl [Mon, 8 Feb 2021 19:45:30 +0000 (20:45 +0100)]
Fix incorrect powf(3) result with x near 1 and |y| much larger than 1

This adjusts the check to trigger overflow/underflow to a slightly lower
value.

Before: powf(9.999995e-01, -1.342177e+08) -> inf
After:  powf(9.999995e-01, -1.342177e+08) -> 1.858724e+31

(cherry picked from commit 93fc67896550548f91b307dbe3053f11db5d4a8a)

Add test case for 93fc67896550 (incorrect powf(3) result)

This adds the test case to contrib/netbsd-tests/lib/libm/t_pow.c, as it
is currently the only place testing pow(3) and friends.

(cherry picked from commit 51af03328755c9095e94d20858a8d10acfe412ae)

3 years agoMerge bmake-20210206
Simon J. Gerraty [Thu, 11 Feb 2021 06:01:59 +0000 (22:01 -0800)]
Merge bmake-20210206

Changes of interest

  o unit-tests: use private TMPDIR to avoid errors from other users
  o avoid strdup in mkTempFile
  o always use vfork
  o job.c: do not create empty shell files in jobs mode
    reduce unnecessary calls to waitpid
  o cond.c: fix debug output for comparison operators in conditionals

(cherry picked from commit dba7b0ef928af88caa38728a73657b837aeeac93)

Approved by: re

3 years ago[POWERPC64LE] add mrsas to GENERIC64LE
Alfredo Dal'Ava Junior [Thu, 4 Feb 2021 06:12:38 +0000 (03:12 -0300)]
[POWERPC64LE] add mrsas to GENERIC64LE

Reviewed by: bdragon
Sponsored by: Eldorado Research Institute (eldorado.org.br)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D28475

(cherry picked from commit eaffd270d8729c4d79f6ce268275ef4c0e6f7b04)

3 years agomrsas: update man page
Alfredo Dal'Ava Junior [Thu, 4 Feb 2021 06:13:13 +0000 (03:13 -0300)]
mrsas: update man page

update mrsas(4) since big-endian is supported since
e34a057ca6ebdf8e30ec8b0dc21d18eb450bf36a

Reviewed by:    bdragon, gbe
Sponsored by:   Eldorado Research Institute (eldorado.org.br)
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D28475

(cherry picked from commit 20e1817f9a68abd9a232367e04d2afeaf4a3c2f8)

3 years ago[udp6] fix possible panic due to lack of locking.
Andrey V. Elsukov [Thu, 11 Feb 2021 08:38:41 +0000 (11:38 +0300)]
[udp6] fix possible panic due to lack of locking.

The lookup for a IPv6 multicast addresses corresponding to
the destination address in the datagram is protected by the
NET_EPOCH section. Access to each PCB is protected by INP_RLOCK
during comparing. But access to socket's so_options field is
not protected. And in some cases it is possible, that PCB
pointer is still valid, but inp_socket is not. The patch wides
lock holding to protect access to inp_socket. It copies locking
strategy from IPv4 UDP handling.

PR: 232192
Obtained from: Yandex LLC
Sponsored by: Yandex LLC
Differential Revision: https://reviews.freebsd.org/D28232

(cherry picked from commit 3c782d9c91666886d868426f0aea040d1a1a8ee4)

3 years ago[udp] fix possible mbuf and lock leak in udp_input().
Andrey V. Elsukov [Thu, 11 Feb 2021 08:55:39 +0000 (11:55 +0300)]
[udp] fix possible mbuf and lock leak in udp_input().

In error case we can leave `inp' locked, also we need to free
mbuf chain `m' in the same case. Release the lock and use `badunlocked'
label to exit with freed mbuf. Also modify UDP error statistic to
match the IPv6 code.

Remove redundant INP_RUNLOCK() from the `if (last == NULL)' block,
there are no ways to reach this point with locked `inp'.

Obtained from: Yandex LLC
Sponsored by: Yandex LLC

(cherry picked from commit c6ded47d0bae801589b564dbe01dccd474edaed0)

3 years agovt: terminal size can grow too big with small font
Toomas Soome [Thu, 21 Jan 2021 22:18:56 +0000 (00:18 +0200)]
vt: terminal size can grow too big with small font

vt is using static buffers for on screen data, the buffer size is
calculated based on maximum supported screen size and 8x16 font.

When using hi-res graphics and very smaller than 8x16 font, we
need to be careful not to overflow static buffers in vt.

Testing: I did test by building smaller buffers than vt currently is using,
royger was testing on actual 4k capable hardware.

MFC after: 1 week
Tested by: royger

(cherry-picked from 32bf05ad89aaa93f4dd27e3721f4cb52cf57fa03)

3 years agossh: remove unused variable
Ed Maste [Fri, 12 Feb 2021 03:21:40 +0000 (22:21 -0500)]
ssh: remove unused variable

This was introduced in 03f6c5cd93ec, which added use of
sysctl net.inet.ip.portrange.reservedhigh instead of IPPORT_RESERVED,
but it appears the rest of that change was lost in some subsequent
update.

The change should probably be restored, but until then there is no
reason to leave an unused variable around.

MFC after: 3 days
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 9e14b918f956c532d0b81c945160bd9bc85c5604)

3 years agossh: remove ssh-hpn leftovers
Ed Maste [Fri, 12 Feb 2021 14:09:00 +0000 (09:09 -0500)]
ssh: remove ssh-hpn leftovers

This was introduced in 8998619212f3a, and left behind when the hpn-ssh
patches were removed in 60c59fad8806.  Although Being able to log
SO_RCVBUF in debug mode might have some small value on its own, it's
not worth carrying an extra diff against upstream.

Reviewed by: kevans
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28610

(cherry picked from commit a62dc346f6171ef1bd52bb8795eaf2d64394ac24)

3 years agossh: diff reduction against OpenBSD, remove unused includes
Ed Maste [Fri, 12 Feb 2021 01:41:02 +0000 (20:41 -0500)]
ssh: diff reduction against OpenBSD, remove unused includes

These appear to be leftovers from ca86bcf2531c7 and f7167e0ea0bf5

MFC after: 3 days
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 154adbbeb8fc2a0d183ec3a4db32cd13668205e8)