]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agojail(8): reset to root cpuset before attaching to run commands
Kyle Evans [Thu, 4 Mar 2021 19:28:53 +0000 (13:28 -0600)]
jail(8): reset to root cpuset before attaching to run commands

Recent changes have made it such that attaching to a jail will augment
the attaching process' cpu mask with the jail's cpuset. While this is
convenient for allowing the administrator to cpuset arbitrary programs
that will attach to a jail, this is decidedly not convenient for
executing long-running daemons during jail creation.

This change inserts a reset of the process cpuset to the root cpuset
between the fork and attach to execute a command. This allows commands
executed to have the widest mask possible, and the administrator can
cpuset(1) it back down inside the jail as needed.

With this applied, one should be able to change a jail's cpuset at
exec.poststart in addition to exec.created.  The former was made
difficult if jail(8) itself was running with a constrained set, as then
some processes may have been spawned inside the jail with a non-root
set.  The latter is the preferred option so that processes starting in
the jail are constrained appropriately up front.

Note that all system commands are still run with the process' initial
cpuset applied.

PR: 253724
Approved by: re (gjb)

(cherry picked from commit 466df976babed65f8a8de9e36d7f016a444609af)
(cherry picked from commit bdd61b6914f1f961b5f414b2d5cc623a5a829b89)

3 years agowg(4): Fix an example in the manual page
Gordon Bergling [Sun, 7 Mar 2021 19:27:59 +0000 (20:27 +0100)]
wg(4): Fix an example in the manual page

The example in the manual page of wg(4) for connecting to a
peer was missing the 'public-key' ifconfig(8) keyword and for the
addressed peer the port must be specified.

PR: 253866
Reported by: Sergey Akhmatov <sergey at akhmatov dot ru>
Approved by: re (gjb)
Reviewed by: debdrup
Differential Revision: https://reviews.freebsd.org/D29115

(cherry picked from commit f7bfe310191c8292da51c8da166a521ff16e0e46)

3 years agosecurity(7): mention new W^X sysctls in the manual page
Evgeniy Khramtsov [Tue, 2 Mar 2021 18:52:22 +0000 (19:52 +0100)]
security(7): mention new W^X sysctls in the manual page

Reviewed by: emaste, gbe
Approved by: re (gjb)
Differential Revision: https://reviews.freebsd.org/D28986

(cherry picked from commit 907023b454f06a6af87f21f8a9d6de6c11b2d275)

3 years agowg: Avoid leaking mbufs when the input handshake queue is full
Mark Johnston [Mon, 8 Mar 2021 17:39:05 +0000 (12:39 -0500)]
wg: Avoid leaking mbufs when the input handshake queue is full

Approved by: re
Reviewed by: grehan
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29011

(cherry picked from commit a11009dccb6a2e75de2b8f1b45a0896eda2e6d85)
(cherry picked from commit 47495bf648a3394383eec64cbff4f3527e76f690)

3 years agobacklight(8): Add note that with option it print the current brightness.
Emmanuel Vadot [Wed, 3 Mar 2021 08:00:42 +0000 (09:00 +0100)]
backlight(8): Add note that with option it print the current brightness.

MFC after:    3 days
PR:        253737
Approved by:  re (gjb)

(cherry picked from commit 1df30489a8f7083c98010c94d9ce522f9e8213dc)
(cherry picked from commit f21c0366f532888bec164717a93964610ab6baf6)

3 years agobacklight: Fix incr/decr with percent value of 0
David Schlachter [Wed, 3 Mar 2021 07:57:35 +0000 (08:57 +0100)]
backlight: Fix incr/decr with percent value of 0

This now does nothing instead of incr/decr by 10%

MFC After:    3 days
PR:        253736
Approved by:  re (gjb)

(cherry picked from commit 3b005d51bd0fe4d8d19fb2df4d470b6e8baebf16)
(cherry picked from commit 9ba393f2ca0fd561c1fbf96f38eb014d7f883381)

3 years agoFix dst/netmask handling in routing socket code.
Alexander V. Chernikov [Tue, 16 Feb 2021 20:30:04 +0000 (20:30 +0000)]
Fix dst/netmask handling in routing socket code.

Traditionally routing socket code did almost zero checks on
 the input message except for the most basic size checks.

This resulted in the unclear KPI boundary for the routing system code
 (`rtrequest*` and now `rib_action()`) w.r.t message validness.

Multiple potential problems and nuances exists:
* Host bits in RTAX_DST sockaddr. Existing applications do send prefixes
 with hostbits uncleared. Even `route(8)` does this, as they hope the kernel
 would do the job of fixing it. Code inside `rib_action()` needs to handle
 it on its own (see `rt_maskedcopy()` ugly hack).
* There are multiple way of adding the host route: it can be DST without
 netmask or DST with /32(/128) netmask. Also, RTF_HOST has to be set correspondingly.
 Currently, these 2 options create 2 DIFFERENT routes in the kernel.
* no sockaddr length/content checking for the "secondary" fields exists: nothing
 stops rtsock application to send sockaddr_in with length of 25 (instead of 16).
 Kernel will accept it, install to RIB as is and propagate to all rtsock consumers,
 potentially triggering bugs in their code. Same goes for sin_port, sin_zero, etc.

The goal of this change is to make rtsock verify all sockaddr and prefix consistency.
Said differently, `rib_action()` or internals should NOT require to change any of the
 sockaddrs supplied by `rt_addrinfo` structure due to incorrectness.

To be more specific, this change implements the following:
* sockaddr cleanup/validation check is added immediately after getting sockaddrs from rtm.
* Per-family dst/netmask checks clears host bits in dst and zeros all dst/netmask "secondary" fields.
* The same netmask checking code converts /32(/128) netmasks to "host" route case
 (NULL netmask, RTF_HOST), removing the dualism.
* Instead of allowing ANY "known" sockaddr families (0<..<AF_MAX), allow only actually
 supported ones (inet, inet6, link).
* Automatically convert `sockaddr_sdl` (AF_LINK) gateways to
  `sockaddr_sdl_short`.

Reported by: Guy Yur <guyyur at gmail.com>
Reviewed By: donner
Approved by: re(gjb)
Differential Revision: https://reviews.freebsd.org/D28668

(cherry picked from commit e1bdecd9f60a80604a351e38cab7cfc56e308c66)

3 years agoFix dpdk/ldradix fib lookup algorithm preference calculation.
Alexander V. Chernikov [Sun, 7 Mar 2021 22:05:34 +0000 (22:05 +0000)]
Fix dpdk/ldradix fib lookup algorithm preference calculation.

The current preference number were copied from IPv4 code,
 assuming 500k routes to be the full-view. Adjust with the current
 reality (100k full-view).

Reported by: Marek Zarychta <zarychtam at plan-b.pwste.edu.pl>
Approved by: re(gjb)

(cherry picked from commit 8a25d3f6ce34b80fef5fd6a324da724c56ad94ed)

3 years agoMake in_localip_more() fib-aware.
Alexander V. Chernikov [Tue, 16 Feb 2021 20:00:46 +0000 (20:00 +0000)]
Make in_localip_more() fib-aware.

It fixes loopback route installation for the interfaces
 in the different fibs using the same prefix.

Reviewed By: donner
PR: 189088
Approved by: re(gjb)
Differential Revision: https://reviews.freebsd.org/D28673

(cherry picked from commit f67641675958cb566b0ae50dc6942017d42393fe)

3 years agoice(4): Update to version 0.28.1-k
Eric Joyner [Tue, 23 Feb 2021 01:45:09 +0000 (17:45 -0800)]
ice(4): Update to version 0.28.1-k

This updates the driver to align with the version included in
the "Intel Ethernet Adapter Complete Driver Pack", version 25.6.

There are no major functional changes; this mostly contains
bug fixes and changes to prepare for new features. This version
of the driver uses the previously committed ice_ddp package
1.3.19.0.

Signed-off-by: Eric Joyner <erj@FreeBSD.org>
Tested by: jeffrey.e.pieper@intel.com
Approved by: re (gjb)
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D28640

(cherry picked from commit d08b8680e12ad692736c84238dcf45c70c228914)
(cherry picked from commit 1da549169de0b30f0ba92fdb4e74897c837d618d)

3 years agoice_ddp: Update package file to 1.3.19.0
Eric Joyner [Tue, 23 Feb 2021 01:43:54 +0000 (17:43 -0800)]
ice_ddp: Update package file to 1.3.19.0

This package is intended to be used with ice(4) version 0.28.1-k.
That update will happen in a forthcoming commit.

