]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
18 months agolinuxkpi: Define `GFP_NOFS` in `linux/gfp.h`
Jean-Sébastien Pédron [Fri, 30 Dec 2022 09:49:08 +0000 (10:49 +0100)]
linuxkpi: Define `GFP_NOFS` in `linux/gfp.h`

Reviewed by: emaste, manu
Approved by: emaste, manu
Differential Revision: https://reviews.freebsd.org/D37910

(cherry picked from commit c0c1c599c0ca7e8a15509503991f8cd97c292bea)

18 months agoAdd ck.h userspace shims for CK_SLIST_
Elliott Mitchell [Thu, 9 Feb 2023 23:27:12 +0000 (16:27 -0700)]
Add ck.h userspace shims for CK_SLIST_

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

(cherry picked from commit cd3193f640e26991d94d87a45ee9b6a953c56fb5)

18 months agotop: fix sorting by pid (-o pid)
Kyle Evans [Mon, 13 Feb 2023 06:39:04 +0000 (00:39 -0600)]
top: fix sorting by pid (-o pid)

The 'pid' order was added, but the equivalent comparator was not back in
8b800d3af2d8c ("Add the PID column to the list of sort keys.").
`ordernames` indices need to match `compares` indices in order for this
to work.

A future commit will restructure all of this to make it less error prone
going forward (see D37083).

Reviewed by: pstef (D37083)

(cherry picked from commit deb63adf945d446ed91a9d84124c71f15ae571d1)

18 months agolibc: popen: slightly simplify cloexec logic
Kyle Evans [Mon, 13 Feb 2023 06:33:52 +0000 (00:33 -0600)]
libc: popen: slightly simplify cloexec logic

No need to check the mode again here; we know that `iop` wraps the
correct fd.

Reviewed by: bapt

(cherry picked from commit f123c6c425d4161b06f237996662496abbd78b94)

18 months agomd5: fix *sum -c with missing files
Kyle Evans [Mon, 13 Feb 2023 06:32:38 +0000 (00:32 -0600)]
md5: fix *sum -c with missing files

If we fail to open one of the files in the file listing, we still need
to advance `rec` along with `argv` so that the checksum we're checking
against lines up with the file we're hashing.

Tests added both for the -c flag, as well as the -b and -t modes of
the *sum programs.

PR: 267722
Reviewed by: emaste (earlier version)

(cherry picked from commit 8d78a0d331ec2c168efe6cb85bbc2da86e9a6124)

18 months agopatch: omit filename if the prompt was ignored
Kyle Evans [Tue, 24 Jan 2023 16:46:01 +0000 (10:46 -0600)]
patch: omit filename if the prompt was ignored

When a file is missing, patch(1) will prompt for a filename to try and
patch it.  If we're doing a dry-run, we'll output that the patch to the
source file was either ignored/failed.  If you ignore the prompt in a
dry-run (i.e. just hit enter), we'll output:

X out of X hunks ignored while patching (null)

Let's improve the aesthetics a bit and just omit the last part if the
prompt was ignored:

X out of X hunks ignored

