]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agoffs_unlock: assert that IN_ENDOFF is not leaked past locked scope
Konstantin Belousov [Sun, 31 Jan 2021 19:01:17 +0000 (21:01 +0200)]
ffs_unlock: assert that IN_ENDOFF is not leaked past locked scope

(cherry picked from commit 26af9f72f7cb162abeced8b7e444800b601e5017)

3 years agoffs softdep: Force processing of VI_OWEINACT vnodes when there is inode shortage
Konstantin Belousov [Sun, 31 Jan 2021 18:39:49 +0000 (20:39 +0200)]
ffs softdep: Force processing of VI_OWEINACT vnodes when there is inode shortage

(cherry picked from commit 28703d27130c9cb7e7830ff53155c379a502c248)

3 years agosoftdep_request_cleanup: wait for softdep_request_clean_flush() to pass
Konstantin Belousov [Wed, 3 Feb 2021 23:58:05 +0000 (01:58 +0200)]
softdep_request_cleanup: wait for softdep_request_clean_flush() to pass

(cherry picked from commit 2011b44fa3f2b2bd5a24be01094420cce9144b2d)

3 years agoufs_inactive(): stop hiding ERELOOKUP from ffs_truncate(), return it.
Konstantin Belousov [Sat, 30 Jan 2021 19:18:22 +0000 (21:18 +0200)]
ufs_inactive(): stop hiding ERELOOKUP from ffs_truncate(), return it.

(cherry picked from commit 013168db8cea926c3dde1247d400d6bedf9a889d)

3 years agoStop ignoring ERELOOKUP from VOP_INACTIVE()
Konstantin Belousov [Sat, 30 Jan 2021 19:17:29 +0000 (21:17 +0200)]
Stop ignoring ERELOOKUP from VOP_INACTIVE()

(cherry picked from commit b59a8e63d6bf9092419b7a421c655d0ae2099662)

3 years agoufs vnops: brace softdep_prelink() with DOINGSUJ instead of DOINGSOFTDEP
Konstantin Belousov [Sat, 23 Jan 2021 23:12:39 +0000 (01:12 +0200)]
ufs vnops: brace softdep_prelink() with DOINGSUJ instead of DOINGSOFTDEP

(cherry picked from commit 6aed2435c8bf1fa55891c7d30186c9ad91064da8)

3 years agoffs softdep: remove will_direnter argument of softdep_prelink()
Konstantin Belousov [Sat, 23 Jan 2021 22:40:19 +0000 (00:40 +0200)]
ffs softdep: remove will_direnter argument of softdep_prelink()

(cherry picked from commit ede40b0675155b5cc862652f2fee11c738a46bcd)

3 years agoufs_direnter: directory truncation does not need special case for rename
Konstantin Belousov [Fri, 29 Jan 2021 12:31:52 +0000 (14:31 +0200)]
ufs_direnter: directory truncation does not need special case for rename

(cherry picked from commit 06f2918ab8a2621c6e6bc5729ed9ab982741aaf2)

3 years agoufs_rename: use VOP_VPUT_PAIR and rely on directory sync/truncation there
Konstantin Belousov [Thu, 28 Jan 2021 13:34:56 +0000 (15:34 +0200)]
ufs_rename: use VOP_VPUT_PAIR and rely on directory sync/truncation there

(cherry picked from commit 038fe6e089f03ca864c1dd5ac0c76404a13bbe79)

3 years agoufs_direnter: move directory truncation to ffs_vput_pair().
Konstantin Belousov [Wed, 27 Jan 2021 20:34:14 +0000 (22:34 +0200)]
ufs_direnter: move directory truncation to ffs_vput_pair().

(cherry picked from commit 74a3652f832f4ed0f1ad9f7eb60d70013b478e1a)

3 years agoffs_vput_pair(): try harder to recover from the vnode reclaim
Konstantin Belousov [Wed, 27 Jan 2021 18:10:51 +0000 (20:10 +0200)]
ffs_vput_pair(): try harder to recover from the vnode reclaim

(cherry picked from commit 30bfb2fa0fad8e5bbcce369df46dcaa2e08324f3)

3 years agoFFS: implement special VOP_VPUT_PAIR().
Konstantin Belousov [Wed, 27 Jan 2021 18:09:53 +0000 (20:09 +0200)]
FFS: implement special VOP_VPUT_PAIR().

(cherry picked from commit f2c9d038bdee547be07c8b0404547617b71f2232)

3 years agonfsserver: use VOP_VPUT_PAIR().
Konstantin Belousov [Sun, 24 Jan 2021 13:02:27 +0000 (15:02 +0200)]
nfsserver: use VOP_VPUT_PAIR().