Signed-off-by: Eric Joyner <erj@FreeBSD.org>
Approved by: re (gjb)
Sponsored by: Intel Corporation

(cherry picked from commit a7ac518bff64d48cf262c60c4dc57eef34e74a07)
(cherry picked from commit a02640c79e0a97b925f49302763da9aa201c4a20)

3 years agoixl(4): Add ability to control link state on ifconfig down
Krzysztof Galazka [Wed, 3 Mar 2021 01:38:51 +0000 (17:38 -0800)]
ixl(4): Add ability to control link state on ifconfig down

Add sysctl link_active_on_if_down, which allows user to control
if interface is kept in active state when it is brought
down with ifconfig. Set it to enabled by default to preserve
backwards compatibility.

Reviewed by: erj
Tested by: gowtham.kumar.ks@intel.com
Approved by: re (gjb)
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D28028

(cherry picked from commit 21802a127d83e8a8c721d69b697e7ddb223d7797)
(cherry picked from commit 2b94bda05a6d43e89c4a785c0f1cd569a41cb200)

3 years agoixl(4): Report RX errors as sum of all RX error counters
Krzysztof Galazka [Wed, 3 Mar 2021 01:33:11 +0000 (17:33 -0800)]
ixl(4): Report RX errors as sum of all RX error counters

HW keeps track of RX errors using several counters, each for
specific type of errors. Report RX errors to OS as sum
of all those counters: CRC errors, illegal bytes, checksum,
length, undersize, fragment, oversize and jabber errors.

There is no HW counter for frames with invalid L3/L4 checksums
so add a SW one.

Also add a "rx_errors" sysctl with a copy of netstat IERRORS
counter value to make it easier accessible from scripts.

Reviewed By: erj
Tested By: gowtham.kumar.ks@intel.com
Approved by: re (gjb)
Sponsored By: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D27639

(cherry picked from commit 9f99061ef9c95b171fc92d34026222bb5e052337)
(cherry picked from commit b149f7c23d13e73b92c2bf8c3691e3e1ebd833c1)

3 years agoix(4): Report RX errors as sum of all RX error counters
Piotr Pietruszewski [Wed, 3 Mar 2021 01:21:58 +0000 (17:21 -0800)]
ix(4): Report RX errors as sum of all RX error counters

HW keeps track of RX errors using several counters, each for
specific type of errors. Report RX errors to OS as sum
of all those counters: CRC errors, illegal bytes, checksum,
length, undersize, fragment, oversize and jabber errors.

Also, add new "rx_errs" sysctl in the dev.ix.N.mac_stats tree. This is
to provide an another way to display the sum of RX errors.

Signed-off-by: Piotr Pietruszewski <piotr.pietruszewski@intel.com>
Reviewed By: erj
Tested By: gowtham.kumar.ks@intel.com
Approved by: re (gjb)
Sponsored By: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D27191

(cherry picked from commit afb1aa4e6df245d38fd2ba683fa521d5dabe8392)
(cherry picked from commit 8fa11f89225695c185a8a92c7530e270e77552f8)

3 years agoixl(4): Fix VLAN HW filtering
Krzysztof Galazka [Wed, 3 Feb 2021 23:22:55 +0000 (15:22 -0800)]
ixl(4): Fix VLAN HW filtering

X700 family of controllers has limited number of available VLAN
HW filters. Driver did not handle properly a case when user
assigned more VLANs to the interface which had all filters
already in use. Fix that by disabling HW filtering when
it is impossible to create filters for all requested VLANs.
Keep track of registered VLANs using bitstring to be able
to re-enable HW filtering when number of requested VLANs
drops below the limit.

Also switch all allocations to use M_IXL malloc type
to ease detecting memory leaks in the driver.

Reviewed by: erj
Tested by: gowtham.kumar.ks@intel.com
Approved by: re (gjb)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D28137

(cherry picked from commit 7d4dceec103039e2b2fa90793ceeb71a8d6684aa)
(cherry picked from commit 7e166d608eecf0188bbb7edf6b3d9abffe1dfc6b)

3 years agoAdd a few missed files to libclang_rt.profile-<arch>.a
Dimitry Andric [Fri, 5 Mar 2021 20:06:05 +0000 (21:06 +0100)]
Add a few missed files to libclang_rt.profile-<arch>.a

Otherwise, programs compiled with -fprofile-instr-generate will
encounter undefined symbol errors during linking, for example
__llvm_profile_counter_bias, lprofSetRuntimeCounterRelocation and a few
others were missing from the profile library.

Approved by: re (gjb)
Reported by: ota@j.email.ne.jp
PR: 254001

(cherry picked from commit 772c631af81abdb6d498d972bab79d04d3db16d0)
(cherry picked from commit 3f684107ef6e41b03a47d64d6e31cebc823d7448)

3 years agoarmv8crypto: fix AES-XTS regression introduced by ed9b7f44
Oleksandr Tymoshenko [Sun, 7 Mar 2021 20:03:47 +0000 (12:03 -0800)]
armv8crypto: fix AES-XTS regression introduced by ed9b7f44

Initialization of the XTS key schedule was accidentally dropped
when adding AES-GCM support so all-zero schedule was used instead.
This rendered previously created GELI partitions unusable.
This change restores proper XTS key schedule initialization.

Reported by: Peter Jeremy <peter@rulingia.com>
MFC after: immediately
Approved by: re (gjb)

(cherry picked from commit 748be78e60ccc4a26325a636347debb1f7e6749b)

3 years agoloader: cursor off should restore display content
Toomas Soome [Sat, 6 Mar 2021 10:19:43 +0000 (12:19 +0200)]
loader: cursor off should restore display content

When drawing cursor, we should store original display
content because there may be image data we would like to restore
when the cursor is removed.

PR: 254054
Reported by: Jose Luis Duran
Approved by: re (gjb)

(cherry picked from commit d708f23ebb06cfc9cf8f96f17a43eb63653b818a)

3 years agoatomic(9): note that atomic_interrupt_fence first appeared in 13.0
Konstantin Belousov [Sat, 6 Mar 2021 05:21:40 +0000 (07:21 +0200)]
atomic(9): note that atomic_interrupt_fence first appeared in 13.0

Approved by: re (gjb)

(cherry picked from commit f5e930b369c6ea7a3f81d8e5b52cc395bb7b4187)
(cherry picked from commit 8fb8f26ab4b62891be27402e4335c27cb6839d9e)

3 years agoUse atomic_interrupt_fence() instead of bare __compiler_membar()
Konstantin Belousov [Fri, 26 Feb 2021 23:54:17 +0000 (01:54 +0200)]
Use atomic_interrupt_fence() instead of bare __compiler_membar()

Approved by: re (gjb)

(cherry picked from commit b5449c92b489445635c7962875ce73b2c9211bba)
(cherry picked from commit c10e0a4656bfe650bb3bf46fcf026a8a51a34a69)

3 years agokcsan: add atomic_interrupt_fence
Mateusz Guzik [Mon, 1 Mar 2021 07:42:15 +0000 (07:42 +0000)]
kcsan: add atomic_interrupt_fence

Approved by: re (gjb)

(cherry picked from commit 2c1c1255e41ac3fecd79f9f704c934642f34fd60)
(cherry picked from commit a552da13fc8f803ffc51755436441f3c14e3c817)

3 years agoatomic: add atomic_interrupt_fence()
Konstantin Belousov [Tue, 23 Feb 2021 22:12:29 +0000 (00:12 +0200)]
atomic: add atomic_interrupt_fence()

Approved by: re (gjb)

(cherry picked from commit e2494f7561c852951d8ac567314f5e12f19ee7af)

3 years agoDo not exit ctl_be_block_worker() prematurely.
Alexander Motin [Sat, 6 Mar 2021 03:39:52 +0000 (22:39 -0500)]
Do not exit ctl_be_block_worker() prematurely.

Return while there are any I/Os in a queue may result in them stuck
indefinitely, since there is only one taskqueue task for all of them.
I think I've reproduced this by switching ha_role to secondary under
heavy load.

Approved by: re (delphij)

(cherry picked from commit 6ed39db2573bb808ac2c206cd6c831f0be86219c)
(cherry picked from commit a3d416f3daafc59bc2f4ee278593c8a3f7a30d2b)

3 years agoMove back the isa non-PNP driver deadline to FreeBSD 14.
Warner Losh [Mon, 8 Mar 2021 22:59:48 +0000 (15:59 -0700)]
Move back the isa non-PNP driver deadline to FreeBSD 14.