Unfortunately we can't really test this without expect(1) because both
force and batch mode will use the first best guess, which is wiped out
by the "File to patch:" prompt.  We could record the initially derived
bestguess there and use *that*, but given that this is only possible in
an interactive session I think it's fine to just omit the filename
rather than adding a fair amount of complexity (which could also break
other scenarios I haven't considered yet)..

Reviewed by: des
Sponsored by: Klara, Inc.

(cherry picked from commit 7e688ed493482c5346d969e7667856d8ced8d87a)

18 months agowg: tests: remove an obsolete workaround
Kyle Evans [Mon, 13 Feb 2023 05:59:21 +0000 (23:59 -0600)]
wg: tests: remove an obsolete workaround

PR 254212 was resolved to avoid issues with not having IPv6 addresses
present in the jail, so we can safely drop this workaround now...

Reviewed by: jhb, markj

(cherry picked from commit e63dcbe7a2cb8f6b6932cef48e70f3372f4df737)

18 months agowg: add a test for the home jail socket feature
Kyle Evans [Mon, 13 Feb 2023 05:59:20 +0000 (23:59 -0600)]
wg: add a test for the home jail socket feature

This adds a test for a semantic that we added to mirror a feature of
the Linux implementation w/ netns: if a wg interface is moved into a
jail, we still create the socket in the context of the home vnet.  With
this added, one can actually create vnet jails that only have a wg
tunnel to the outside world providing network connectivity without any
epairs in the setup.

Reviewed by: jhb, markj (both earlier version)

(cherry picked from commit 96f4ab26633a457c52fdb9c45f48dcb052b408a4)

18 months agoamd64 ia32 vdso: always define some __vdso_ symbols
Konstantin Belousov [Sun, 5 Feb 2023 21:41:25 +0000 (23:41 +0200)]
amd64 ia32 vdso: always define some __vdso_ symbols

(cherry picked from commit ee844871206562c6aaaa14ee4576cb20895adb00)

18 months agoamd64: record a dependency of vdso on its linker script
Konstantin Belousov [Sun, 5 Feb 2023 21:40:31 +0000 (23:40 +0200)]
amd64: record a dependency of vdso on its linker script

(cherry picked from commit 5bb807fed4622b17f2b2aa837f5ebd124e08f904)

18 months agosesutil: plug memory leaks
Alan Somers [Wed, 19 Jan 2022 21:57:27 +0000 (14:57 -0700)]
sesutil: plug memory leaks

Sponsored by: Axcient
Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D33955

(cherry picked from commit 09f29b03ddf857a366f338145693b5449e6ca5de)

18 months agoirdma: fix LINT-NOIP/NOINET/NOINET6 builds
Mitchell Horne [Mon, 30 May 2022 20:47:32 +0000 (17:47 -0300)]
irdma: fix LINT-NOIP/NOINET/NOINET6 builds

This module depends on the presence of both INET and INET6 options in
order to compile.

Reviewed by: erj
Fixes: cdcd52d41e24 ("irdma: Add RDMA driver for Intel(R) Ethernet...")
Differential Revision: https://reviews.freebsd.org/D35343

(cherry picked from commit acdfbc6cbe0a8a976d446216be84994c8ee8d5c1)

18 months agoloader: always install help files
Mitchell Horne [Thu, 11 Feb 2021 14:29:00 +0000 (10:29 -0400)]
loader: always install help files

Address two issues with current help file logic:

The existing condition prevents the common help file from being
installed when there are no additional help files defined. This results
in no loader.help on EFI platforms, for example.

Second, due to the fact that we build and install multiple loader types,
each successive install will clobber the previous loader.help. The
result is that we could lose type-specific commands, or possibly list
them in loaders that do not have such commands.

Instead, give each loader type a uniquely named help file. The EFI
loader will look for /boot/loader.help.efi, userboot will look for
/boot/loader.help.userboot, etc. The interpreter variant has no effect
on which help file is loaded.

This leaves the old /boot/loader.help unused.

Some credit for the final approach goes to Mathieu <sigsys@gmail.com>
for their version of the fix in https://reviews.freebsd.org/D22951.

PR: 267134
Reported by: Daniel O'Connor <darius@dons.net.au>
Reviewed by: imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D28591

(cherry picked from commit 8859960436f5727f163a7b3468e08710c5e6d874)

18 months agodtrace: implement riscv dtrace_getustackdepth()
Mitchell Horne [Mon, 6 Feb 2023 18:23:42 +0000 (14:23 -0400)]
dtrace: implement riscv dtrace_getustackdepth()

Pretty trivial following other implementations. The existing
dtrace_getustack_common() does most of the work.

Reviewed by: markj
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38303

(cherry picked from commit c6943b44f7d73176acd2e36e0615e1b2ded02c0a)

18 months agodtrace: Fix RISC-V user stack unwinder
Jessica Clarke [Mon, 6 Feb 2023 18:30:57 +0000 (14:30 -0400)]
dtrace: Fix RISC-V user stack unwinder

The unwind logic was copied from AArch64 which follows the peculiar
AACPS (where, unlike typical RISC architectures, its frame pointer
follows an x86/stack machine-like convention where the frame pointer
points at the bottom of the frame record, not the top). Delete the
pointless riscv_frame struct and fix this.

Reviewed by: mhorne
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D28054

(cherry picked from commit 38720107324b3903f342bcb0306c72c4e4235053)

18 months agodtrace_asm.S: properly enter/exit user access
Mitchell Horne [Mon, 6 Feb 2023 18:04:21 +0000 (14:04 -0400)]
dtrace_asm.S: properly enter/exit user access

In order to read or write userspace memory without generating an access
fault, we must first enable the SUM bit in the sstatus CSR.

Reviewed by: markj
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38298

(cherry picked from commit 0e563bde48b1af6bd472e940f04a8d76315749ab)

18 months agodtrace: handle page faults in riscv dtrace_trap()
Mitchell Horne [Mon, 6 Feb 2023 18:08:35 +0000 (14:08 -0400)]
dtrace: handle page faults in riscv dtrace_trap()

We must detect the correct amount to increment sepc, as it may have been
a compressed instruction that triggered the fault.

Reviewed by: markj
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38299

(cherry picked from commit 06faad1de2c9aadcfd606d5f7121b201dbfbaa9d)

18 months agoUse maybe_yield() in a few more places
Mitchell Horne [Thu, 9 Feb 2023 15:42:53 +0000 (11:42 -0400)]
Use maybe_yield() in a few more places

Reviewed by: kib, markj
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38186

(cherry picked from commit dc9b13736fce15ec3dc77a87e06d6406c92a0141)

18 months agoBoolify should_yield()
Mitchell Horne [Thu, 9 Feb 2023 15:35:11 +0000 (11:35 -0400)]
Boolify should_yield()

Do this ahead of adding a man page that describes the function. No
functional change.

Reviewed by: kib, markj
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38181

(cherry picked from commit d570418bd8918980e578ff78a229593766b832bb)

18 months agoUpdate comments referencing create_thread()
Mitchell Horne [Thu, 9 Feb 2023 15:34:38 +0000 (11:34 -0400)]
Update comments referencing create_thread()

The equivalent function is now named thread_create(). Mention
kthread_add() where it is also relevant.

Reviewed by: kib, markj
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38180

(cherry picked from commit a7a452fedc42d9e260224b7e2cd833df7287319f)

18 months agounbound: Fix config file path
Juraj Lutter [Tue, 17 Jan 2023 17:25:47 +0000 (18:25 +0100)]
unbound: Fix config file path

Commit 1838dec31895fd4752fa8631322ab93be0705a66 changed the
config file path to /usr/local/etc/unbound/unbound.conf which
is wrong for unbound in base.

Reported by: Ihor Antonov <ihor_AT_antonovs_family>
Reviewed by: zlei
Approved by: zlei
Differential Revision: https://reviews.freebsd.org/D38106

Fixes: 1838dec31895fd4752fa8631322ab93be0705a66
(cherry picked from commit 1d577bedbae80ced38ccb834e6835e5fd98bc411)

18 months agounbound: Fix config.h
Cy Schubert [Sun, 15 Jan 2023 06:55:05 +0000 (22:55 -0800)]
unbound: Fix config.h

FreeBSD src does not support HAVE_DECL_EVSIGNAL_ASSIGN. While reviewing
the new config.h after regenerating it, this definition was not removed.

Updating config.h is a manual process of configuring the port and
copying/merging the generated config.h into src. This definition was
missed and not removed (#undef'd).

Fixes: 1838dec31895fd4752fa8631322ab93be0705a66

(cherry picked from commit 06b93ef8cda227d755d7f6cfa95d08c0ccc9dc2d)

18 months agounbound: Vendor import 1.17.1
Cy Schubert [Sun, 15 Jan 2023 05:39:31 +0000 (21:39 -0800)]
unbound: Vendor import 1.17.1

Release notes at
    https://www.nlnetlabs.nl/news/2023/Jan/12/unbound-1.17.1-released/.

Merge commit '7699e1386a16236002b26107ffd2dcbde375e197' into main

(cherry picked from commit 1838dec31895fd4752fa8631322ab93be0705a66)

18 months agoheimdal: Resolve hdb_free_entry() SIGSEGV/SIGILL
Cy Schubert [Tue, 7 Feb 2023 15:46:59 +0000 (07:46 -0800)]
heimdal: Resolve hdb_free_entry() SIGSEGV/SIGILL

When the client sends kadmind a create principal (kadm_create) request
kadm_s_create_principal() returns an error before zeroing out ent (an
hdb entry structure wrapper -- hdb_entry_ex), resulting in a NULL
reference.

Fix obtained from upstream commit 35ea4955a.

PR: 268059
Reported by: Robert Morris <rtm@lcs.mit.edu>
Obtained from: Heimdal commit 35ea4955a

(cherry picked from commit 6a70e0b4cdc606931555cdc59dc6c8d4a3ab4e3e)

18 months agonetlink: add headers installation
Alexander V. Chernikov [Sat, 1 Oct 2022 16:31:58 +0000 (16:31 +0000)]
netlink: add headers installation

(cherry picked from commit 11ca01e9aa479559da240ceba17fdcdf2d1e97c3)

18 months agoahci: increase timout
Mariusz Zaborski [Fri, 10 Feb 2023 15:56:04 +0000 (16:56 +0100)]
ahci: increase timout

For some devices, like Marvell 88SE9230, it takes more time
to connect to the device. This patch introduces a special flag
that extends the timeout from around 100ms to around 500ms.

This change is based on the work of: Peter Eriksson <pen@lysator.liu.se>

PR: 243401
Reviewed by: imp
Tested by: dch
MFC after: 3 days
Sponsored by: Equinix
Sponsored by: SkunkWerks, GmbH
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D38413

(cherry picked from commit f08ac4cb14c1c0740346a4363f82e1e1367c2bad)

18 months agotzcode: Resurrect tzsetwall(3) with a deprecation warning.
Dag-Erling Smørgrav [Thu, 9 Feb 2023 18:35:34 +0000 (19:35 +0100)]
tzcode: Resurrect tzsetwall(3) with a deprecation warning.

This function has been around since 4.4BSD but was dropped upstream in 2020.  This went unnoticed when tzcode was updated.  Bring it back, but prepare for removing it before 14.0 is released.

PR: 269445
MFC after: 3 days
Reported by: val@packett.cool
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D38445

(cherry picked from commit 71e0c8906e1a4ff774f8ae810aeb94af039eedb7)

18 months agossh: update to OpenSSH 9.2p1
Ed Maste [Mon, 6 Feb 2023 21:54:56 +0000 (16:54 -0500)]
ssh: update to OpenSSH 9.2p1

Release notes are available at https://www.openssh.com/txt/release-9.2

OpenSSH 9.2 contains fixes for two security problems and a memory safety
problem.  The memory safety problem is not believed to be exploitable.
These fixes have already been committed to OpenSSH 9.1 in FreeBSD.

Some other notable items from the release notes:

 * ssh(1): add a new EnableEscapeCommandline ssh_config(5) option that
   controls whether the client-side ~C escape sequence that provides a
   command-line is available. Among other things, the ~C command-line
   could be used to add additional port-forwards at runtime.

 * sshd(8): add support for channel inactivity timeouts via a new
   sshd_config(5) ChannelTimeout directive. This allows channels that
   have not seen traffic in a configurable interval to be
   automatically closed. Different timeouts may be applied to session,
   X11, agent and TCP forwarding channels.

 * sshd(8): add a sshd_config UnusedConnectionTimeout option to
   terminate client connections that have no open channels for a
   length of time. This complements the ChannelTimeout option above.

 * sshd(8): add a -V (version) option to sshd like the ssh client has.

 * scp(1), sftp(1): add a -X option to both scp(1) and sftp(1) to
   allow control over some SFTP protocol parameters: the copy buffer
   length and the number of in-flight requests, both of which are used
   during upload/download. Previously these could be controlled in
   sftp(1) only. This makes them available in both SFTP protocol
   clients using the same option character sequence.

 * ssh-keyscan(1): allow scanning of complete CIDR address ranges,
   e.g.  "ssh-keyscan 192.168.0.0/24". If a CIDR range is passed, then
   it will be expanded to all possible addresses in the range
   including the all-0s and all-1s addresses. bz#976

 * ssh(1): support dynamic remote port forwarding in escape
   command-line's -R processing. bz#3499

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

(cherry picked from commit f374ba41f55c1a127303d92d830dd58eef2f5243)

18 months agolocal-unbound-setup: Use default root certificates
Tijl Coosemans [Thu, 19 Jan 2023 17:13:35 +0000 (18:13 +0100)]
local-unbound-setup: Use default root certificates

Don't force /etc/ssl/cert.pem.  It does not exist by default, only if
security/ca_root_nss is installed.  Just use the default OpenSSL search
locations which are /etc/ssl/cert.pem and /etc/ssl/certs/.

The tls-system-cert option was added in Unbound 1.16.0.

Reviewed by: zlei
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D38243

(cherry picked from commit 8932f7ce1783a10e9ba79c61d54077aa7693552e)

18 months agossh: fix SIZEOF_TIME_T #define on i386
Ed Maste [Wed, 8 Feb 2023 18:31:44 +0000 (13:31 -0500)]
ssh: fix SIZEOF_TIME_T #define on i386

Reported by: imp
Reviewed by: imp
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38443

(cherry picked from commit 1aa9a35f6361cc898e2323e1f2823771eb4161da)

19 months agosbin/ping6: Remove remains of ping6.
Xin LI [Sun, 29 Jan 2023 23:21:25 +0000 (15:21 -0800)]
sbin/ping6: Remove remains of ping6.

(cherry picked from commit 195ec47b478a66fd935d59b2d189705f06f601cf)

19 months agorescue: Add fetch(1) to the rescue tool.
John Grafton [Sun, 29 Jan 2023 23:05:15 +0000 (15:05 -0800)]
rescue: Add fetch(1) to the rescue tool.

After a failed upgrade, having fetch(1) on a system that is
physically unnreachable would be very useful to download files
required to get the OS back up and functional.

On my system this adds 589,824 bytes (3.8%) to the binary size.

PR: 266224
Reported by: Dan Mahoney
Differential Revision: https://reviews.freebsd.org/D38193

(cherry picked from commit ea34aa4780e5a581732520ea579342af94684882)

rescue: Fix link order of SSL libraries and fetch.

ld.bfd requires libraries to be linked in order.  libssl requires
libcrypto.  libfetch requires libssl.  To fix the latter, move fetch
up above tar rather than listing the ssl libraries twice.

Reviewed by: delphij
Fixes: ea34aa4780e5 rescue: Add fetch(1) to the rescue tool.
Differential Revision: https://reviews.freebsd.org/D38304

(cherry picked from commit 0f031350f32b8760e0843a6476d67aa21116103b)

19 months agoFIOSEEKHOLE/FIOSEEKDATA: correct consistency for bmap-based implementation
Konstantin Belousov [Sat, 4 Feb 2023 01:20:19 +0000 (03:20 +0200)]
FIOSEEKHOLE/FIOSEEKDATA: correct consistency for bmap-based implementation

PR: 269261

(cherry picked from commit 3b6056204dd80cc866b7998ef0776247ebc42ce4)

19 months agonetlink: allow to override sb_max for netlink sockets.
Alexander V. Chernikov [Fri, 10 Feb 2023 16:07:17 +0000 (16:07 +0000)]
netlink: allow to override sb_max for netlink sockets.

Netlink sockets sometimes require larger buffers than other sockets.
For example, full-view IPv4 dump sent via netlink may consume 50+ megabytes.
The desired buffer may be bigger than the system maximum `sb_max`.
FreeBSD HEAD has a mechanism for overriding protocol `setsockopt()` handler,
 which netlink  uses to permit buffer reservations beyond `sb_max`.
 This behaviour is handy as it doesn't require system administrator to lift
 the limits for other sockets.
Stable/13 lack such muchanism, so a different approach has to be used.
This diff is a direct commit to stable/13 and it simply copies the logic from
 Netlink in -HEAD for checking if the larger buffer size should be permitted.

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

19 months agoRevert "netlink: allow to override sb_max for netlink sockets"
Alexander V. Chernikov [Fri, 10 Feb 2023 16:05:52 +0000 (16:05 +0000)]
Revert "netlink: allow to override sb_max for netlink sockets"

This reverts commit 4f81fdc0886f623043767866ebe4339bd12edf18.

19 months agonetlink: do not require elevated privileges when reading arp/ndp state.
Alexander V. Chernikov [Thu, 9 Feb 2023 14:12:33 +0000 (14:12 +0000)]
netlink: do not require elevated privileges when reading arp/ndp state.

MFC after: 1 day

(cherry picked from commit 5a5436eb5d960b9e243f8196147c6a51ca4f9dee)

19 months agonetlink: allow to override sb_max for netlink sockets
Alexander V. Chernikov [Thu, 9 Feb 2023 21:36:43 +0000 (21:36 +0000)]
netlink: allow to override sb_max for netlink sockets

19 months agoefiserialio: use port settings (sio->Mode) for initial setup
Toomas Soome [Thu, 2 Feb 2023 14:01:02 +0000 (16:01 +0200)]
efiserialio: use port settings (sio->Mode) for initial setup

Use serial port setup done by system firmware.
ARM64 Hyper-V does hung if we attempt to override the defaults,
therefore we should default to use settings from firmware.

Tested by: schakrabarti@microsoft.com
PR: 266248
MFC after: 1 week

(cherry picked from commit c243de11cf7c4bb3d67bbc1655b149037e5b04f1)

19 months agoPost-13.2-branch updates
Colin Percival [Fri, 10 Feb 2023 00:38:08 +0000 (16:38 -0800)]
Post-13.2-branch updates

Rename stable/13 to -STABLE

Bump __FreeBSD_version

Approved by: re (implicit)
Sponsored by: https://www.patreon.com/cperciva

19 months agousr.sbin/kbdcontrol.c: Add backwards compatibility functions
Stefan Eßer [Mon, 6 Feb 2023 22:56:44 +0000 (23:56 +0100)]
usr.sbin/kbdcontrol.c: Add backwards compatibility functions

This commit allows a kbdcontrol binary built with a version of kbio.h
that supports Unicode characters in dead key maps to load and display
keymaps including the dead key tables on a kernel built with a
previous version of kbio.h (that only supported 8 bit characters in
the dead key map).

This commit is meant as a temporary compatibility shim that will be
reverted when it can be assumed that all relevant systems have been
upgraded to a kernel that uses the updated kbio.h.

MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D38388

(cherry picked from commit b92f8e5c0dccd52ea194cabe835b7af0b5e91f09)

19 months agoSupport Unicode characters in keymap dead key tables
Stefan Eßer [Mon, 6 Feb 2023 22:48:47 +0000 (23:48 +0100)]
Support Unicode characters in keymap dead key tables

Support for Unicode characters had been added to the keyboard code,
but there are keymaps that have accented characters accessed via dead
key combinations, and those were still restricted to 8 bit codes.

This update to kbd.c adds support for Unicode characters and
compatibility code that allows a kbdcontrol command built from kbio.h
without these patches to work on a new kernel.

Compatibility code that allows a new kbdcontrol binary running on an
old kernel to load and display the dead key map will be committed in a
separate commit.

Reviewed by: imp, brooks
Approved by: brooks
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D38381

(cherry picked from commit 4972fb9276389fb87a790b415b1161cff395884c)

19 months agocontrib/bc: update to version 6.2.4
Stefan Eßer [Mon, 6 Feb 2023 21:33:56 +0000 (22:33 +0100)]
contrib/bc: update to version 6.2.4

This update contains only documentation changes (new main repository
URL and changed mail address of the program author) and changes to
the build system that do not affect the FreeBSD base system build.

MFC after: 3 days

(cherry picked from commit 4fca8e0f65a8bbbd1242c1f7d8e33b77c479f5de)

19 months agoipfilter: Fix use after free on packet with broken lengths
Cy Schubert [Thu, 2 Feb 2023 00:49:08 +0000 (16:49 -0800)]
ipfilter: Fix use after free on packet with broken lengths

Under the scenario with a packet with length of 67 bytes, a header length
using the default of 20 bytes and a TCP data offset (th_off) of 48 will
cause m_pullup() to fail to make sure bytes are arragned contiguously.
m_pullup() will free the mbuf chain and return a null. ipfilter stores
the resultant mbuf address (or the resulting NULL) in its fr_info_t
structure. Unfortuntely the eroneous packet is not flagged for drop.
This results in a kernel page fault at line 410 of sys/netinet/ip_fastfwd.c
as it tries to use a now previously freed, by m_pullup(), mbuf.

PR: 266442
Reported by: Robert Morris <rtm@lcs.mit.edu>

(cherry picked from commit 79f7745c098a766d34a4e072cdd1a06e6d0829d5)

19 months agoipfilter: Correctly type ipf_pullup()
Cy Schubert [Tue, 31 Jan 2023 19:09:00 +0000 (11:09 -0800)]
ipfilter: Correctly type ipf_pullup()

ipf_pullup() outputs a pointer to ip_t. Though returning a pointer to
void does work, it is imprecise and not completely correct.

(cherry picked from commit c941e8c65d9df878136dc5d51d70256d33f7769f)

19 months agosqlite3: Vendor import of sqlite3 3.40.1
Cy Schubert [Fri, 6 Jan 2023 17:10:14 +0000 (09:10 -0800)]
sqlite3: Vendor import of sqlite3 3.40.1

Release notes at https://www.sqlite.org/releaselog/3_40_1.html.

Obtained from:  https://www.sqlite.org/2022/sqlite-autoconf-3400100.tar.gz

Merge commit 'c728c97f5c838c9a873516c4499e4e1a41788ce7' into main

(cherry picked from commit 5ae830e9bacf120c5ab95d515814e2b815e839a6)

19 months agosockbufs: add sbreserve_locked_limit() with custom maxsockbuf limit.
Alexander V. Chernikov [Tue, 27 Sep 2022 13:52:11 +0000 (13:52 +0000)]
sockbufs: add sbreserve_locked_limit() with custom maxsockbuf limit.

Protocols such as netlink may need a large socket receive buffer,
 measured in tens of megabytes. This change allows netlink to
 set larger socket buffers (given the privs are in place), without
 requiring user to manuall bump maxsockbuf.

Reviewed by: glebius
Differential Revision: https://reviews.freebsd.org/D36747

(cherry picked from commit 7b660faa9e30c15d3be9b2c44c3ca046a33331f4)

19 months agolibmd / md5: Add SHA-512/224.
Dag-Erling Smørgrav [Mon, 6 Feb 2023 16:57:36 +0000 (17:57 +0100)]
libmd / md5: Add SHA-512/224.

While there, remove .Tn from man pages.

Also remove an obsolete comment about the 80386.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans, allanjude
Differential Revision: https://reviews.freebsd.org/D38373

(cherry picked from commit 2768d7056727c414241ebc4b9d26e62dd5460760)

19 months agosha512_224: Fix SHA512_224_Final() on little-endian machines.
Sebastian Huber [Mon, 6 Feb 2023 16:57:28 +0000 (17:57 +0100)]
sha512_224: Fix SHA512_224_Final() on little-endian machines.

PR: 266863
MFC after: 1 week
Reviewed by: allanjude, cperciva, des
Differential Revision: https://reviews.freebsd.org/D38372

(cherry picked from commit 6680cfe8e0eec4427716ab50d73ab8231dd9ab28)

19 months agocp: Add tests involving sparse files.
Dag-Erling Smørgrav [Wed, 1 Feb 2023 20:06:24 +0000 (21:06 +0100)]
cp: Add tests involving sparse files.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D38290

(cherry picked from commit 822fa7ae1e3e7ed277e47e6de355387e524c6ee4)

cp: Simplify the common case.

* The allocated buffer is only used in the fallback case, so move it
  there.  The argument for passing it in from the caller was that if
  malloc(3) were to fail, we'd want it to fail before we started
  copying anything, but firstly, it was already not in the right place
  to ensure that, and secondly, malloc(3) never fails (except in very
  contrived circumstances, such as an unreasonable RLIMIT_AS or
  RLIMIT_DATA).

* Remove the mmap(2) option.  It is almost never beneficial,
  especially when the alternative is copy_file_range(2), and it adds
  needless complexity and indentation.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: rmacklem, mav
Differential Revision: https://reviews.freebsd.org/D38291

(cherry picked from commit 6c85042afcbbf4cd0fb7e7c03226c7249081e690)

cp: Minor code cleanup.

* Fix includes in utils.c, cf. style(9).
* Fix type mismatch: readlink(2) returns ssize_t, not int.
* It is not necessary to set errno to 0 as fts_read(3) already does it.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: allanjude
Differential Revision: https://reviews.freebsd.org/D38369

(cherry picked from commit cb96a0ef0040fa7968245ab203ab70a7ed2d275d)

cp: Adjust the sparse file tests.

* The sparsity check was ineffective: it compared the apparent size in bytes to the actual size in blocks.  Instead, write a tool that reliably detects sparseness.
* Some of the seq commands were missing an argument.
* Based on empirical evidence, 1 MB holes are not necessarily large enough to be preserved by the underlying filesystem.  Increase the hole size to 16 MB.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: cracauer
Differential Revision: https://reviews.freebsd.org/D38414

(cherry picked from commit 8b418c83d175fde3b1f65210509ddcf2ac248d9f)

19 months agolibc: Add tests for strchrnul(3).
Dag-Erling Smørgrav [Wed, 1 Feb 2023 20:06:20 +0000 (21:06 +0100)]
libc: Add tests for strchrnul(3).

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: allanjude
Differential Revision: https://reviews.freebsd.org/D38286

(cherry picked from commit 606d0e4a9a862a7b4e3469a084834ca0e888afa4)

19 months agocmp: Print a summary on SIGINFO.
Dag-Erling Smørgrav [Tue, 31 Jan 2023 00:28:47 +0000 (01:28 +0100)]
cmp: Print a summary on SIGINFO.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D38280

(cherry picked from commit 6673a5476d029cd5b47b2eed27032211a14f52bd)

cmp: Increase buffer size for non-mmap case.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: rpokala
Differential Revision: https://reviews.freebsd.org/D38281

(cherry picked from commit 134841a7f3e5516a83732d40a4d42268c901a492)

19 months agow: Complete libxo transition.
Dag-Erling Smørgrav [Wed, 25 Jan 2023 06:21:13 +0000 (07:21 +0100)]
w: Complete libxo transition.

MFC after: 1 week
Sponsred by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D38172

(cherry picked from commit d90ff31ae5cd9ba073fbd6a7b2367b5209ea534e)

w: Unlike err(3), xo_err(3) won't accept a null format string.

MFC after: 1 week
X-MFC-with: d90ff31ae5cd
Sponsored by: Klara, Inc.
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D38192

(cherry picked from commit 6fc1bbbf62bda2f1b5be3a4be3d36bc964490ebe)

19 months agofind: Logic nit in man page.
Dag-Erling Smørgrav [Tue, 24 Jan 2023 08:53:35 +0000 (09:53 +0100)]
find: Logic nit in man page.

Arguments follow primaries, not the other way around.

MFC after: 1 week
Sponsored by: Klara, Inc.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D38173

(cherry picked from commit 14ebab25e1231decd80a64194e9028a9ada8d6e6)

19 months agodf: Return non-zero status on write failure.
Dag-Erling Smørgrav [Tue, 17 Jan 2023 13:40:05 +0000 (14:40 +0100)]
df: Return non-zero status on write failure.

While here, complete the libxo conversion and switch return value to standard constants.

MFC after: 1 week
Sponsored by: Klara, Inc.
Differential revision: https://reviews.freebsd.org/D38097

(cherry picked from commit c968598479917f52022b86d0089a9835ddcf2799)

19 months agosbin/md5.c: fix -q -c for BSD style versions
Stefan Eßer [Tue, 26 Jul 2022 21:04:57 +0000 (23:04 +0200)]
sbin/md5.c: fix -q -c for BSD style versions

The BSD style commands (with names not ending in "sum") ignored the -c
options and the passed digest value when invoked with -q.

The man page stated that -q causes only the calculated digest to be
printed, but did not consider the case of both the -q and -c being
used in combination.

Since there is no warning that -c will be ignored when the -q option
is used, users night (and did) expect that the exit code would reflect
the matching of the calculated digest and the argument passed with -c.

This update implements and documents this expected behavior.

PR: 265461
Reported by: Dmitrij <bugs.freebsd@1fff.net>
MFC after: 2 weeks

(cherry picked from commit 9f3aa538e307743b2b5048d38f87b7fd32d0c596)

19 months agoupdate external URLs
Wolfram Schneider [Sat, 5 Feb 2022 08:19:56 +0000 (08:19 +0000)]
update external URLs

(cherry picked from commit 6981ec8bdff0f57833ab58747815e6e160eceaa2)

19 months agosockets: add MSG_TRUNC flag handling for recvfrom()/recvmsg().
Alexander V. Chernikov [Mon, 25 Jul 2022 19:46:40 +0000 (19:46 +0000)]
sockets: add MSG_TRUNC flag handling for recvfrom()/recvmsg().

Implement Linux-variant of MSG_TRUNC input flag used in recv(), recvfrom() and recvmsg().
Posix defines MSG_TRUNC as an output flag, indicating packet/datagram truncation.
Linux extended it a while (~15+ years) ago to act as input flag,
resulting in returning the full packet size regarless of the input
buffer size.
It's a (relatively) popular pattern to do recvmsg( MSG_PEEK | MSG_TRUNC) to get the
packet size, allocate the buffer and issue another call to fetch the packet.
In particular, it's popular in userland netlink code, which is the primary driving factor of this change.

This commit implements the MSG_TRUNC support for SOCK_DGRAM sockets (udp, unix and all soreceive_generic() users).

PR: kern/176322
Reviewed by: pauamma(doc)
Differential Revision: https://reviews.freebsd.org/D35909
MFC after: 1 month

(cherry picked from commit be1f485d7d6bebc53b055cc165a11ada0ab5fb17)

19 months agomd5/tests: extend md5 test
Stefan Eßer [Mon, 6 Feb 2023 20:11:51 +0000 (21:11 +0100)]
md5/tests: extend md5 test

The testloop function is called with various parameters, but those
were ignored in the coreutils-c-test script. This was an oversight
and is fixed by passing the option to all invocations of the hash
functions in this test script.

Reported by: des
MFC after: 3 days

(cherry picked from commit d804497068c16bcb05383d7227d899f4ba59f706)

19 months agonetlink: allow path weight manipulations for single-path routes.
Alexander V. Chernikov [Sun, 29 Jan 2023 15:53:34 +0000 (15:53 +0000)]
netlink: allow path weight manipulations for single-path routes.

Add support for the scenario when user adds/deletes paths for a single
 prefix one-by-one, all with different weights.
This change adds a new FreeBSD-specific RTA attribute, NL_RTA_WEIGHT.
When dumping non-multipath routes, this attribute is added if the
 route weight is not RT_DEFAULT_WEIGHT.
When adding a new route, this attribute is parsed as a relative path
 weight.

MFC after: 2 weeks

(cherry picked from commit 3ebccb20d56455f4bef1366f942680d1b60828f6)

19 months agonetlink: export nextop group kernel index when dumping multipath route.
Alexander V. Chernikov [Sat, 28 Jan 2023 15:37:58 +0000 (15:37 +0000)]
netlink: export nextop group kernel index when dumping multipath route.

MFC after: 2 weeks

(cherry picked from commit 95b47ba6299401b487f29a05ac859629ee7d4f0b)

19 months agocarp: turn net.inet.carp.allow into a RW tunable
Boris Lytochkin [Sun, 29 Jan 2023 16:42:40 +0000 (16:42 +0000)]
carp: turn net.inet.carp.allow into a RW tunable

Currently CARP starts announcing its state when initialised, regardless
of the state of the other services provided by the server.
As a result, the device can become master while still loading the
firewall ruleset or initialising long-starting service.

This change adds the way to request delayed CARP start by setting the
  net.inet.carp.allow=0 in the loader.conf.

Differential Revision: https://reviews.freebsd.org/D38167
MFC after: 2 weeks

(cherry picked from commit ee49c5d33d93a6b10222f64a0dc16590ac2048a0)

19 months agonetlink: add "netlink" to the list of kernel features
Alexander V. Chernikov [Mon, 30 Jan 2023 11:13:51 +0000 (11:13 +0000)]
netlink: add "netlink" to the list of kernel features

Reduce the amount of debug messages on module init/detach.

MFC after: 1 week

(cherry picked from commit 7fc9cfa57ccd4ee8ee71f8edfacfc26afab9cd2e)

19 months agonetlink: add NETLINK to GENERIC.
Alexander V. Chernikov [Tue, 31 Jan 2023 14:22:11 +0000 (14:22 +0000)]
netlink: add NETLINK to GENERIC.

This is a followup of 692e19cf5195 (add netlink to GENERIC@amd64).

Netlink is a communication protocol defined in RFC 3549. It is async,
TLV-based protocol, providing 1-1 and 1-many communications between kernel
and userland. Netlink is currently used in Linux kernel to modify, read and
subscribe for nearly all networking states. Interface state, addresses, routes,
firewall, rules, fibs, etc, are controlled via Netlink.

Netlink support was added in D36002. It has got a number of improvements and
first customers since then:
* net/bird2 got netlink support, enabling route multipath in FreeBSD
* netlink-based devd notifications are being worked on ( D37574 ).
* linux(4) fully supports and depends on Netlink

Enabling Netlink in GENERIC targets two goals.
The first one is to provide stability for the third-party userland applications,
so they can rely on the fact that netlink always exists since 14.0 and potentially 13.2.
Loadable module makes life of the app delepers harder. For example, `net/bird2` can be
either build with netlink or rtsock support, but not both.

The second goal is to enable gradual conversion of the base userland tools
to use netlink(4) interfaces. Converting tools like netstat (D36529), route,
ifconfig one-by-one simplifies testing and addressing the feedback.
Othewise, switching all base to use netlink at once may be too big of a leap.

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

(cherry picked from commit e80699a809a079c4e673940544d6ddd944e8d08e)

19 months agopytest: delete interfaces from inside the jail.
Alexander V. Chernikov [Wed, 25 Jan 2023 16:32:52 +0000 (16:32 +0000)]
pytest: delete interfaces from inside the jail.

This change follows the approach used in 80fc25025ffc, to
 minimise the impact of the delayed interface migration.

MFC after: 2 weeks

(cherry picked from commit 20ea7f26e41375828a390fba613b86acfe366add)

19 months agopytest: add an example test fetching test directory and ATF vars.
Alexander V. Chernikov [Wed, 25 Jan 2023 13:55:33 +0000 (13:55 +0000)]
pytest: add an example test fetching test directory and ATF vars.

MFC after: 2 weeks

(cherry picked from commit 864ea9abfb98493a157dc17be17c428080843bdd)

19 months agonetinet6: honor blackhole/unreach routes in the non-fastforwading code.
Alexander V. Chernikov [Sun, 22 Jan 2023 16:57:36 +0000 (16:57 +0000)]
netinet6: honor blackhole/unreach routes in the non-fastforwading code.

Currently, under the conditions specified below, IPv6 ingress packet
 processing can ignore blackhole/reject flag on the prefix. The packet
 will instead be looped locally till TTL expiration and a single ICMPv6
 unreachable message will be send to the source even in case of
 RTF_BLACKHOLE.
The following conditions needs hold to make the scenario happen:
* IPv6 forwarding is enabled
* Packet is not fast-forwarded
* Destination prefix has either RTF_BLACKHOLE or RTF_REJECT flag
Fix this behavior by checking for the blackhole/reject flags in
ip6_forward().

Reported by: Dmitriy Smirnov <fox@sage.su>
Reviewed by: ae
Differential Revision: https://reviews.freebsd.org/D38164
MFC after: 3 days

(cherry picked from commit 30dd227cff75bdabaac2002a2b17095f3392a485)

19 months agoatf_pytest_wrapper: fix pytest output truncation
Jose Luis Duran [Wed, 28 Dec 2022 17:28:59 +0000 (17:28 +0000)]
atf_pytest_wrapper: fix pytest output truncation

Pass `-vv` to pytest in order to always get the full output.
While here, enforce the modeline.

Differential Revision: https://reviews.freebsd.org/D37894
MFC after: 2 weeks

(cherry picked from commit 058ac3e8063366dafa634d9107642e12b038bf09)

19 months agopytest: silence deprecation warning in the pytest atf wrapper
Jose Luis Duran [Wed, 28 Dec 2022 15:51:18 +0000 (15:51 +0000)]
pytest: silence deprecation warning in the pytest atf wrapper

Convert `pytest.mark` decorator to the `pytest.hookimpl()` one,
 as suggested by the
 https://docs.pytest.org/en/latest/deprecations.html#configuring-hook-specs-impls-using-markers

Differential Revision: https://reviews.freebsd.org/D37884
MFC after: 2 weeks

(cherry picked from commit eaeebfcb38599c94e89bbba3e9c7aeb821c84d71)

19 months agotests: Add an IPv4 loopback address of 127.0.0.1/8 to the lo0
Jose Luis Duran [Wed, 11 Jan 2023 14:33:58 +0000 (14:33 +0000)]
tests: Add an IPv4 loopback address of 127.0.0.1/8 to the lo0
 interface by default when creating VNETSs using pytest.

Reviewed By: asomers
Differential Revision: https://reviews.freebsd.org/D38021

(cherry picked from commit 4856aeaaed17726a1dfa5dd6c736e5b0851255b6)

19 months agoRead the arm64 far early in el0 exceptions
Andrew Turner [Wed, 25 Jan 2023 17:47:39 +0000 (17:47 +0000)]
Read the arm64 far early in el0 exceptions

When handling userspace exceptions on arm64 we need to dereference the
current thread pointer. If this is being promoted/demoted there is a
small window where it will cause another exception to be hit. As this
second exception will set the fault address register we will read the
incorrect value in the userspace exception handler.

Fix this be always reading the fault address before dereferencing the
current thread pointer.

Reported by: olivier@
Reviewed by: markj
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D38196

(cherry picked from commit f29942229d24ebb8b98f8c5d02f3c8632648007e)

19 months agolinux(4): Attach netlink on i386.
Dmitry Chagin [Mon, 6 Feb 2023 14:00:44 +0000 (17:00 +0300)]
linux(4): Attach netlink on i386.

Discussed with: melifaro
MFC after: 3 days

(cherry picked from commit 07db1f36848c008efb7ab6b37e199212560833ae)

19 months agolinux(4): Microoptimize linux_ipc code to unindent else blocks.
Dmitry Chagin [Fri, 3 Feb 2023 16:17:34 +0000 (19:17 +0300)]
linux(4): Microoptimize linux_ipc code to unindent else blocks.

No functional change.

MFC after: 1 week

(cherry picked from commit eb08932156dc5801418924cf0bf9f167b15f7bf0)

19 months agolinux(4): Use designated initializers.
Dmitry Chagin [Fri, 3 Feb 2023 16:17:15 +0000 (19:17 +0300)]
linux(4): Use designated initializers.

MFC after: 1 week

(cherry picked from commit 3e0c56a717d6af3b680463b25388c7acd7cb8844)

19 months agolinux(4): Remove stale comment that no longer applies.
Dmitry Chagin [Thu, 2 Feb 2023 17:21:37 +0000 (20:21 +0300)]
linux(4): Remove stale comment that no longer applies.

MFC after: 1 week

(cherry picked from commit ce20c00e858f209f42d404eca597553e461e0892)

19 months agolinux(4): Microoptimize rt_sendsig() on amd64.
Dmitry Chagin [Thu, 2 Feb 2023 17:21:37 +0000 (20:21 +0300)]
linux(4): Microoptimize rt_sendsig() on amd64.

Drop proc lock earlier, before copying user stuff.

Pointed out by: kib
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D38326
MFC after: 1 week

(cherry picked from commit 6ad07a4b2bdf0856545ff8495a7b3396695814fa)

19 months agolinux(4): Preserve fpu fxsave state across signal delivery on amd64.
Dmitry Chagin [Thu, 2 Feb 2023 17:21:37 +0000 (20:21 +0300)]
linux(4): Preserve fpu fxsave state across signal delivery on amd64.

PR: 240768
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D38302
MFC after: 1 week

(cherry picked from commit a95cb95e12e537dbe70f9de18cc0fe98e4a5ebf5)

19 months agolinux(4): Deduplicate linux_trans_osrel().
Dmitry Chagin [Thu, 2 Feb 2023 14:58:07 +0000 (17:58 +0300)]
linux(4): Deduplicate linux_trans_osrel().

MFC after: 1 week

(cherry picked from commit 95b8603427d5759c5d6090ffaacfaf7f3b8fb926)

19 months agolinux(4): Deduplicate linux_copyout_strings().
Dmitry Chagin [Thu, 2 Feb 2023 14:58:07 +0000 (17:58 +0300)]
linux(4): Deduplicate linux_copyout_strings().

It is still present in the 32-bit Linuxulator on amd64.

MFC after: 1 week

(cherry picked from commit 6039e966ff276ff6bcb57f2f70e7d8ff376b24fd)

19 months agolinux(4): Deduplicate linux_fixup_elf().
Dmitry Chagin [Thu, 2 Feb 2023 14:58:07 +0000 (17:58 +0300)]
linux(4): Deduplicate linux_fixup_elf().

Use native routines to fixup initial process stack. On Arm64 linux_elf_fixup() is
noop, as it do the stack fixup (room for argc) in the linux_copyout_strings().

MFC after: 1 week

(cherry picked from commit 9e550625f867a23ea3d87a77aa3c216b79ecd790)

19 months agolinux(4): Add coredump support to i386.
Dmitry Chagin [Thu, 2 Feb 2023 14:58:06 +0000 (17:58 +0300)]
linux(4): Add coredump support to i386.

MFC after: 1 week

(cherry picked from commit cc1b0f7d9626bbd116429014444cbf61edf708a2)

19 months agolinux(4): Use COMPAT_LINUX32 enstead of __ELF_WORD_SIZE.
Dmitry Chagin [Thu, 2 Feb 2023 14:58:06 +0000 (17:58 +0300)]
linux(4): Use COMPAT_LINUX32 enstead of __ELF_WORD_SIZE.

COMPAT_LINUX32 option is defined for case when building 32-bit Linuxulator
for the 64-bit host. Usage of __ELF_WORD_SIZE is wrong here as it is equal to 32
on i386 too.

MFC after: 1 week

(cherry picked from commit 6f8439db241c7409275d77f5376e8505967bef67)

19 months agolinux(4): Microoptimize linux_elf.h for future use.
Dmitry Chagin [Thu, 2 Feb 2023 14:58:06 +0000 (17:58 +0300)]
linux(4): Microoptimize linux_elf.h for future use.

In order to reduce code duplication move coredump support definitions
into the appropriate header and hide private definitions.

MFC after: 1 week

(cherry picked from commit 7446514533a40b376eaeb349ea33531ce9c711c2)

19 months agolinux(4): Deduplicate MI futex structures.
Dmitry Chagin [Wed, 1 Feb 2023 18:57:04 +0000 (21:57 +0300)]
linux(4): Deduplicate MI futex structures.

MFC after: 1 week

(cherry picked from commit 575e48f1c4eb05fe8df6aaeb5f55e17c63a02639)

19 months agoamd64: Eliminate write only cpu_fxsr.
Dmitry Chagin [Wed, 1 Feb 2023 15:17:06 +0000 (18:17 +0300)]
amd64: Eliminate write only cpu_fxsr.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D38289
MFC after: 1 week

(cherry picked from commit 5c32146723ef88b07506c081653898cd2f293a52)

19 months agoUnstaticize {get,set}_fpcontext() on amd64
Edward Tomasz Napierala [Tue, 4 Jan 2022 13:25:12 +0000 (13:25 +0000)]
Unstaticize {get,set}_fpcontext() on amd64

This will be used to fix Linux signal delivery.

Discussed With: kib
Sponsored By: EPSRC

(cherry picked from commit 562bc0a943d1fad1a9b551557609d2941a851b4d)

19 months agoiommu_gas: initialize start_gap as first node
Doug Moore [Wed, 8 Feb 2023 17:04:13 +0000 (11:04 -0600)]
iommu_gas: initialize start_gap as first node

In iommu_gas.c, domain->start_gap points to one of the nodes on either
side of the first free, unallocated range. In iommu_gas_init_domain,
it is initialized to point to the node after the single free
range. Change it to point to the node before that free range, so that,
when 'lowaddr' is within the initial free range, the first allocation
search for free space below 'lowaddr' does not begin and end at an
address above 'lowaddr'. This fixes problems on a machine with Intel
DMAR enabled.

Reported by: jah
Reviewed by: dougm
Tested by: jah
Obtained from: jah
Fixes: commit db151ca0c343531256b8839f938a4ecbd8b4fd7e iommu_gas: start space search from 1st free space
MFC after: 1 day

(cherry picked from commit 87d405eab91169e0b650a7dd2e5097c0b990fac5)

19 months agoatrtc: expose power loss as sysctl
Corvin Köhne [Thu, 8 Dec 2022 07:28:42 +0000 (08:28 +0100)]
atrtc: expose power loss as sysctl

Exposing the a power loss of the rtc as an sysctl makes it easier to
detect an empty cmos battery.

Reviewed by: manu
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D38325

(cherry picked from commit 55f1ca209d37d7b5a6faf57b23c7341cb7f84ee6)

19 months agossh: Be more paranoid with host/domain names coming from the
Ed Maste [Mon, 6 Feb 2023 16:45:52 +0000 (11:45 -0500)]
ssh: Be more paranoid with host/domain names coming from the

never write a name with bad characters to a known_hosts file.

replace recently-added valid_domain() check for hostnames going to
known_hosts with a more relaxed check for bad characters.

Obtained from: OpenSSH-portable commit 445363433ba2
Obtained from: OpenSSH-portable commit 3cae9f92a318
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 2e828220579e3ada74ed0613871ec6ec61d669ba)

19 months agossh: fix bug in PermitRemoteOpen which caused it to ignore...
Ed Maste [Mon, 6 Feb 2023 16:33:38 +0000 (11:33 -0500)]
ssh: fix bug in PermitRemoteOpen which caused it to ignore...

its first argument unless it was one of the special keywords "any" or
"none".

Obtained from: OpenSSH-portable commit b3daa8dc5823
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 94e21add45344f0669f910ea77db499e8c892c90)