(cherry picked from commit 4a21bcb24174438e0944d6e4d6633290a067b7a8)

3 years agoffs_snapshot: use VOP_VPUT_PAIR after VOP_CREATE.
Konstantin Belousov [Sun, 24 Jan 2021 13:56:05 +0000 (15:56 +0200)]
ffs_snapshot: use VOP_VPUT_PAIR after VOP_CREATE.

(cherry picked from commit be44e986377780f533f961fe7c009b93379b4710)

3 years agoUse VOP_VPUT_PAIR() for eligible VFS syscalls.
Konstantin Belousov [Thu, 28 Jan 2021 22:31:30 +0000 (00:31 +0200)]
Use VOP_VPUT_PAIR() for eligible VFS syscalls.

(cherry picked from commit 3b2aa36024abcb2d8fdbf3a6ecc7438b073b04e4)

3 years agonullfs: provide special bypass for VOP_VPUT_PAIR
Konstantin Belousov [Sun, 24 Jan 2021 13:22:48 +0000 (15:22 +0200)]
nullfs: provide special bypass for VOP_VPUT_PAIR

(cherry picked from commit e4aaf35ab54958f74409790fa2b7df8c2d230cee)

3 years agoAdd VOP_VPUT_PAIR() with trivial default implementation.
Konstantin Belousov [Thu, 28 Jan 2021 22:30:53 +0000 (00:30 +0200)]
Add VOP_VPUT_PAIR() with trivial default implementation.

(cherry picked from commit 49c117c193768b10f5fb1c5e4d6b88300cfbcdd6)

3 years agovn_open(): If the vnode is reclaimed during open(2), do not return error.
Konstantin Belousov [Wed, 3 Feb 2021 11:02:18 +0000 (13:02 +0200)]
vn_open(): If the vnode is reclaimed during open(2), do not return error.

(cherry picked from commit ee965dfa64929227ced8adb68900c35f877480e7)

3 years agoufs_direnter/SU: unconditionally UFS_UPDATE inode when extending directory
Konstantin Belousov [Sat, 23 Jan 2021 21:52:10 +0000 (23:52 +0200)]
ufs_direnter/SU: unconditionally UFS_UPDATE inode when extending directory

(cherry picked from commit 08c2dc2841214187a162d5e4475aa1b94d03fd77)

3 years agoffs_syncvnode: only clear IN_NEEDSYNC after successfull sync
Konstantin Belousov [Sat, 23 Jan 2021 21:50:55 +0000 (23:50 +0200)]
ffs_syncvnode: only clear IN_NEEDSYNC after successfull sync

(cherry picked from commit 1de1e2bfbf3c089418bbe67c096d60315c8ca5dd)

3 years agoMerge ufs_fhtovp() into ffs_inotovp().
Konstantin Belousov [Thu, 28 Jan 2021 12:20:48 +0000 (14:20 +0200)]
Merge ufs_fhtovp() into ffs_inotovp().

(cherry picked from commit 89fd61d955ada4fdb20030253206201bc279cdf0)

3 years agoffs_inotovp(): interface to convert (ino, gen) into alive vnode
Konstantin Belousov [Tue, 26 Jan 2021 11:52:59 +0000 (13:52 +0200)]
ffs_inotovp(): interface to convert (ino, gen) into alive vnode

(cherry picked from commit 5952c86c78b177b5e904bf139e6b56519897c7e0)

3 years agoffs: Add FFSV_REPLACE_DOOMED flag to ffs_vgetf()
Konstantin Belousov [Tue, 26 Jan 2021 11:35:21 +0000 (13:35 +0200)]
ffs: Add FFSV_REPLACE_DOOMED flag to ffs_vgetf()

(cherry picked from commit f16c26b1c009fd0d87d07d3b1cf0d5078ad7f511)

3 years agoffs: call ufsdirhash_dirtrunc() right after setting directory size
Konstantin Belousov [Thu, 28 Jan 2021 18:33:58 +0000 (20:33 +0200)]
ffs: call ufsdirhash_dirtrunc() right after setting directory size

(cherry picked from commit e94f2f1be32294cb6d519b6631f7522466fbbb3b)

3 years agobuf SU hooks: track buf_start() calls with B_IOSTARTED flag
Konstantin Belousov [Sat, 30 Jan 2021 02:10:34 +0000 (04:10 +0200)]
buf SU hooks: track buf_start() calls with B_IOSTARTED flag

(cherry picked from commit bf0db19339e770a82236b74f523be4b572bde15d)