Approved by: re@ (gjb)

(cherry picked from commit 6ffdaa5f2d4f0881557f64dabf61fb57541e0fba)
(cherry picked from commit 832d0719d6e5eb4ee2dec62f88ec79bfb617cd9d)

3 years agoriscv: fix errors in some atomic type aliases
Mitchell Horne [Thu, 4 Mar 2021 17:52:45 +0000 (13:52 -0400)]
riscv: fix errors in some atomic type aliases

This appears to be a copy-and-paste error that has simply been
overlooked. The tree contains only two calls to any of the affected
variants, but recent additions to the test suite started exercising the
call to atomic_clear_rel_int() in ng_leave_write(), reliably causing
panics.

Apparently, the issue was inherited from the arm64 atomic header. That
instance was addressed in c90baf6817a0, but the fix did not make its way
to RISC-V.

Note that the particular test case ng_macfilter_test:main still appears
to fail on this platform, but this change reduces the panic to a
timeout.

PR: 253237
Reported by: Jenkins, arichardson
Reviewed by: kp, arichardson
Approved by: re (gjb)

(cherry picked from commit 0d3b3beeb253e09b2b6b3805065594aecc7e2c2f)
(cherry picked from commit cc24f5bc6f6eb56a959bd23ebb051d3bf6ebf670)

3 years agobc: Vendor import new version 3.3.3
Stefan Eßer [Fri, 5 Mar 2021 10:30:11 +0000 (11:30 +0100)]
bc: Vendor import new version 3.3.3

(cherry picked from commit 028616d0dd69a3da7a30cb94d35f040bf2ced6b9)

Make length(0) and length(0.0) return 1 for compatibility with GNU bc
and the traditional FreeBSD bc.

Fix a potential division by zero error in a non-standard (extended)
math library function.

(cherry picked from commit f165641df4da1752f8bb1f55c1e602cdb657fba4)

Approved by:   re

3 years agoUpgrade to version 3.3.0
Stefan Eßer [Wed, 17 Feb 2021 21:56:16 +0000 (22:56 +0100)]
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)

Approved by:   re

3 years agoif_vtbe: Add missing includes to fix build
Jessica Clarke [Mon, 8 Mar 2021 20:47:29 +0000 (20:47 +0000)]
if_vtbe: Add missing includes to fix build

PR: 254137
Reported by: Mina Galić <me@igalic.co>
Fixes: f8bc74e2f4a5 ("tap: add support for virtio-net offloads")
Approved by: re (gjb)

(cherry picked from commit f2f8405cf6b50a9d91acc02073abf1062d9d34f4)
(cherry picked from commit e3394851b5da6ec46e655a4f801cd6cac0840445)

3 years agotcp: remove incorrect reset of SACK variable in PRR
Richard Scheffenegger [Fri, 5 Mar 2021 16:45:23 +0000 (17:45 +0100)]
tcp: remove incorrect reset of SACK variable in PRR
tcp: Add prr_out in preparation for PRR/nonSACK and LRD

Reviewed by:   #transport, rrs, tuexen, kbowling
Approved by:   #re (gjb)
PR:            253848
MFC after:     3 days
Sponsored by:  NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D29083
Differential Revision: https://reviews.freebsd.org/D29058

(cherry picked from commit 4a8f3aad37dd35c905e34b64b022d60844ba8d01)
(cherry picked from commit d90bba73a2e43fa12ea19425d101df4c488c1070)

(cherry picked from commit e53138694aa41c24c17847afe959225ce0eeff91)
(cherry picked from commit 71cc98ba735283b8720c9031eb87810f3d3d96a0)

3 years agorack: unbreak TCP fast open for the client side
Michael Tuexen [Fri, 5 Mar 2021 14:57:26 +0000 (15:57 +0100)]
rack: unbreak TCP fast open for the client side

Allow sending user data on the SYN segment.

Reviewed by: rrs
Approved by: re (gjb)
Differential Revision: https://reviews.freebsd.org/D29082
Sponsored by: Netflix, Inc.

(cherry picked from commit 705d06b289e9821439b7b694d766cad75bc064e5)
(cherry picked from commit 873f8376015c12febec3619976a8c30fbead4ad6)

3 years agozfs: cancel TRIM or initialize on FAULTED non-writeable vdevs
Martin Matuska [Wed, 3 Mar 2021 01:38:09 +0000 (02:38 +0100)]
zfs: cancel TRIM or initialize on FAULTED non-writeable vdevs

From the openzfs commit message:
  When a device which is actively trimming or initializing becomes
  FAULTED, and therefore no longer writable, cancel the active
  TRIM or initialization.  When the device is merely taken offline
  with `zpool offline` then stop the operation but do not cancel it.
  When the device is brought back online the operation will be
  resumed if possible.

Obtained from: openzfs/zfs@bedbc13daa6dfe9e0221bfadb8d8db2378deaacc
Approved by: re (delphij)

(cherry picked from commit dc2743434f6cc73ca8ec1d551aba03a678eac804)

3 years agozfs: fix assert in FreeBSD-specific dmu_read_pages
Martin Matuska [Wed, 3 Mar 2021 01:32:59 +0000 (02:32 +0100)]
zfs: fix assert in FreeBSD-specific dmu_read_pages

From the openzfs 2e160dee9 commit message:
  The function has three similar pieces of code: for read-behind pages,
  requested pages and read-ahead pages.  All three pieces had an
  assert to ensure that the page is not mapped.  Later the assert was
  relaxed to require that the page is not mapped for writing.  But that
  was done in two places out of three.  This change fixes the third piece,
  read-ahead.

Obtained from: openzfs/zfs@2e160dee97a4badbc318561f76ea56451c916d2f
Approved by: re (delphij)

(cherry picked from commit 19049a2b2bd7119ef7b34102513f6bbfdf9ff862)

3 years agozfs: fix vdev_rebuild_thread deadlock
Martin Matuska [Wed, 3 Mar 2021 01:28:56 +0000 (02:28 +0100)]
zfs: fix vdev_rebuild_thread deadlock

From the openzfs 8e43fa12c commit message:
  The metaslab_disable() call may block waiting for a txg sync.
  Therefore it's important that vdev_rebuild_thread release the
  SCL_CONFIG read lock it is holding before this call.  Failure
  to do so can result in the txg_sync thread getting blocked
  waiting for this lock which results in a deadlock.

Obtained from: openzfs/zfs@8e43fa12c571878f32119122771888ab9092a75a
Approved by: re (delphij)

(cherry picked from commit c7069063144395b025c0ef178431eb2cafdbe1ca)

3 years agozfs: fix overly broad locking in spa_vdev_config_exit()
Martin Matuska [Wed, 3 Mar 2021 01:25:03 +0000 (02:25 +0100)]
zfs: fix overly broad locking in spa_vdev_config_exit()

Resolves a deadlock which can occur when the ZED or zpool
command attaches a new device.

From the openzfs 75a089ed3 commit message:
  Calling vdev_free() only requires the we acquire the spa config
  SCL_STATE_ALL locks, not the SCL_ALL locks.  In particular, we need
  need to avoid taking the SCL_CONFIG lock (included in SCL_ALL) as a
  writer since this can lead to a deadlock.  The txg_sync_thread() may
  block in spa_txg_history_init_io() when taking the SCL_CONFIG lock
  as a reading when it detects there's a pending writer.

Obtained from: openzfs/zfs@75a089ed34befb8d11df9be92a4438cc49554bf6
Approved by: re (delphij)

(cherry picked from commit f08e17c8a251210b58d63b52bfe1a77dccff6e78)

3 years agogrowfs: allow operation on RW-mounted filesystems
Ed Maste [Tue, 2 Mar 2021 22:35:48 +0000 (17:35 -0500)]
growfs: allow operation on RW-mounted filesystems

growfs supports growing mounted filesystems (writes are temporarily
suspended while the grow happens).  Drop the check for fs_clean == 0
to restore this case.  Leave fs_flags check for FS_UNCLEAN or
FS_NEEDSFSCK which represent the state of the filesystem when it was
mounted, and fsck should be run first if they are set.

PR: 253754
Reviewed by: mckusick
Approved by: re (gjb)
Fixes: 6eb925f8450f ("Filesystem utilities that modify the...")
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29021

(cherry picked from commit 0dcde5cc12744e5188300711a8829e5e6a9cd0de)
(cherry picked from commit b5920128c7ebcf5060605928263a54b31b317993)