19 months agossh: fix double-free caused by compat_kex_proposal()
Ed Maste [Mon, 6 Feb 2023 16:26:08 +0000 (11:26 -0500)]
ssh: fix double-free caused by compat_kex_proposal()

Security: CVE-2023-25136
Obtained from: OpenSSH-portable commit 12da78233364
Sponsored by: The FreeBSD Foundation

(cherry picked from commit fe1371e8f3d7336748d291a7360b2aacce943fb1)

19 months agoblacklistd: diff reduction against upstream
Ed Maste [Mon, 23 Jan 2023 16:19:46 +0000 (11:19 -0500)]
blacklistd: diff reduction against upstream

Add `conf_` prefix, maching https://github.com/zoulasc/blocklist

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 8089749d38781946c008372f4016d69eee549f1c)

19 months agogeli: split the initalization of HMAC
Mariusz Zaborski [Wed, 8 Feb 2023 16:41:06 +0000 (08:41 -0800)]
geli: split the initalization of HMAC

GELI allows to read a user key from a standard input.
However if user initialize multiple providers at once, the standard
input will be empty for the second and next providers.
This caused GELI to encrypt a master key with an empty key file.

This commits initialize the HMAC with the key file, and then reuse the
finalized structure to generate different encryption keys for different
providers.