3 years ago504ebd612ec: kern: sonewconn: set so_options before pru_attach()
Kyle Evans [Wed, 20 Jan 2021 17:53:05 +0000 (11:53 -0600)]
504ebd612ec: kern: sonewconn: set so_options before pru_attach()

Protocol attachment has historically been able to observe and modify
so->so_options as needed, and it still can for newly created sockets.
779f106aa169 moved this to after pru_attach() when we re-acquire the
lock on the listening socket.

Restore the historical behavior so that pru_attach implementations can
consistently use it. Note that some pru_attach() do currently rely on
this, though that may change in the future. D28265 contains a change to
remove the use in TCP and IB/SDP bits, as resetting the requested linger
time on incoming connections seems questionable at best.

This does move the assignment out from under the head's listen lock, but
glebius notes that head won't be going away and applications cannot
assume any specific ordering with a race between a connection coming in
and the application changing socket options anyways.

4c0bef07be0: kern: net: remove TCP_LINGERTIME

TCP_LINGERTIME can be traced back to BSD 4.4 Lite and perhaps beyond, in
exactly the same form that it appears here modulo slightly different
context.  It used to be the case that there was a single pr_usrreq
method with requests dispatched to it; these exact two lines appeared in
tcp_usrreq's PRU_ATTACH handling.

The only purpose of this that I can find is to cause surprising behavior
on accepted connections. Newly-created sockets will never hit these
paths as one cannot set SO_LINGER prior to socket(2). If SO_LINGER is
set on a listening socket and inherited, one would expect the timeout to
be inherited rather than changed arbitrarily like this -- noting that
SO_LINGER is nonsense on a listening socket beyond inheritance, since
they cannot be 'connected' by definition.

Neither Illumos nor Linux reset the timer like this based on testing and
inspection of Illumos, and testing of Linux.

(cherry picked from commit 504ebd612ec61165bb949cfce3a348b0d6f37008)
(cherry picked from commit 4c0bef07be071a1633ebc86a653f9bd59d40796e)

3 years agopam_login_access: Fix negative entry matching logic
Mark Johnston [Tue, 23 Feb 2021 22:01:29 +0000 (17:01 -0500)]
pam_login_access: Fix negative entry matching logic

PR: 252194
Approved by: so
Security: CVE-2020-25580
Security: FreeBSD-SA-21:03.pam_login_access

(cherry picked from commit 6ab923cbca8759503a08683a5978b9ebf5efd607)

3 years agoFix divide-by-zero panic when ASLR is enabled and superpages disabled
Jason A. Harmening [Mon, 15 Feb 2021 02:47:22 +0000 (18:47 -0800)]
Fix divide-by-zero panic when ASLR is enabled and superpages disabled

When locating the anonymous memory region for a vm_map with ASLR
enabled, we try to keep the slid base address aligned on a superpage
boundary to minimize pagetable fragmentation and maximize the potential
usage of superpage mappings.  We can't (portably) do this if superpages
have been disabled by loader tunable and pagesizes[1] is 0, and it
would be less beneficial in that case anyway.

PR: 253511

(cherry picked from commit 41032835dc2d489ec7841d7529f74f6389329cd3)

3 years agohkbd: Fix handling of keyboard ErrorRollOver reports
Vladimir Kondratyev [Sat, 13 Feb 2021 18:18:07 +0000 (21:18 +0300)]
hkbd: Fix handling of keyboard ErrorRollOver reports

Ignore fantom keyboard state reports entirelly rather than ignore
RollOver states for each key separatelly.  Latter results in spurious
release/push pairs of events on each fantom keyboard state report.

Reported by: Jan Martin Mikkelsen <janm_AT_transactionware_DOT_com>
Submitted by: Jan Martin Mikkelsen (initial version)
PR: 253249
MFC after: 1 week

(cherry picked from commit 812c59ed614df94380e0b1f9ff4a3d15b78ce1bf)

3 years agoukbd: Fix handling of keyboard ErrorRollOver reports
Vladimir Kondratyev [Sat, 13 Feb 2021 18:12:56 +0000 (21:12 +0300)]
ukbd: Fix handling of keyboard ErrorRollOver reports

Ignore fantom keyboard state reports entirelly rather than ignore
RollOver states for each key separatelly.  Latter results in spurious
release/push pairs of events on each fantom keyboard state report.

Reported by: Jan Martin Mikkelsen <janm_AT_transactionware_DOT_com>
Submitted by: Jan Martin Mikkelsen (initial version)
PR: 253249
MFC after: 1 week

(cherry picked from commit 032d3153877ef1767c121bbdf8e00f4f93b30a5d)