3 years agoloader_4th: brand image is aligned right
Toomas Soome [Sat, 6 Mar 2021 08:54:08 +0000 (10:54 +0200)]
loader_4th: brand image is aligned right

With screen border removed, I forgot to update forth brand image
coordinates to avoid image alignment.

(cherry picked from commit 6a3095aa6d0350dda89bac66d26f22a01e2257c4)

Approved by:    re (delphij)

3 years agoImport wireguard fixes from pfSense 2.5
Peter Grehan [Sat, 27 Feb 2021 04:15:04 +0000 (14:15 +1000)]
Import wireguard fixes from pfSense 2.5

Merge the following fixes from https://github.com/pfsense/FreeBSD-src
 1940e7d3  Save address of ingress packets to allow wg to work on HA
 8f5531f1  Fix connection to IPv6 endpoint
 825ed9ee  Fix tcpdump for wg IPv6 rx tunnel traffic
 2ec232d3  Fix issue with replying to INITIATION messages in server mode
 ec77593a  Return immediately in wg_init if in DETACH'd state
 0f0dde6f  Remove unnecessary wg debug printf on transmit
 2766dc94  Detect and fix case in wg_init() where sockets weren't cleaned up
 b62cc7ac  Close the UDP tunnel sockets when the interface has been stopped

Approved by: re (kib)
Obtained from: pfSense 2.5
Relnotes: yes
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 96aabea8bd238b503e949753355dc5b6a857aa9c)

3 years agoarcmsr(4): Fixed no action of hot plugging device on type_F adapter.
Xin LI [Wed, 3 Mar 2021 06:57:20 +0000 (22:57 -0800)]
arcmsr(4): Fixed no action of hot plugging device on type_F adapter.

Many thanks to Areca for continuing to support FreeBSD.

Submitted by: 黃清隆 <ching2048 areca com tw>
Approved by: re (gjb)

(cherry picked from commit 5842073a9b7471831e0da48d29dd984d575f4e9e)
(cherry picked from commit e298c1c3c257446eba06945a0b4755ca30387012)

3 years agoloader: use display pixel density for font autoselection
Toomas Soome [Sat, 20 Feb 2021 08:51:28 +0000 (10:51 +0200)]
loader: use display pixel density for font autoselection

Calculate font size from 16 density independent pixels (dp) by using:
size = 16 * ppi/160 * display_factor

We are specifying font size 16dp, and assuming 1dp = 160ppi.
Also apply scaling factor 2 (display_factor).

(cherry picked from commit becaac3972f1fde4e3c44516399468ba5ca65c9b)

Approved by:    re (gjb)

3 years agoupdate to RC1
Glen Barber [Fri, 5 Mar 2021 00:51:39 +0000 (19:51 -0500)]
update to RC1

Approved by: re (implicit)
Sponsored by: Rubicon Communications, LLC ("Netgate")

3 years agolinux: fix handling of flags for 32 bit send(2) syscall
Edward Tomasz Napierala [Fri, 5 Feb 2021 17:24:23 +0000 (17:24 +0000)]
linux: fix handling of flags for 32 bit send(2) syscall

Previously the flags were passed as-is, which could resulted
in spurious EAGAIN returned for non-blocking sockets, which
broke some Steam games.

Approved by: re (gjb)
PR: 248065
Reported By: Alex S <iwtcex@gmail.com>
Tested By: Alex S <iwtcex@gmail.com>
Reviewed By: emaste
MFC After: 3 days
Sponsored By: The FreeBSD Foundation

(cherry picked from commit f6e8256a965d5b7a7d43034ea31b2430a3b51066)
(cherry picked from commit 9d930fb09072d21464288df8c834cb8d0b760073)

3 years agoDon't check compat.linux.emul_path before loading linux(4)
Edward Tomasz Napierala [Mon, 8 Feb 2021 21:52:31 +0000 (21:52 +0000)]
Don't check compat.linux.emul_path before loading linux(4)

Fix e40787f900f to make libexec/rc/rc.d/linux retrieve the sysctl
after loading the kernel module which provides it, not before.

Approved by: re (gjb)
Reported By: jkim
Sponsored By: The FreeBSD Foundation

(cherry picked from commit 07cac176fba947381c8111b8e02e8067e7fa542a)
(cherry picked from commit 5dc2e1bcf41f853b31b6d08a5c2d643408e890f3)

3 years agoUse compat.linux.emul_path instead of hardcoded path in /etc/rc.d/linux
Edward Tomasz Napierala [Tue, 2 Feb 2021 14:40:38 +0000 (14:40 +0000)]
Use compat.linux.emul_path instead of hardcoded path in /etc/rc.d/linux

In /etc/rc.d/linux the mounting paths of procfs, sysfs and devfs
are hardcoded to "/compat/linux".  Switching to the content of
compat.linux.emul_path sysctl would allow to switch linuxulator
to different place.

Approved by: re (gjb)
Submitted by: freebsdnewbie_freenet.de
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27807

(cherry picked from commit e40787f900f3c262d5134d342e5a16757dd2193c)
(cherry picked from commit 1b2802ed4ed09746d6870080f85d79a9ccd782b0)

3 years agolibc: fix buffer overrun in getrpcport(3)
Edward Tomasz Napierala [Sun, 31 Jan 2021 21:41:55 +0000 (21:41 +0000)]
libc: fix buffer overrun in getrpcport(3)

Approved by: re (gjb)
Reviewed By: markj
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D27332

(cherry picked from commit 5299d64b2b9f7a25e423ef1785d9402a0ef198d3)
(cherry picked from commit a3576b6207074ba5182be253c26af72f8fb51759)

3 years agoO_RELATIVE_BENEATH: return ENOTCAPABLE instead of EINVAL for abs path
Konstantin Belousov [Sun, 28 Feb 2021 23:59:12 +0000 (01:59 +0200)]
O_RELATIVE_BENEATH: return ENOTCAPABLE instead of EINVAL for abs path

Approved by: re (gjb)

(cherry picked from commit 28cd3a673e0e32b009fd573764956b280d1affe1)

3 years agonameicap_check_dotdot: trim tracker on check
Konstantin Belousov [Sun, 28 Feb 2021 00:15:21 +0000 (02:15 +0200)]
nameicap_check_dotdot: trim tracker on check

Approved by:  re (gjb)

(cherry picked from commit 49c98a4bf3a87ace0df99056fa683805c1645e61)

3 years agoAdd nameicap_cleanup_from(), to clean tracker list starting from some element
Konstantin Belousov [Sun, 28 Feb 2021 00:14:43 +0000 (02:14 +0200)]
Add nameicap_cleanup_from(), to clean tracker list starting from some element

Approved by: re (gjb)

(cherry picked from commit e8a2862aa0384c75603f801625e309a3dae0ed05)

3 years agonameicap_tracker_add: avoid duplicates in the tracker list
Konstantin Belousov [Sun, 28 Feb 2021 00:13:19 +0000 (02:13 +0200)]
nameicap_tracker_add: avoid duplicates in the tracker list

Approved by: re (gjb)

(cherry picked from commit 2388ad7c293fbc89ee239a1adcb87fd158c4e8e9)

3 years agoDo not call nameicap_tracker_add() for dotdot case.
Konstantin Belousov [Sun, 28 Feb 2021 00:12:43 +0000 (02:12 +0200)]
Do not call nameicap_tracker_add() for dotdot case.

Approved by: re (gjb)

(cherry picked from commit 59e749428111c029116a4302a544c7cc18b33772)

3 years agoopen(2): Remove O_BENEATH and AT_BENEATH
Konstantin Belousov [Tue, 16 Feb 2021 03:31:40 +0000 (05:31 +0200)]
open(2): Remove O_BENEATH and AT_BENEATH

Approved by: re (gjb)

(cherry picked from commit 20e91ca36a56b8db1e6677f577ad011b66dd6eb3)

3 years agofhlink(2): the syscalls do not take flag
Konstantin Belousov [Sun, 28 Feb 2021 00:38:11 +0000 (02:38 +0200)]
fhlink(2): the syscalls do not take flag

Approved by: re (gjb)

(cherry picked from commit 600756afb532a86a39fb488f5c4fc7e248921655)

3 years agoFFS extattr: fix handling of the tail
Konstantin Belousov [Mon, 1 Mar 2021 15:24:11 +0000 (17:24 +0200)]
FFS extattr: fix handling of the tail

Approved by: re (gjb)

(cherry picked from commit 8742817ba62ec604156c139727155d36f5fbad06)

