]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
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)

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

Approved by: re (delphij, gjb)

(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

Approved by: re (delphij, gjb)

(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

Approved by: re (delphij, gjb)

(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.

Approved by: re (delphij, gjb)

(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()

Approved by: re (delphij, gjb)

(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

Approved by: re (delphij, gjb)

(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()

Approved by: re (delphij, gjb)

(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

Approved by: re (delphij, gjb)

(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

Approved by: re (delphij, gjb)

(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().

Approved by: re (delphij, gjb)

(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

Approved by: re (delphij, gjb)

(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().

Approved by: re (delphij, gjb)

(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().

Approved by: re (delphij, gjb)

(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.

Approved by: re (delphij, gjb)

(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.

Approved by: re (delphij, gjb)

(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

Approved by: re (delphij, gjb)

(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.

Approved by: re (delphij, gjb)

(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.

Approved by: re (delphij, gjb)

(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

Approved by: re (delphij, gjb)

(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

Approved by: re (delphij, gjb)

(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().

Approved by: re (delphij, gjb)

(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

Approved by: re (delphij, gjb)

(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()

Approved by: re (delphij, gjb)

(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

Approved by: re (delphij, gjb)

(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

Approved by: re (delphij, gjb)

(cherry picked from commit bf0db19339e770a82236b74f523be4b572bde15d)

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.
Approved by: re (gjb)

(cherry picked from commit 922cf8ac43adc9983f9a9e05cfd838306c1ef483)

3 years agocxgb(4): Rework my commit 9dc7c250.
Alexander Motin [Mon, 22 Feb 2021 22:21:05 +0000 (17:21 -0500)]
cxgb(4): Rework my commit 9dc7c250.

The previous implementation was reported to try to coalesce packets
in situations when it should not, that resulted in assertion later.
This implementation better checks the first packet of the chain for
the coallescing elligibility.

Approved by: re (gjb@)

(cherry picked from commit d510bf133d045d6c83742aeda6949bec150f6cbf)
(cherry picked from commit 1f3cff343b451d9fc9c10f4f8c4b416ed5eae23f)

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
Approved by: re (gjb)

(cherry picked from commit 21269625733f591c998f7d26790179e922ffbde0)

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
Approved by: re (gjb)

(cherry picked from commit 940415f20a784156ec0e247989796385896f32a8)

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
Approved by: re (gjb)

(cherry picked from commit 64649f0285424435634c2dfd39f49536fc2b50dd)

3 years agoloader: autoload_font will hung loader when there is no local console
Toomas Soome [Sun, 21 Feb 2021 10:32:18 +0000 (12:32 +0200)]
loader: autoload_font will hung loader when there is no local console

If we start with console set to comconsole, the local
console (vidconsole, efi) is never initialized and attempt to
use the data can render the loader hung.

(cherry picked from commit 61c50cbc096d28e44cb8b627e524ae58158c423a)

Reported by: Kamigishi Rei
Approved by: re (gjb)

3 years agovm_kern: Avoid sign extension in the KVA_QUANTUM definition
Mark Johnston [Mon, 22 Feb 2021 20:50:09 +0000 (15:50 -0500)]
vm_kern: Avoid sign extension in the KVA_QUANTUM definition

Otherwise, on a powerpc64 NUMA system with hashed page tables, the
first-level superpage reservation size is large enough that the value of
the kernel KVA arena import quantum, KVA_NUMA_IMPORT_QUANTUM, is
negative and gets sign-extended when passed to vmem_set_import().  This
results in a boot-time hang on such platforms.

Approved by: re (gjb)
Reported by: bdragon

(cherry picked from commit 23e875fd97fb9f17b3f5dc2b26082f25e1a86b6f)
(cherry picked from commit 0486986ad81dbbfca291acf5b15f94d67d8a61bd)

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.

(cherry picked from commit 9b388ac30375ad4e0259b264a006753edcb2bd3c)

Reported by: jhb
Approved by: re (gjb)

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.

(cherry picked from commit 6e26189be406a9a3799074b16925e6cd63cc703b)

Reviewed by: tsoome
Approved by: re (gjb)

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)

Approved by: re (gjb)

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)

Approved by: re (gjb)

3 years agoAdd UPDATING entries and bump version
Mark Johnston [Wed, 24 Feb 2021 00:21:19 +0000 (19:21 -0500)]
Add UPDATING entries and bump version

Approved by: re (implicit, so)
Approved by: so

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: re (implicit, so)
Approved by: so
Security: CVE-2020-25580
Security: FreeBSD-SA-21:03.pam_login_access

(cherry picked from commit 6ab923cbca8759503a08683a5978b9ebf5efd607)
(cherry picked from commit 8cf559d6b9b4782bf67eb868ea480f47fc8c64a4)

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.

Approved by: re (implicit, so)
Approved by: so
Security: CVE-2021-26932
Security: FreeBSD-SA-21:06.xen
Security: XSA-361
Sponsored by: Citrix Systems R&D

(cherry picked from commit 808d4aad1022a2a33d222663b0c9badde30b9d45)
(cherry picked from commit ab3e1bd3c22a222520c23c2793cc39e3a23c9b46)

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
Approved by: re (gjb)

(cherry picked from commit c61fae1475f1864dc4bba667b642f279afd44855)

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.

Approved by: re@ (gjb@)
Sponsored by: iXsystems, Inc.
Reviewed by: np, jhb
Differential Revision: https://reviews.freebsd.org/D28716

(cherry picked from commit 294e62bebf36f873fd083d2fe8edd78919dda4e8)
(cherry picked from commit c930816b76713623ccdef09d682e41266c1d724f)

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.

Approved by: re (gjb)
PR: 253440
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 8ba333e02eaa59337a4e1d5534d4e894344c8226)
(cherry picked from commit af80731179386cf019463e392370b6478a714aea)

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
Approved by: re (gjb)

(cherry picked from commit 6b7e592c215fb76ea027f25030ddc9a697184fbe)

3 years agoktls(4): Mention WITH_OPENSSL_KTLS in the ktls(4) manual page
Gordon Bergling [Mon, 8 Feb 2021 20:21:26 +0000 (21:21 +0100)]
ktls(4): Mention WITH_OPENSSL_KTLS in the ktls(4) manual page

Since we ship a ktls(4) enabled OpenSSL version, mention
the src.conf(5) option WITH_OPENSSL_KTLS in the manual page.

Approved by: re (gjb)
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D28435

(cherry picked from commit 6c34d8ce11cb73e718fc23d85b6fbfab07ee15b4)

3 years agoMFS jail: Change both root and working directories in jail_attach(2)
Jamie Gritton [Fri, 19 Feb 2021 22:13:35 +0000 (14:13 -0800)]
MFS 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:    re (gjb), markj, kib

(cherry picked from commit d4380c0cdd0517dc038403dd5c99242ce78bdeb5)
(cherry picked from commit 5dbb407145c8128753fa30b695bc266dc671e433)

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.

Approved by: re (gjb)

(cherry picked from commit b2c4ca8d2872bc4410626f2b1ceafa49de5828ce)
(cherry picked from commit 9ec09b04df17b3601e6f5ae8664c6ab81e1e4783)

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.

Approved by: re (gjb)
Submitted by: Michal Krawczyk <mk@semihalf.com>
Obtained from: Semihalf
Sponsored by: Amazon, Inc

(cherry picked from commit 1c808fcd859f5ce24132a903a4c7c9996e0513b1)
(cherry picked from commit e540e45097e54aaae553ea12468801ceab473d47)

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.

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

(cherry picked from commit 2551d928501fb613dba09b7ffe7e383dba276ca6)
(cherry picked from commit 796faf365c0ea0f50f5138ff8fa62fe48ff3ef71)

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.

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

(cherry picked from commit 1cf282363101f5d99b1dadfb0d3250bbe6f482a5)
(cherry picked from commit 944f4316558055a2bb6481048386e94b523ab48c)

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++.

Approved by: re (gjb)
Reported-by: Dom Dwyer <dom@itsallbroken.com>
Reviewed By: vangyzen
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D28550

(cherry picked from commit 04e34c0202ea50cea67d5779f54bc612c74e6532)

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.

Approved by:    re (kib)
Reported by: delphij@
MFC after: 3 days

(cherry picked from commit 2ed689a674c380e48245933d5326da4dda65f94d)
(cherry picked from commit 9823eb6909fcd82bb9d70e77037542e527e3d6ff)

3 years agoMFS 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)]
MFS 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.

Approved by:    re (gjb)
Reported by:    trasz
Approved by:    kib

(cherry picked from commit cc7b73065302005ebc4a19503188c8d6d5eb923d)
(cherry picked from commit 894360bacd42f021551f76518edd445f6d299f2e)

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.

Approved by: re (gjb)

(cherry picked from commit 0281f88e5dbc8d6f819bf3f22dd11239ff5374ea)

3 years agoupdate to 13.0-BETA3
Glen Barber [Thu, 18 Feb 2021 23:57:03 +0000 (18:57 -0500)]
update to 13.0-BETA3

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

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

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

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

(cherry picked from commit a26f7358583174f2fe0df3e979f7b8b02069278c)

Approved by: re (gjb)