Reported by: Nathan Dorfman
Tested by: philip
Security: FreeBSD-SA-23:01.geli
Security: CVE-2023-0751

(cherry picked from commit 5fff09660e06a66bed6482da9c70df328e16bbb6)

19 months agovmm: avoid spurious rendezvous
Corvin Köhne [Tue, 15 Nov 2022 10:53:49 +0000 (11:53 +0100)]
vmm: avoid spurious rendezvous

A vcpu only checks if a rendezvous is in progress or not to decide if it
should handle a rendezvous. This could lead to spurios rendezvous where
a vcpu tries a handle a rendezvous it isn't part of. This situation is
properly handled by vm_handle_rendezvous but it could potentially
degrade the performance. Avoid that by an early check if the vcpu is
part of the rendezvous or not.

At the moment, rendezvous are only used to spin up application
processors and to send ioapic interrupts. Spinning up application
processors is done in the guest boot phase by sending INIT SIPI
sequences to single vcpus. This is known to cause spurious rendezvous
and only occurs in the boot phase. Sending ioapic interrupts is rare
because modern guest will use msi and the rendezvous is always send to
all vcpus.

Reviewed by: jhb
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D37390

(cherry picked from commit 892feec2211d0dbd58252a34d78dbcb2d5dd7593)

19 months agolibthr pshared: correct a bug in allocation
Konstantin Belousov [Wed, 1 Feb 2023 20:12:45 +0000 (22:12 +0200)]
libthr pshared: correct a bug in allocation