3 years agosendfile: Use the pager size to determine the file extent when possible
Mark Johnston [Thu, 25 Feb 2021 15:04:44 +0000 (10:04 -0500)]
sendfile: Use the pager size to determine the file extent when possible

Previously sendfile would issue a VOP_GETATTR and use the returned size,
i.e., the file size.  When paging in file data, sendfile_swapin() will
use the pager to determine whether it needs to zero-fill, most often
because of a hole in a sparse file.  An attempt to page in beyond the
end of a file is treated this way, and occurs when the requested page is
past the end of the pager.  In other words, both the file size and pager
size were used interchangeably.

With ZFS, updates to the pager and file sizes are not synchronized by
the exclusive vnode lock, at least partially due to its use of
MNTK_SHARED_WRITES.  In particular, the pager size is updated after the
file size, so in the presence of a writer concurrently extending the
file, sendfile could incorrectly instantiate "holes" in the page cache
pages backing the file, which manifests as data corruption when reading
the file back from the page cache.  The on-disk copy is unaffected.

Fix this by consistently using the pager size when available.

Approved by: re (gjb)
Reported by: dumbbell
Reviewed by: chs, kib
Tested by: dumbbell, pho
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28811

(cherry picked from commit faa998f6ff69573fe82765c77c7268ee89ac945e)
(cherry picked from commit 095558ac894977906fbbdf74c34b6d13fea7c8ed)

3 years agotcp: various improvements and fixes to PRR
Richard Scheffenegger [Fri, 19 Feb 2021 12:52:06 +0000 (13:52 +0100)]
tcp: various improvements and fixes to PRR
- Ensure cwnd doesn't shrink to zero with PRR
- use accurate rfc6675_pipe when enabled
- Address two incorrect calculations and enhance readability
- address second instance of cwnd potentially becoming zero
- fix sublte bug due to implicit int to uint typecase in max()
- fix bug due to typo in hand-coded CEILING() function by using howmany() macro
- use int instead of long, and add a missing long typecast
- replace if conditionals with easier to read imax/imin (as in pseudocode)
- Avoid accounting left-edge twice in partial ACK.
- Include new data sent in PRR calculation
- Improve PRR initial transmission timing
- Fix prr_out when pipe < ssthresh

Reviewed By:    #transport, kbowling, tuexen
Reported by:    Liang Tian
Approved by:    re (gjb)
MFC after:      3 days
Sponsored by:   NetApp, Inc.
Differential Revision:  https://reviews.freebsd.org/D28780
Differential Revision:  https://reviews.freebsd.org/D28816
Differential Revision:  https://reviews.freebsd.org/D28813
Differential Revision:  https://reviews.freebsd.org/D28819
Differential Revision:  https://reviews.freebsd.org/D28941
Differential Revision:  https://reviews.freebsd.org/D28953
Differential Revision:  https://reviews.freebsd.org/D28998

(cherry picked from commit 853fd7a2e39802e46bd3d6476529796ac22412d9)
(cherry picked from commit c3aa4ba5dfc084e40e4151b25a0d5f8d24a036ba)

(cherry picked from commit a8e431e1537d056a3f9e466eaceec28c399c220b)
(cherry picked from commit 32ed0ef06b8326271c4665406cac81fa47d0d29c)

(cherry picked from commit 48396dc77922c68377ecac0ead2f8b0b5453c451)
(cherry picked from commit ffbf1b809ef5080afa130c11fa4afce9fef7e7fe)

(cherry picked from commit 31d7a27c6e88c3d5bd0907774ec70176a92da5bb)
(cherry picked from commit 25fb4c363b299c26c35158fa059379af4a007253)

(cherry picked from commit 9e83a6a556ed8d9a2821de5d5f5c7d4b1292c694)
(cherry picked from commit 9596751563dc1819d177fa3ec6660a3bdc18021c)

(cherry picked from commit e9071000c9a04e3f685579500e24da9848944bb1)
(cherry picked from commit 2b43cd2ea26f758d23e8c009cf7521c4ddec7353)

(cherry picked from commit 0b0f8b359d0b94b09cfec35e5d5de01b23c7fbf1)
(cherry picked from commit 05e742af6f548364909ed671f0b3774e54dc77d1)

3 years agoRACK: fix an issue triggered by using the CDG CC module
Michael Tuexen [Tue, 2 Mar 2021 11:32:16 +0000 (12:32 +0100)]
RACK: fix an issue triggered by using the CDG CC module

Obtained from: rrs@
Approved by: re (gjb)
PR: 238741
Sponsored by: Netlix, Inc.

(cherry picked from commit 99adf230061268175a36061130e6adb0882270e8)
(cherry picked from commit ae608d4ee7202cc34603e620bc551547e772c4d2)

3 years agojail: allow root to implicitly widen its cpuset to attach
Kyle Evans [Fri, 26 Feb 2021 21:46:47 +0000 (15:46 -0600)]
jail: allow root to implicitly widen its cpuset to attach

The default behavior for attaching processes to jails is that the jail's
cpuset augments the attaching processes, so that it cannot be used to
escalate a user's ability to take advantage of more CPUs than the
administrator wanted them to.

This is problematic when root needs to manage jails that have disjoint
sets with whatever process is attaching, as this would otherwise result
in a deadlock. Therefore, if we did not have an appropriate common
subset of cpus/domains for our new policy, we now allow the process to
simply take on the jail set *if* it has the privilege to widen its mask
anyways.

With the new logic, root can still usefully cpuset a process that
attaches to a jail with the desire of maintaining the set it was given
pre-attachment while still retaining the ability to manage child jails
without jumping through hoops.

A test has been added to demonstrate the issue; cpuset of a process
down to just the first CPU and attempting to attach to a jail without
access to any of the same CPUs previously resulted in EDEADLK and now
results in taking on the jail's mask for privileged users.

PR: 253724
Approved by: re (gjb)

(cherry picked from commit 60c4ec806dfd0f79edf8ca3abc04bbb69c0418f7)
(cherry picked from commit c4ccb6d1be1f00ebcda9e83f06db55f9d6c152ac)

3 years agoddb: fix show devmap output on 32-bit arm
Thomas Skibo [Mon, 11 Jan 2021 20:58:12 +0000 (16:58 -0400)]
ddb: fix show devmap output on 32-bit arm

The output has been broken since 1b6dd6d772ca. Casting to uintmax_t
before the call to printf is necessary to ensure that 32-bit addresses
are interpreted correctly.

PR: 243236
Approved by: re (gjb)

(cherry picked from commit 9976b42b697ce203b1d257b2a6fe64c8a2961645)
(cherry picked from commit 0a223cf980b5ef8bea726a843fe5a7faf2278330)

3 years agoarmv8crypto: add missing newline
Elliott Mitchell [Sun, 28 Feb 2021 20:03:44 +0000 (16:03 -0400)]
armv8crypto: add missing newline

The missing newline mildly garbles boot-time messages and this can be
troublesome if you need those.

Reported by: Mike Karels (mike@karels.net)
Reviewed by: gonzo
Approved by: re (gjb)

(cherry picked from commit 530d38441d55b7ac62ebae6ac8ea76903a4a3b0c)
(cherry picked from commit 0ae67623992788538b90b7c0e2882c4aa645a81f)

3 years agonfsclient: fix panic in cache_enter_time()
Rick Macklem [Sun, 28 Feb 2021 01:54:05 +0000 (17:54 -0800)]
nfsclient: fix panic in cache_enter_time()

Juraj Lutter (otis@) reported a panic "dvp != vp not true" in
cache_enter_time() called from the NFS client's nfsrpc_readdirplus()
function.
This is specific to an NFSv3 mount with the "rdirplus" mount
option. Unlike NFSv4, NFSv3 replies to ReaddirPlus
includes entries for the current directory.

This trivial patch avoids doing a cache_enter_time()
call for the current directory to avoid the panic.

Approved by: re (gjb)

(cherry picked from commit 3fe2c68ba20fb3365ef91e0b85f88237b5369f38)

3 years agocopy_file_range(2): Fix for small values of input file offset and len
Rick Macklem [Mon, 1 Mar 2021 14:28:30 +0000 (06:28 -0800)]
copy_file_range(2): Fix for small values of input file offset and len

r366302 broke copy_file_range(2) for small values of
input file offset and len.

It was possible for rem to be greater than len and then
"len - rem" was a large value, since both variables are
unsigned.

Approved by: re (gjb)

(cherry picked from commit a5f9fe2bab789f49e8b53da3a62dbd34725e23ea)