3 years agohidraw: Make HIDIOCGRDESCSIZE ioctl return report descriptor size
Vladimir Kondratyev [Sat, 13 Feb 2021 18:19:02 +0000 (21:19 +0300)]
hidraw: Make HIDIOCGRDESCSIZE ioctl return report descriptor size

defined by hardware rather than cached one to match HIDIOCGRDESC ioctl.
This fixes errors reported by hid-tools being run against /dev/hidraw#
device node belonging to driver which overloads report descriptor.

MFC after: 1 week

(cherry picked from commit f988d7fa050e4886cdeb9483a039e75d58c31883)

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>

(cherry picked from commit 9c4a8d24f0ffd5243fa5c6fe27178f669f16d1f5)

3 years agoofwfb: fix incorrect colors on powerpc* and add new tunable parameters
Alfredo Dal'Ava Junior [Fri, 19 Feb 2021 06:22:25 +0000 (03:22 -0300)]
ofwfb: fix incorrect colors on powerpc* and add new tunable parameters

- Implements little-endian support (powerpc64le)
- Adds 'hw.ofwfb.physaddr' kernel parameter so user can manually
  provide correct address if it's not detected correctly
- Adds 'hw.ofwfb.argb32_pixel' so user can set it manually if
  colors are inverted due to incorrect pixel format (default = 1)
- Automatically selects RGBA32 pixel format if NVidia graphic adapter
  is detected (sets hw.ofwfb.argb32_pixel=0)

Machines equipped with NVidia graphic adapters tend to use RGBA32
pixel format. By default ARGB32 pixel format is used, proved to work
on machines equipped with ATI graphic adapter and the onboard adapter
used on Talos II and Blackbird machines from Raptor Computing Systems.

Original patch developed by bdragon

Reviewed by: bdragon, luporl
MFC after: 3 days
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D28604

(cherry picked from commit 50b7c1f530f174be720b83f7e1d13e0fd42c5974)

3 years agocgem: improve usage of busdma(9) KPI
Mitchell Horne [Wed, 20 Jan 2021 15:07:53 +0000 (11:07 -0400)]
cgem: improve usage of busdma(9) KPI

BUS_DMA_NOCACHE should only be used when one needs to guarantee the
created mapping has uncached memory attributes, usually as a result
of buggy hardware. Normal use cases should pass BUS_DMA_COHERENT, to
create an appropriate mapping based on the flags passed to
bus_dma_tag_create().

This should have no functional change, since the DMA tags in this driver
are created without the BUS_DMA_COHERENT flag.

Reported by: mmel
Reviewed by: mmel, Thomas Skibo <thomas-bsd@skibo.net>

(cherry picked from commit 04d2d2d7fd22bba638ccb5a0b2e0805087a70cd3)

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

(cherry picked from commit 9976b42b697ce203b1d257b2a6fe64c8a2961645)

3 years agopf tests: Test unicast reverse path forwarding check
Kristof Provost [Mon, 15 Feb 2021 21:16:36 +0000 (22:16 +0100)]
pf tests: Test unicast reverse path forwarding check

Ensure that pf's urpf-failed keyword works as expected.

PR: 253479
MFC after: 1 week
Reviewed by: melifaro@
Differential Revision: https://reviews.freebsd.org/D28694

(cherry picked from commit 6b52139eb8e8eda0ea263b24735556194f918642)

3 years agopf tests: Test that dup-to doesn't produce extra duplicate packets
Kristof Provost [Thu, 28 Jan 2021 10:02:20 +0000 (11:02 +0100)]
pf tests: Test that dup-to doesn't produce extra duplicate packets

(cherry picked from commit cd579b6fba46b9f5005358d1e82def7b26703224)

3 years agopf: duplicate frames only once when using dup-to pf rule
Yannis Planus [Thu, 28 Jan 2021 13:59:07 +0000 (14:59 +0100)]
pf: duplicate frames only once when using dup-to pf rule

When using DUP-TO rule, frames are duplicated 3 times on both output
interfaces and duplication interface. Add a flag to not duplicate a
duplicated frame.

Inspired by a patch from MiƂosz Kaniewski milosz.kaniewski at gmail.com
https://lists.freebsd.org/pipermail/freebsd-pf/2015-November/007886.html

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

(cherry picked from commit 0c458752ceee14818034df7bfcdfb04129dceeda)

3 years agopgcache read: protect against reads past end of the vm object size
Konstantin Belousov [Mon, 15 Feb 2021 03:34:06 +0000 (05:34 +0200)]
pgcache read: protect against reads past end of the vm object size

PR: 253158

(cherry picked from commit c61fae1475f1864dc4bba667b642f279afd44855)

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)