PR: 269277

(cherry picked from commit 25c862ae503a1c99458f4e055fd50c878fadbea3)

19 months agolibthr: add pshared_destroy() helper
Konstantin Belousov [Wed, 1 Feb 2023 21:06:04 +0000 (23:06 +0200)]
libthr: add pshared_destroy() helper

(cherry picked from commit 3cf37d1251bf71b2171e67af8f2ca43cbe3d874d)

19 months agoirdma(4): remove 14-current specific code
Bartosz Sobczak [Fri, 20 Jan 2023 08:28:36 +0000 (09:28 +0100)]
irdma(4): remove 14-current specific code

This is a direct commit to the stable/13 branch.

Signed-off-by: Bartosz Sobczak <bartosz.sobczak@intel.com>
Signed-off-by: Eric Joyner <erj@FreeBSD.org>
19 months agoirdma(4): Add code for compilation on stable/13 branch
Bartosz Sobczak [Mon, 6 Feb 2023 22:37:39 +0000 (14:37 -0800)]
irdma(4): Add code for compilation on stable/13 branch

Current content of the irdma(4) driver consists only of code that is
compilable on current 14-CURRENT branch which makes it impossible to
merge into stable/13 branch because of missing dependencies in the ofed
tree.

This patch adds missing code that allows for merging into stable branch.
Once it is there, code relating only to version 14 or higher should be
removed.