3 years agormlock: Add a required compiler membar to the rlock slow path
Mark Johnston [Wed, 24 Feb 2021 02:15:50 +0000 (21:15 -0500)]
rmlock: Add a required compiler membar to the rlock slow path

The tracker flags need to be loaded only after the tracker is removed
from its per-CPU queue.  Otherwise, readers may fail to synchronize with
pending writers attempting to propagate priority to active readers, and
readers and writers deadlock on each other.  This was observed in a
stable/12-based armv7 kernel where the compiler had reordered the load
of rmp_flags to before the stores updating the queue.

Approved by: re (gjb)
Reviewed by: rlibby, scottl
Discussed with: kib
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D28821

(cherry picked from commit 1d44514fcd68809cfd493a7352ace29ddad443d6)
(cherry picked from commit c29d3ecdc8b3903d812c0467319ced6f85872d0e)

3 years agoCreate dhclient pid directory if it doesn't exist
Chris Rees [Sun, 21 Feb 2021 18:56:56 +0000 (18:56 +0000)]
Create dhclient pid directory if it doesn't exist

 - Upgrading from older FreeBSD versions can result in errors

 - /var/run can be a tmpfs, and this should be handled correctly

Approved by: re (gjb)
Approved by: markj
Differential: https://reviews.freebsd.org/D28843
MFC after: 2 weeks

(cherry picked from commit ce94bedf475ac17307be0d5cbc66a8abe0741bf6)

3 years agosctp: several fixes and improvements
Michael Tuexen [Sat, 23 Jan 2021 19:56:45 +0000 (20:56 +0100)]
sctp: several fixes and improvements

Approved by: re (gjb)

sctp: improve consistency

No functional change intended.

(cherry picked from commit 7a051c0a7890dc8e490ebe125bfc70a28e89ddaf)
(cherry picked from commit 459f1b906515076b7ce30a06ab69a60891d8cbe8)

sctp: fix PR-SCTP stats when adding addtional streams

(cherry picked from commit 0f7573ffd6141b19419c9a6238246b9ba0e6dce6)
(cherry picked from commit 21398f02b0c7913f815ae6ded426da60d92c635b)

sctp: fix a locking issue for old unordered data

Thanks to Anatoly Korniltsev for reporting the issue for the
userland stack.

(cherry picked from commit 8dc6a1edca6de0c64f6c082f69097746d1346592)
(cherry picked from commit 3fa95c0fe60bbd67db6043c7e18910387bbe1bac)

sctp: improve input validation

Improve the handling of INIT chunks in specific szenarios and
report and appropriate error cause.
Thanks to Anatoly Korniltsev for reporting the issue for the
userland stack.

(cherry picked from commit af885c57d65d33c0306e91d3e090e76772a0d012)
(cherry picked from commit 16b538975024e2b7038807bf5b712124f5a7b889)

sctp: small cleanup, no functional change intended.

(cherry picked from commit bdd4630c9a9cea64830f981fc897ac953c48892c)
(cherry picked from commit 5573b94fa67f954dd0db57de328e60941ee8c9d1)

sctp: clear a pointer to a net which will be removed

(cherry picked from commit 5ac839029d01c0f48e1b1ff1a599cb47cf5e98ee)
(cherry picked from commit 04c13928d9f306a7d7ac34452644a538d2be6fdc)

sctp: improve computation of an alternate net

Espeially handle the case where the net passed in is about to
be deleted and therefore not in the list of nets anymore.

Reported by: syzbot+9756917a7c8381adf5e8@syzkaller.appspotmail.com

(cherry picked from commit b963ce4588b33f733aef3f7a7f3fbe5018a89728)
(cherry picked from commit 8cf046aff9719779b665f7f4f4a8bad4b3945341)

sctp: avoid integer overflow when starting the HB timer

Reported by: syzbot+14b9d7c3c64208fae62f@syzkaller.appspotmail.com

(cherry picked from commit 70e95f0b6917a8b8cd4a2a5f883f3e9753fc86d8)
(cherry picked from commit f7c20120c19b6307536908a7f779be2832b133f3)

3 years agotcp: improve behaviour when using TCP_NOOPT
Michael Tuexen [Sun, 14 Feb 2021 11:10:31 +0000 (12:10 +0100)]
tcp: improve behaviour when using TCP_NOOPT

Use ISS for SEG.SEQ when sending a SYN-ACK segment in response to
an SYN segment received in the SYN-SENT state on a socket having
the IPPROTO_TCP level socket option TCP_NOOPT enabled.

Approved by: re (gjb)
Reviewed by: rscheff
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D28656

(cherry picked from commit ed782b9f5a7a05debe944a33b4ac9e5629a95803)
(cherry picked from commit e949dcc283cd3b19e8e3113d8d3e10a72c2bbe6e)

3 years agoRemove __NO_TLS.
Konstantin Belousov [Fri, 19 Feb 2021 15:20:29 +0000 (17:20 +0200)]
Remove __NO_TLS.

Approved by: re (gjb)

(cherry picked from commit 3ae8d83d04a7a6ec11b64c89ee60c180b0bde30e)

3 years agomips: Don't set __NO_TLS to disable some uses of TLS.
John Baldwin [Thu, 18 Feb 2021 00:34:23 +0000 (16:34 -0800)]
mips: Don't set __NO_TLS to disable some uses of TLS.

Approved by: re (gjb)

(cherry picked from commit 24fd63e0970f91189dd2acde987bd2e4c8c04a50)

3 years agoriscv: Don't set __NO_TLS to disable some uses of TLS.
John Baldwin [Thu, 18 Feb 2021 00:33:09 +0000 (16:33 -0800)]
riscv: Don't set __NO_TLS to disable some uses of TLS.

Approved by: re (gjb)

(cherry picked from commit dd176fd7e7b5aad231cd6ebf49fd14ae7394dfee)

3 years agolibsysdecode: fix decoding of TCP_NOPUSH and TCP_MD5SIG
Michael Tuexen [Tue, 9 Feb 2021 22:35:55 +0000 (23:35 +0100)]
libsysdecode: fix decoding of TCP_NOPUSH and TCP_MD5SIG

TCP_FASTOPEN_MIN_COOKIE_LEN was incorrectly registered as a name of
a IPPROTO_TCP level socket option, which overwrote TCP_NOPUSH.
TCP_FASTOPEN_PSK_LEN was incorrectly registered as a name of an
IPPROTO_TCP level socket option, which overwrote TCP_MD5SIG.

Approved by: re (gjb)
Sponsored by: Netflix, Inc.

(cherry picked from commit f25266bee7dafb10f03e06537c8127cc17335bed)
(cherry picked from commit 2a9b68d5e1bba633c37cc829f52e79e1281e910b)

3 years agomkimg: Add support for offset if the source is an image
Emmanuel Vadot [Thu, 25 Feb 2021 17:10:19 +0000 (18:10 +0100)]
mkimg: Add support for offset if the source is an image

This allow us to create image with the following format:
mkimg -v -o sdcard -s gpt -p efi:=esp_aarch64.img:1M -p freebsd-ufs::1G

Which will add a efi partition at a 1M offset on the image with its content
coming from the esp_aarch64.img file.

MFC after: 3 days
Approved by: re (gjb)
(cherry picked from commit 8f3c71c85e5f6a4d2bddbfead225d33b96dbd7d7)
(cherry picked from commit 6f6c6480047ba1ebbc398c1052446e35f8a4ecab)

3 years agomkimg: We always want the last block of the last inserted partition
Emmanuel Vadot [Thu, 25 Feb 2021 15:34:28 +0000 (16:34 +0100)]
mkimg: We always want the last block of the last inserted partition

Even with an absolute offset we want to know the last block the partition
otherwise we endup with an image the size of the metadata.
This allow to create image with the ESP placed at a specific position which
is useful on arm/arm64 where u-boot have always a hard time to read the ESP
if it's not aligned on 512k.
mkimg -v -o sdcard -s gpt -p efi::54M:1M -p freebsd-ufs::1G
now works.

MFC after: 3 days
Approved by: re (gjb)
(cherry picked from commit 3b6268bb9e4aea939c4ce7f37353174aa90e6751)
(cherry picked from commit 9c5f4f8e4ee8261a669ab99257bffd439bad6635)

3 years agopwm_backlight: Add MODULE_DEPEND on backlight
Brett Mastbergen [Mon, 22 Feb 2021 10:28:28 +0000 (10:28 +0000)]
pwm_backlight: Add MODULE_DEPEND on backlight

Make the pwm_backlight module depend on backlight, so it
has access to the backlight interface symbols.  Otherwise you'll
get an error like:

link_elf: symbol backlight_get_info_desc undefined

Approved by: re (gjb)
Signed-off-by: Brett Mastbergen <brett.mastbergen@gmail.com>
MFC after: 3 days
PR:  253765
(cherry picked from commit 43d4dfac96f7f8285a27989f315c075d28aadb12)
(cherry picked from commit 135fa1610fa177bb8c77aab951cfb4395edc249f)

3 years agoefibootmgr: Check for efi supported after parsing args
Warner Losh [Thu, 11 Feb 2021 23:06:30 +0000 (16:06 -0700)]
efibootmgr: Check for efi supported after parsing args

Move the check for efi variables being supported to after parsing the args. This
allows '-h' to produce both as a normal user as well as on all systems.

Approved by: re@ (gjb)

(cherry picked from commit 7fe2f504f8a0e4237872f8528e911c5f7b7ed59d)
(cherry picked from commit b8b867a10f56b4a78b680fb5d2a97c83e745a0ce)

3 years agouefi: Add riscv to historical details
Jessica Clarke [Mon, 22 Feb 2021 22:27:00 +0000 (22:27 +0000)]
uefi: Add riscv to historical details

Approved by: re@ (gjb)
(cherry picked from commit 963cf6cb0fd7e8708c455ecf567fbc34fe2a7156)
(cherry picked from commit 44f483e0fa52c42c8f97cf1600c1f7272a283707)

3 years agoRestore missing word
Warner Losh [Mon, 22 Feb 2021 21:39:04 +0000 (14:39 -0700)]
Restore missing word

"in" got dropped when I shuffled things around.

Noticed by: rpokala@
MFC After: 3 days
Approved by: re@ (gjb)
(cherry picked from commit f11e9f325aee3459fee94f3a660a8e6c1a25c2ac)
(cherry picked from commit 1df1b4190b41ee3237486e9daa0a751cbc56312d)

3 years agouefi: add historical details
Warner Losh [Mon, 22 Feb 2021 21:20:00 +0000 (14:20 -0700)]
uefi: add historical details

Add details about when armv6 and armv7 support was added.
Approved by: re@ (gjb)
(cherry picked from commit 8c09ecb2e25155b4f1490a177826608d52b1bd1b)
(cherry picked from commit f88db54fd87471802b44520715d8e373ddf86f60)

3 years agoRemove incorrect statement about EFI environment variables being unsupported.
Warner Losh [Mon, 22 Feb 2021 20:19:21 +0000 (13:19 -0700)]
Remove incorrect statement about EFI environment variables being unsupported.

Our uefi support has included environment variable support for several years
now. Remove the bogus blanket statement saying we don't support them.

MFC After: 3 days
Approved by: re@ (gjb)
(cherry picked from commit ab77cc9e7bf6d0c2d862dfd514539b81ae248dfd)
(cherry picked from commit 78050d4966c5a9c8e953cab2a286450238d51e4f)

3 years agouart: only use MSI on devices that advertise 1 MSI vector
Warner Losh [Wed, 17 Feb 2021 22:08:19 +0000 (15:08 -0700)]
uart: only use MSI on devices that advertise 1 MSI vector

This updates r311987/fb1d9b7f4113d which allowed any number of vectors to be
used. Since we're just attaching one instance, the meaning of more than one
vector is not clear and seems to cause problems. Fall back to old methods for
these cards.

PR: 235016
Submitted by: David Cross
Approved by: re@ (gjb)
(cherry picked from commit 955b6109bb36036e9357006be42dfa89cd7cb0f2)
(cherry picked from commit ef1f2056084202c554d5482af9586a8995e604d5)

3 years agoboot: remove gptboot.efifat, it never should have been
Warner Losh [Fri, 19 Feb 2021 22:34:25 +0000 (15:34 -0700)]
boot: remove gptboot.efifat, it never should have been

conical hat reduction: Make sure we also remove gotboot.efifat. It was created,
briefly, and shouldn't have existed in the first place. Kill it at the same
place we kill boot1.efifat.

Pointy Hat to: imp@
Approved by: re@ (gjb)
(cherry picked from commit 8cd1b2b1a7ab55e96aaf40a401d8792f2697b274)
(cherry picked from commit dd9b24be14d4311ca6056f41a2d81801d2c0fa03)

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)
(cherry picked from commit 00065c7630c25850298dd3ba6919c2d3628e8ad9)
(cherry picked from commit d2fb8eb1472ccc1b2175238f7668816544bf15f7)

3 years agohid: bump HID_ITEM_MAXUSAGES to 8
Warner Losh [Mon, 8 Feb 2021 19:29:20 +0000 (12:29 -0700)]
hid: bump HID_ITEM_MAXUSAGES to 8

My YOGA requires a minimum of 7 to parse w/o an error. Since the memory savings
are trivial and the yoga a popular system, bump the default up to 8. There's no
API/ABI issues in doing this. This hid_item struct isn't exported to userland
and the one libusbhid has is different and only shares a name...

MFC After: 3 days
Reviewed by: wulf@
Differential Revision: https://reviews.freebsd.org/D28543
Approved by: re@ (gjb)
(cherry picked from commit db2f512381ac3c0c227f5c0354690bb929dcac17)
(cherry picked from commit 0dc5c9467b5bbcf26a8232553a1c213bb95ce635)

3 years agoacpi: limit the AMDI0020/AMDI0010 workaround to an option
Warner Losh [Mon, 8 Feb 2021 21:43:25 +0000 (14:43 -0700)]
acpi: limit the AMDI0020/AMDI0010 workaround to an option

It appears that production versions of EPYC firmware get the _STA method right
for these nodes. In fact, this workaround breaks on production hardware by
including too many uart nodes. This work around was for pre-release hardware
that wound up not having a large deployment. Move this work around to a kernel
option since the machines that needed it have been powered off and are difficult
to resurrect. Should there be a more significant deployment than is understood,
we can restrict it based on smbios strings.

Discussed with: mmacy@, seanc@, jhb@
MFC After: 3 days
Approved by: re@ (gjb)
(cherry picked from commit 35af933173d516101f4c44af328fbe2d6e587869)
(cherry picked from commit a60c5de933e1516f65ead98b0ee141224ad607f4)

3 years agopf: Fix incorrect fragment handling
Kristof Provost [Thu, 25 Feb 2021 07:07:36 +0000 (08:07 +0100)]
pf: Fix incorrect fragment handling

A sequence of overlapping IPv4 fragments could crash the kernel in
pf due to an assertion.

Approved by:    re (gjb)
Reported by: Alexander Bluhm
Obtained from: OpenBSD
MFC after: 3 days
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 5f1b1f184b7f12330cf4a027e3db7c6700c67640)
(cherry picked from commit 86ebf4d3e12c3eae94d3e9a8dcf5bd5741889b58)

3 years agopmap: Fix largemap restart checks in the kernel_maps sysctl handler
Mark Johnston [Thu, 25 Feb 2021 23:49:47 +0000 (18:49 -0500)]
pmap: Fix largemap restart checks in the kernel_maps sysctl handler

The purpose of these checks is to ensure that the address of the
next-level page table page is valid, since nothing is synchronizing with
a concurrent update of the large map and large map PTPs are freed to the
system.  However, if PG_PS is set, there is no next level.

Approved by: re (gjb)
Reported by: rpokala
Reviewed by: kib
Tested by: rpokala
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28922

(cherry picked from commit aac25e222525780db8939d07a594d3e090c0a148)
(cherry picked from commit 5966aae9c7c25707c785ec056cb8462a037a480e)

3 years agoiflib: Avoid double counting in rxeof
Mark Johnston [Wed, 24 Feb 2021 15:08:53 +0000 (10:08 -0500)]
iflib: Avoid double counting in rxeof

iflib_rxeof() was counting everything twice.  This was introduced when
pfil hooks were added to the iflib receive path.  We want to count rx
packets/bytes before the pfil hooks are executed, so remove the counter
adjustments that are executed after.

Approved by: re (gjb)
PR: 253583
Reviewed by: gallatin, erj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28900

(cherry picked from commit b6999635b195e8c0dd5c08ac9ff268c92107cc66)
(cherry picked from commit 76294b65df64e87f29a7d7df23c5360dd9ada5aa)

3 years agoOpenSSL: Regen manual page for the previous commit
Jung-uk Kim [Wed, 17 Feb 2021 23:19:13 +0000 (18:19 -0500)]
OpenSSL: Regen manual page for the previous commit