Signed-off-by: Eric Joyner <erj@FreeBSD.org>
Reviewed by: erj@
MFC after: 1 day
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D38170

(cherry picked from commit a527c18cd7ba5d4afacbfb85817ca7b8b2487b52)

19 months agoirdma(4): Upgrade driver to 1.1.5-k
Bartosz Sobczak [Thu, 22 Dec 2022 01:10:15 +0000 (17:10 -0800)]
irdma(4): Upgrade driver to 1.1.5-k

This is to upgrade current irdma driver version (in support of RDMA on
Intel(R) Ethernet Controller E810) to 1.1.5-k

change summary:
- refactor defines for hardware registers
- rereg_mr verb added in libirdma
- fix print warning during compilation
- rt_ros2priority macro fix
- irdma.4 validated with mandoc
- fixing nd6_resolve usage
- added libirdma_query_device
- sysctl for irdma version
- aeq_alloc_db fix
- dwork_flush protected with qp refcount
- PFC fixes

Signed-off-by: Eric Joyner <erj@FreeBSD.org>
Reviewed by: erj@
Relnotes: yes
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D36944

(cherry picked from commit 777e472cd86b9394d07bf96c19dbafc2e1ff4fdc)

19 months agoirdma(4): hide tasklet-related definitions to avoid redefines
Bartosz Sobczak [Mon, 23 Jan 2023 10:17:53 +0000 (11:17 +0100)]
irdma(4): hide tasklet-related definitions to avoid redefines

checking if either from_tasklet or tasklet_setup
exists before defining irdma's own version.

This is a result of changes introduced in:
f2978460c7fd ("LinuxKPI: tasklet add (*callback) support", 2022-11-08)

The code should be kept until the from_timer and
tasklet_setup is defined in linuxkpi's interrupt.h

This is a direct commit to the stable/13 branch.

Signed-off-by: Bartosz Sobczak <bartosz.sobczak@intel.com>
Signed-off-by: Eric Joyner <erj@FreeBSD.org>
19 months agoibcore: The use of IN_LOOPBACK() now requires a valid VNET context.
Hans Petter Selasky [Wed, 31 Aug 2022 10:37:28 +0000 (12:37 +0200)]
ibcore: The use of IN_LOOPBACK() now requires a valid VNET context.

Make sure the VNET is set before using this macro.

Fixes: efe58855f3ea2cfc24cb705aabce3bc0fe1fb6d5
PR: 266054
Sponsored by: NVIDIA Networking

(cherry picked from commit f50274674ebf3a51a77708f569d38a238cbad6ec)