This is regen for 9b2f020c14af71a2606012143432dd717c7cf90e.

Approved by: re (gjb)

(cherry picked from commit 351d06eeb509a420f3470c96b4a265467c87e2c2)
(cherry picked from commit cdba1277dd26c8f7e54a40d86d44748f2d1a8c29)

3 years agoHandle partial data re-sending on ktls/sendfile on FreeBSD
Oleksandr Tymoshenko [Wed, 17 Feb 2021 22:49:30 +0000 (14:49 -0800)]
Handle partial data re-sending on ktls/sendfile on FreeBSD

Add a handler for EBUSY sendfile error in addition to
EAGAIN. With EBUSY returned the data still can be partially
sent and user code has to be notified about it, otherwise it
may try to send data multiple times.

PR: 251969
Approved by: re (gjb)
Obtained from: OpenSSL (dfcfd17f2818cf520ce6381aed9ec3d2fc12170d)
Sponsored by: Netflix (merging to FreeBSD)

(cherry picked from commit 9b2f020c14af71a2606012143432dd717c7cf90e)
(cherry picked from commit 63241a0764c9414e1bcce3bcb05bfbdba8f1f487)

3 years agoupdate to BETA4
Glen Barber [Fri, 26 Feb 2021 02:18:11 +0000 (21:18 -0500)]
update to BETA4

Approved by: re (implicit)
Sponsored by: Rubicon Communications, LLC ("Netgate")

3 years agoReimplement FreeBSD/arm64 dtrace_gethrtime() to use the system timer.
Robert Watson [Tue, 16 Feb 2021 15:19:05 +0000 (15:19 +0000)]
Reimplement FreeBSD/arm64 dtrace_gethrtime() to use the system timer.
dtrace_gethrtime() is the high-resolution nanosecond timestemp used
for the DTrace 'timestamp' built-in variable.  The new implementation
uses the EL0 cycle counter and frequency registers in ARMv8-A.  This
replaces a previous implementation that relied on an
instrumentation-safe implementation of getnanotime(), which provided
only timer resolution.

Approved by: re (gjb)
Reviewed by: andrew, bsdimp (older version)
Useful comments appreciated: jrtc27, emaste
Differential Revision: https://reviews.freebsd.org/D28723

3 years agoFix crash with rtadv-originated multipath IPv6 routes.
Alexander V. Chernikov [Wed, 24 Feb 2021 16:42:48 +0000 (16:42 +0000)]
Fix crash with rtadv-originated multipath IPv6 routes.

PR: 253800
Reported by: Frederic Denis <freebsdml at hecian.net>
Approved by: re(gjb)

(cherry picked from commit 7dfdd039a3584885648d33888359032479038dc1)

3 years agoFix nd6 rib_action() handling.
Alexander V. Chernikov [Tue, 23 Feb 2021 22:31:07 +0000 (22:31 +0000)]
Fix nd6 rib_action() handling.

rib_action() guarantees valid rc filling IFF it returns without error.
Check rib_action() return code instead of checking rc fields.

PR: 253800
Reported by: Frederic Denis <freebsdml@hecian.net>
Approved by: re(gjb)

(cherry picked from commit ea10694336b9a07d58d22187052291976f4906b2)

3 years agoarm64: extend struct db_reg to include watchpoint registers
Mitchell Horne [Thu, 28 Jan 2021 17:49:47 +0000 (13:49 -0400)]
arm64: extend struct db_reg to include watchpoint registers

The motivation is to provide access to these registers from userspace
via ptrace(2) requests PT_GETDBREGS and PT_SETDBREGS.

This change breaks the ABI of these particular requests, but is
justified by the fact that the intended consumers (debuggers) have not
been taught to use them yet. Making this change now enables active
upstream work on lldb to begin using this interface, and take advantage
of the hardware debugging registers available on the platform.

PR: 252860
Reported by: Michał Górny (mgorny@gentoo.org)
Reviewed by: andrew, markj (earlier version)
Tested by: Michał Górny (mgorny@gentoo.org)
Sponsored by: The FreeBSD Foundation
Approved by: re (gjb)

(cherry picked from commit f2583be110ca3a5b32f0993f1464a5c69151c62f)
(cherry picked from commit 4786c8582c569a7245dadbdbb4638d1667c10d62)

3 years agoarm64: handle watchpoint exceptions from EL0
Mitchell Horne [Fri, 5 Feb 2021 21:46:48 +0000 (17:46 -0400)]
arm64: handle watchpoint exceptions from EL0

This is a prerequisite to allowing the use of hardware watchpoints for
userspace debuggers.

This is also a slight departure from the x86 behaviour, since `si_addr`
returns the data address that triggered the watchpoint, not the
address of the instruction that was executed. Otherwise, there is no
straightforward way for the application to determine which watchpoint
was triggered. Make a note of this in the siginfo(3) man page.

Reviewed by: jhb, markj (earlier version)
Tested by: Michał Górny (mgorny@gentoo.org)
Sponsored by: The FreeBSD Foundation
Approved by: re (gjb)

(cherry picked from commit bd012c71592323d957b409bb5e0cf7940729650e)
(cherry picked from commit 9372df63ad5b814440732d171c8f04f0e1c26b87)

3 years agoarm64: validate breakpoint registers
Mitchell Horne [Tue, 9 Feb 2021 18:29:38 +0000 (14:29 -0400)]
arm64: validate breakpoint registers

In particular, we want to disallow setting breakpoints on kernel
addresses from userspace. The control register fields are validated or
ignored as appropriate.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Approved by: re (gjb)

(cherry picked from commit de2b9422807586d376ec7ffa7b660cd492464bdf)
(cherry picked from commit 8837e9c54072679b69ae0c0345e7ef7d241255aa)

3 years agoFix bug 253158 - Panic: snapacct_ufs2: bad block - mksnap_ffs(8) crash
Kirk McKusick [Fri, 12 Feb 2021 05:31:16 +0000 (21:31 -0800)]
Fix bug 253158 - Panic: snapacct_ufs2: bad block - mksnap_ffs(8) crash

PR: 253158
Approved by: re (delphij, gjb)

(cherry picked from commit 8563de2f2799b2cb6f2f06e3c9dddd48dca2a986)
(cherry picked from commit c31480a1f66537e59b02e935a547bcfc76715278)

3 years agoCall softdep_prealloc() before taking ffs_lock_ea(), if unlock is committing
Konstantin Belousov [Sun, 21 Feb 2021 10:11:54 +0000 (12:11 +0200)]
Call softdep_prealloc() before taking ffs_lock_ea(), if unlock is committing

Approved by: re (delphij, gjb)

(cherry picked from commit 6f30ac9995ff662a2fee5eda4cd87dd0f0e337ba)

3 years agoffs_close_ea: do not relock vnode under lock_ea
Konstantin Belousov [Sun, 21 Feb 2021 10:10:06 +0000 (12:10 +0200)]
ffs_close_ea: do not relock vnode under lock_ea

Approved by: re (delphij, gjb)

(cherry picked from commit 5e198e7646a27412c0541719f7bf1bbc0bd89223)

3 years agoffs_vnops.c: style
Konstantin Belousov [Sat, 20 Feb 2021 17:01:40 +0000 (19:01 +0200)]
ffs_vnops.c: style

Approved by: re (delphij, gjb)

(cherry picked from commit c6d68ca842a3f5b6814cdd5c87e406bad579b792)

3 years agoffs: do not call softdep_prealloc() from UFS_BALLOC()
Konstantin Belousov [Thu, 18 Feb 2021 14:51:50 +0000 (16:51 +0200)]
ffs: do not call softdep_prealloc() from UFS_BALLOC()

Approved by: re (delphij, gjb)

(cherry picked from commit 49831462794690155ce8dbe02679e6d9390f3d7d)

3 years agoffs_reallocblks: change the guard for softdep_prealloc() call to DOINGSUJ()
Konstantin Belousov [Fri, 19 Feb 2021 12:37:12 +0000 (14:37 +0200)]
ffs_reallocblks: change the guard for softdep_prealloc() call to DOINGSUJ()

Approved by: re (delphij, gjb)

(cherry picked from commit cc9958bf22f1426faf4be8bf492ce69587a9008f)

3 years agofifo: minor comment and assert improvements.
Konstantin Belousov [Mon, 1 Feb 2021 10:43:16 +0000 (12:43 +0200)]
fifo: minor comment and assert improvements.

Approved by: re (delphij, gjb)

(cherry picked from commit adf28ab45670329459aed8afeec2dbe91c9b3713)