]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
16 months agoAdd a psci macro to build a version value
Andrew Turner [Thu, 16 Mar 2023 12:14:01 +0000 (12:14 +0000)]
Add a psci macro to build a version value

Add PSCI_VER that takes a major and minor version and builds the value
returned by the firmware. This will be used by bhyve.

Sponsored by: Arm Ltd

16 months agoAllow psci.h to be used by userspace
Andrew Turner [Thu, 16 Mar 2023 12:08:32 +0000 (12:08 +0000)]
Allow psci.h to be used by userspace

Wrap parts of psci.h that aren't usable by userspace in _KERNEL checks.
This allows it to be used to implement PSCI and SMCCC by bhyve in
userspace.

Sponsored by: Arm Ltd
Sponsored by: Innovate UK
Sponsored by: The FreeBSD Foundation

16 months agostress2: New problem found was added
Peter Holm [Thu, 16 Mar 2023 12:59:16 +0000 (13:59 +0100)]
stress2: New problem found was added

16 months agotarfs: Fix backtracking during node creation.
Dag-Erling Smørgrav [Thu, 16 Mar 2023 11:31:14 +0000 (11:31 +0000)]
tarfs: Fix backtracking during node creation.

Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D39082

16 months agotarfs: Support tar files which include file modes with permissions.
Dag-Erling Smørgrav [Thu, 16 Mar 2023 11:31:10 +0000 (11:31 +0000)]
tarfs: Support tar files which include file modes with permissions.

Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D39020

16 months agotarfs: Correctly track link count.
Dag-Erling Smørgrav [Thu, 16 Mar 2023 11:31:06 +0000 (11:31 +0000)]
tarfs: Correctly track link count.

Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D39019

16 months agotarfs: Repeat tests using GNU tar if available.
Dag-Erling Smørgrav [Thu, 16 Mar 2023 11:31:01 +0000 (11:31 +0000)]
tarfs: Repeat tests using GNU tar if available.

Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Reviewed by: ngie, asomers
Differential Revision: https://reviews.freebsd.org/D39018

16 months agocarp: carp_master_down_locked() requires net epoch
Zhenlei Huang [Thu, 16 Mar 2023 10:00:13 +0000 (18:00 +0800)]
carp: carp_master_down_locked() requires net epoch

Reviewed by: kp
Fixes: 1d126e9b9474 carp: Widen epoch coverage
MFC after: 1 day
Differential Revision: https://reviews.freebsd.org/D39113

16 months agopf tests: test IPv6 fragmentation with link-local addresses
Kristof Provost [Sun, 12 Mar 2023 15:08:31 +0000 (16:08 +0100)]
pf tests: test IPv6 fragmentation with link-local addresses

We've observed a panic after pf_refragment6() with link-local addresses,
because pf_refragment6() calls ip6_forward() even for a simple output
case.
That results in us entering ip6_forward() with an mbuf with a NULL
m->m_pkthdr.rcvif, which can cause a NULL deref (but seemingly not for
GUAs.

Test sending fragmented link-local packets to pf.

MFC after: 3 days
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D39063

16 months agopf: set scope in pf_refragment6()
Kristof Provost [Mon, 13 Mar 2023 09:27:59 +0000 (10:27 +0100)]
pf: set scope in pf_refragment6()

Link-local traffic needs to have a scope embedded before it's passed on
to ip6_output(). Do so in pf_refragment6(), because when we end up here
in the output path we may have passed through ip6_output() already
(before being reassembled), where the scope would have been removed.

Re-embed the scope so that link-local traffic is sent correctly.

Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D39062

16 months agopf: distinguish forwarding and output cases for pf_refragment6()
Kristof Provost [Sun, 12 Mar 2023 17:34:42 +0000 (18:34 +0100)]
pf: distinguish forwarding and output cases for pf_refragment6()

Re-introduce PFIL_FWD, because pf's pf_refragment6() needs to know if
we're ip6_forward()-ing or ip6_output()-ing.

ip6_forward() relies on m->m_pkthdr.rcvif, at least for link-local
traffic (for in6_get_unicast_scopeid()). rcvif is not set for locally
generated traffic (e.g. from icmp6_reflect()), so we need to call the
correct output function.

Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revisi: https://reviews.freebsd.org/D39061

16 months agosctp: don't do RTT measurements with cookies
Michael Tuexen [Thu, 16 Mar 2023 09:45:13 +0000 (10:45 +0100)]
sctp: don't do RTT measurements with cookies

When receiving a cookie, the receiver does not know whether the
peer retransmitted the COOKIE-ECHO chunk or not. Therefore, don't
do an RTT measurement. It might be much too long.
To overcome this limitation, one could do at least two things:
1. Bundle the INIT-ACK chunk with a HEARTBEAT chunk for doing the
   RTT measurement. But this is not allowed.
2. Add a flag to the COOKIE-ECHO chunk, which indicates that it
   is the initial transmission, and not a retransmission. But
   this requires an RFC.

MFC after: 1 week

16 months agosctp: allow disabling of SCTP_ACCEPT_ZERO_CHECKSUM socket option
Michael Tuexen [Wed, 15 Mar 2023 21:55:23 +0000 (22:55 +0100)]
sctp: allow disabling of SCTP_ACCEPT_ZERO_CHECKSUM socket option

16 months agosctp: improve negotiation of zero checksum feature
Michael Tuexen [Wed, 15 Mar 2023 21:29:52 +0000 (22:29 +0100)]
sctp: improve negotiation of zero checksum feature

Enforce consistency between announcing 0-cksum support and actually
using it in the association. The value from the inp when the
INIT ACK is sent must be used, not the one from the inp when the
cookie is received.

16 months agonetlink: improve snl(3)
Alexander V. Chernikov [Wed, 15 Mar 2023 13:56:26 +0000 (13:56 +0000)]
netlink: improve snl(3)

Summary:
* add snl_send_message() as a convenient send wrapper
* add signed integer parsers
* add snl_read_reply_code() to simplify operation result checks
* add snl_read_reply_multi() to simplify reading multipart messages
* add snl_create_genl_msg_request()
* add snl_get_genl_family() to simplify family name->id resolution
* add tests for some of the functionality

Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D39092
MFC after: 2 weeks

16 months agoarm64: Support stage 2 mappings in pmap_remove_all
Andrew Turner [Wed, 15 Mar 2023 16:27:51 +0000 (16:27 +0000)]
arm64: Support stage 2 mappings in pmap_remove_all

This has been hit when testing bhyve.

Sponsored by: Arm Ltd

16 months agossh: update FREEBSD-upgrade instructions
Ed Maste [Wed, 23 Feb 2022 18:33:24 +0000 (13:33 -0500)]
ssh: update FREEBSD-upgrade instructions

Make it clear that the 'freebsd-configure.sh' and 'freebsd-namespace.sh'
scripts are run from the crypto/openssh directory.

Sponsored by: The FreeBSD Foundation

16 months agoStop using the rid as an index in the arm timer
Andrew Turner [Wed, 15 Mar 2023 13:35:04 +0000 (13:35 +0000)]
Stop using the rid as an index in the arm timer

The order of the interrupt array doesn't matter. Store the described
interrupts at the start of the array to simplify iterating over them.

Reviewed by: imp, kevans
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D39094

16 months agoUse the arm physical timer when able
Andrew Turner [Wed, 15 Mar 2023 13:33:02 +0000 (13:33 +0000)]
Use the arm physical timer when able

To allow bhyve manage the virtual timer while in a guest have FreeBSD
use the virtual timer only when bhyve will be unavailable due to not
starting at EL2 where the hypervisor switcher will run.

Reviewed by: imp, kevans
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D39093

16 months agoSupport the arm64 pmap_remove_write for stage 2
Andrew Turner [Tue, 15 Nov 2022 17:49:42 +0000 (17:49 +0000)]
Support the arm64 pmap_remove_write for stage 2

The fields we need to adjust are different in stage 1 and stage 2
tables. Handle this by adding variables to hold the bits to check,
set, and clear.

Reviewed by: alc
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37399

16 months agoarm64: limit EFI excluded regions to physical memory types
Mitchell Horne [Wed, 15 Mar 2023 15:26:57 +0000 (12:26 -0300)]
arm64: limit EFI excluded regions to physical memory types

Consolidate add_efi_map_entry() and exclude_efi_map_entry() into a
single function, handle_efi_map_entry(), so that the exact set of entry
types handled is the same in the addition or exclusion cases. Before,
exclude_efi_map_entry() had a 'default' case that would exclude all
entry types that were not listed explicitly in the switch statement.

Logically, we do not need to exclude a range that could not possibly be
added to physmem, and we do not need to exclude bus ranges that are not
physical memory, for example EFI_MD_TYPE_IOMEM.

Since physmem's ram0 device will reserve bus memory resources for its
owned ranges, this was preventing attachment of the watchdog device on
the RPI4B. For some reason its region of memory-mapped I/O appeared in
the EFI memory map (with the aforementioned EFI_MD_TYPE_IOMEM type).
This change fixes the attachment issue, as we prevent the physmem API
from messing with this range of bus space.

PR: 270044
Reported by: karels, Mark Millard
Reviewed by: andrew, karels, imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D39003

16 months agonet: refactor if_clone.c #1
Alexander V. Chernikov [Mon, 13 Mar 2023 10:41:58 +0000 (10:41 +0000)]
net: refactor if_clone.c #1

* Add ifc_find_cloner()
* Rename current ifc_find_cloner() to ifc_find_cloner_in_vnet()
* Add ifc_find_cloner_match()

This change simplifies the code a bit and reduces the diff to
 the netlink interface cloners merge (D39032).

Reviewed by: glebius, kp
Differential Revision: https://reviews.freebsd.org/D39046
MFC after: 2 weeks

16 months agoSupport arm64 stage2 TLB invalidation
Andrew Turner [Thu, 3 Nov 2022 16:01:37 +0000 (16:01 +0000)]
Support arm64 stage2 TLB invalidation

To invalidate stage 2 mappings on arm64 we may need to call into the
hypervisor so add a function pointer that bhyve can use to implement
this.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37254

16 months agoKeep per-timer interrupt data together
Andrew Turner [Tue, 14 Mar 2023 09:27:23 +0000 (09:27 +0000)]
Keep per-timer interrupt data together

Eliminate a redundant resource array allow possible use by bhyve later.

Reviewed by: kevans
Sponsored by: Arm Ltd
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37424

16 months agoveriexec: Improve comments
Warner Losh [Wed, 15 Mar 2023 04:59:20 +0000 (22:59 -0600)]
veriexec: Improve comments

Make it clear we're checking to see if the target is a verified file and
prevent its replacement if so.

Sponsored by: Netflix
Reviewed by: rpokala
Differential Revision: https://reviews.freebsd.org/D39079

16 months agolibbe: Avoid double printing cloning errors.
John Grafton [Wed, 15 Mar 2023 03:14:14 +0000 (21:14 -0600)]
libbe: Avoid double printing cloning errors.

be_clone calls be_clone_cb and both call set_error on the return
error path.  set_error prints the error resulting in a double print.
be_clone_cb should just return the error code and allow be_clone
to print it.

PR: 265248
Reported by: Graham Perrin
Reviewed by: imp, kevans
Pull Request: https://github.com/freebsd/freebsd-src/pull/685

16 months agojail: convert several functions from int to bool
Mina Galić [Wed, 15 Mar 2023 03:04:40 +0000 (21:04 -0600)]
jail: convert several functions from int to bool

these functions exclusively return (0) and (1), so convert them to bool

We also convert some networking related jail functions from int to bool
some of which were returning an error that was never used.

Differential Revision: https://reviews.freebsd.org/D29659
Reviewed by: imp, jamie (earlier version)
Pull Request: https://github.com/freebsd/freebsd-src/pull/663

16 months agorc: ignore .pkgsave files
Mina Galić [Wed, 15 Mar 2023 02:52:15 +0000 (20:52 -0600)]
rc: ignore .pkgsave files

The local parts of rc already skip .sample files; we add .pkgsave to the
list, and add logic for base.

Thanks to @RhodiumToad for getting this started.

Differential Revision: https://reviews.freebsd.org/D27962
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/662

16 months agoppp: Remove trailing semicolon
Elyes Haouas [Wed, 15 Mar 2023 02:09:16 +0000 (20:09 -0600)]
ppp: Remove trailing semicolon

Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/654

16 months agopmccontrol: Remove trailing semicolon
Elyes Haouas [Wed, 15 Mar 2023 02:09:16 +0000 (20:09 -0600)]
pmccontrol: Remove trailing semicolon

Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/654

16 months agolpr: Remove trailing semicolon
Elyes Haouas [Wed, 15 Mar 2023 02:09:16 +0000 (20:09 -0600)]
lpr: Remove trailing semicolon

Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/654

16 months agobhyve: Remove trailing semicolon
Elyes Haouas [Wed, 15 Mar 2023 02:09:16 +0000 (20:09 -0600)]
bhyve: Remove trailing semicolon

Macros shouldn't use trailing semicolon.

Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/654

16 months agoCI: Run pkgbase METALOG lint script
Ed Maste [Wed, 16 Nov 2022 21:24:19 +0000 (16:24 -0500)]
CI: Run pkgbase METALOG lint script

tools/pkgbase/metalog_reader.lua checks for errors in METALOG (for
pkgbase staging), such as hard links with differing modes, duplicate
entries, etc.  Run it as part of the Cirrus-CI job to prevent
regressions.

Reviewed by: manu, imp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37521

16 months ago.github: Test DISK_IMAGE_TOOLS_BOOTSTRAP in CI
Jessica Clarke [Wed, 15 Mar 2023 00:06:53 +0000 (00:06 +0000)]
.github: Test DISK_IMAGE_TOOLS_BOOTSTRAP in CI

Building the tools is quick so we should provide coverage of this to
ensure it keeps working, especially on non-FreeBSD.

Reviewed by: emaste, arichardson
Differential Revision: https://reviews.freebsd.org/D39073

16 months agoAdd new DISK_IMAGE_TOOLS_BOOTSTRAP option
Jessica Clarke [Wed, 15 Mar 2023 00:06:53 +0000 (00:06 +0000)]
Add new DISK_IMAGE_TOOLS_BOOTSTRAP option

This will build etdump, makefs and mkimg as bootstrap tools to allow
easily creating disk images. Note that etdump is bootstrapped due to its
use in the release scripts for building ISO images.

Reviewed by: emaste, arichardson
Differential Revision: https://reviews.freebsd.org/D39072

16 months agosrc.conf.5: Regen after ZFS-related options changes
Jessica Clarke [Wed, 15 Mar 2023 00:06:52 +0000 (00:06 +0000)]
src.conf.5: Regen after ZFS-related options changes

Since 9503d2704ca6 LOADER_ZFS gets turned off when ZFS is, and since
63715498ac6b ZFS is no longer disabled on powerpc and powerpcspe.

Reviewed by: emaste
Fixes: 9503d2704ca6 ("opts: Minor cleanup of ZFS options")
Fixes: 63715498ac6b ("powerpc: enable ZFS on 32 bit powerpc/powerpcspe")
Differential Revision: https://reviews.freebsd.org/D39071

16 months agosecure_getenv: Put under __BSD_VISIBLE
Warner Losh [Tue, 14 Mar 2023 23:42:18 +0000 (17:42 -0600)]
secure_getenv: Put under __BSD_VISIBLE

Sponsored by: Netflix
Reviewed by: delphij
Differential Revision: https://reviews.freebsd.org/D39076

16 months agojail.8: Update the allow.nfsd section
Rick Macklem [Tue, 14 Mar 2023 22:28:02 +0000 (15:28 -0700)]
jail.8: Update the allow.nfsd section

This patch updates the information for "allow.nfsd"
and adds configuration information.

This is a content change.

Reviewed by: karels, markj, pauamma (manpages)
MFC after: 3 months
Differential Revision: https://reviews.freebsd.org/D39033

16 months agonet80211: make ieee80211_scan_dump_channels private
Bjoern A. Zeeb [Tue, 14 Mar 2023 21:01:19 +0000 (21:01 +0000)]
net80211: make ieee80211_scan_dump_channels private

ieee80211_scan_dump_channels() is only used locally and only when
IEEE80211_DEBUG is compiled.  Stop exporting it, make it file local
and hide under the #ifdef to reduce the footprint for production
kernels a tiny bit.

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

16 months agonet80211: define mask for ss_flags rather than using hardcoded 0xfff
Bjoern A. Zeeb [Tue, 14 Mar 2023 21:00:48 +0000 (21:00 +0000)]
net80211: define mask for ss_flags rather than using hardcoded 0xfff

scan state ss_flags in two places cut off the "internal" GOTPICK
options.  Replace the hardcoded 0xfff with a defined mask.
Note that "internal" flags is confusing as we also supplement the
the 16bit by another 16bit of "internal flags" passed around but
comaparing to GOTPICK never stored to my understanding.

No functional change.

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

16 months agonetmap: get rid of save_if_input for emulated adapters
Vincenzo Maffione [Tue, 14 Mar 2023 21:59:23 +0000 (21:59 +0000)]
netmap: get rid of save_if_input for emulated adapters

The save_if_input function pointer was meant to save the previous
value of ifp->if_input before replacing it with the emulated
adapter hook.
However, the same pointer value is already stored in the if_input
field of the netmap_adapter struct, to be used for host TX ring processing.

Reuse the netmap_adapter if_input field to simplify the code
and save some space.

MFC after: 14 days

16 months agoinfiniband: Convert BPF handling for IfAPI
Justin Hibbits [Thu, 9 Feb 2023 02:32:47 +0000 (21:32 -0500)]
infiniband: Convert BPF handling for IfAPI

Summary:
All callers of infiniband_bpf_mtap() call it through the wrapper macro,
which checks the if_bpf member explicitly.  Since this is getting
hidden, move this check into the internal function and remove the
wrapper macro.

Reviewed by: hselasky
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D39024

16 months agossh: fix leak and apply style(9) to hostname canonicalization
Ed Maste [Wed, 8 Feb 2023 13:16:53 +0000 (08:16 -0500)]
ssh: fix leak and apply style(9) to hostname canonicalization

Fixes: bf2e2524a2ce ("ssh: canonicize the host name before...")
Fixes: 3e74849a1ee2 ("ssh: canonicize the host name before...")
Reviewed by: rew
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38441

16 months agocompiler-rt: remove eprintf
Ed Maste [Tue, 14 Mar 2023 17:01:20 +0000 (13:01 -0400)]
compiler-rt: remove eprintf

It was used by ancient GCC assert.h.  Prior to 2001 GCC used to provide
its own assert.h  The GCC assert.h required __eprintf to emit the error
message.  FreeBSD's own assert.h never used this.

Reviewed by: ed (previously), imp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D2597

16 months agoReserve u2f group for FIDO/U2F key support (SSH, etc.)
Ed Maste [Fri, 18 Feb 2022 18:13:20 +0000 (13:13 -0500)]
Reserve u2f group for FIDO/U2F key support (SSH, etc.)

We have FIDO/U2F support in the base system now, so reserve a group ID
for it (maching the security/u2f-devd port).

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34341

16 months agoping: Remove ifndef icmp_data guards
Jose Luis Duran [Tue, 14 Mar 2023 15:22:33 +0000 (11:22 -0400)]
ping: Remove ifndef icmp_data guards

Early versions of <netinet/ip_icmp.h> [1] did not have icmp_data
defined, but FreeBSD has always had.  Remove these guards.

NetBSD [2] and OpenBSD [3] have already removed them.

[1]: https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/netinet/ip_icmp.h
[2]: https://github.com/NetBSD/src/commit/203dfd34867991fd002f747d74a96f26ae80d41c
[3]: https://github.com/openbsd/src/commit/d83449c83c03b86e72d642dc92bcea434310435a

Reviewed by: markj
MFC after: 1 week

16 months agoping: Fix the display of Flags/Fragment Offset
Jose Luis Duran [Tue, 14 Mar 2023 15:09:27 +0000 (11:09 -0400)]
ping: Fix the display of Flags/Fragment Offset

In the IP header, Flags + Fragment Offset is a 16-bit field.

Use ntohs() instead of ntohl(), otherwise the Flags/Fragment Offset
values may not display correctly.

Before (DF set)

    Vr HL TOS  Len   ID Flg  off TTL Pro  cks      Src      Dst
     4  5  00 0054 0001   0 0000  40  01 b6a4 192.0.2.1  192.0.2.2

After (DF set)

    Vr HL TOS  Len   ID Flg  off TTL Pro  cks      Src      Dst
     4  5  00 0054 0001   2 0000  40  01 b6a4 192.0.2.1  192.0.2.2

Reviewed by: markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D38479

16 months agoping6: Use errx to avoid appending a specious error message
Jose Luis Duran [Tue, 14 Mar 2023 15:08:54 +0000 (11:08 -0400)]
ping6: Use errx to avoid appending a specious error message

Reviewed by: asomers, markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D38418

16 months agoudp: Fix a memory leak in udp6_send()
Mark Johnston [Tue, 14 Mar 2023 14:26:29 +0000 (10:26 -0400)]
udp: Fix a memory leak in udp6_send()

Reviewed by: glebius
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D38993

16 months agoIncrease protection provided by veriexec with new unlink/rename hooks.
dl [Tue, 14 Mar 2023 04:26:41 +0000 (22:26 -0600)]
Increase protection provided by veriexec with new unlink/rename hooks.

Functions implemented :

- mac_veriexec_vnode_check_unlink: Unlink on a file has been
  requested and requires validation. This function prohibits the
  deleting a protected file (or deleting one of these hard links, if
  any).
- mac_veriexec_vnode_check_rename_from: Rename the file has been
  requested and must be validated. This function controls the renaming
  of protected file
- mac_veriexec_vnode_check_rename_to: File overwrite rename has been
  requested and must be validated. This function prevent overwriting of
  a file protected (overwriting by mv command).

The 3 fonctions together aim to control the 'removal' (via unlink) and
the 'mv' on files protected by veriexec. The intention is to reach the
functional level of NetBSD veriexec.

Add sysctl node security.mac.veriexec.unlink to toggle control on
syscall unlink.

Add tunable kernel variable security.mac.veriexec.block_unlink to toggle
unlink protection. Add the corresponding read-only sysctl.

[ tidied up commit message, trailing whitespace, long lines, { placement ]

Reviewed by: sjg, imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/613

16 months agoloader: Add support for booting from a ZFS snapshot
Allan Jude [Sat, 26 Nov 2022 18:11:13 +0000 (18:11 +0000)]
loader: Add support for booting from a ZFS snapshot

When booting from a snapshot we need to follow a different code path
to turn the objset ID into the name, and for forward lookups we need
to walk the parent's snapnames_zap.

With this, it is possible to set the pools BOOTFS property to a
snapshot and boot with a read-only filesystem of that snapshot.

Reviewed by: tsoome, rew, imp
Sponsored By: Beckhoff Automation GmbH & Co. KG
Sponsored By: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D38600

16 months agoroute.8: Don't reference an external command in EXAMPLES
Gordon Bergling [Tue, 14 Mar 2023 13:55:28 +0000 (14:55 +0100)]
route.8: Don't reference an external command in EXAMPLES

It is better to mention the externel command for showing
the routing table as using an explicit command.

PR: 231579
Suggested by: karels
Reviewed by: karles, gbe
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D39075

16 months agoCI: update QEMU command line to avoid deprecated option format
Ed Maste [Tue, 7 Mar 2023 16:38:01 +0000 (11:38 -0500)]
CI: update QEMU command line to avoid deprecated option format

> warning: short-form boolean option 'readonly' deprecated
> Please use readonly=on instead

Sponsored by: The FreeBSD Foundation

16 months agoAlways enable the virtual timer for userspace
Andrew Turner [Fri, 10 Mar 2023 12:43:59 +0000 (12:43 +0000)]
Always enable the virtual timer for userspace

We always have it, some languages assume it's present, e.g. go
before 1.20. Enable it by default on arm and arm64.

PR: 269070
Reviewed by: kevans
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D39059

16 months agoFix the ofw parent check in arm64 nexus
Andrew Turner [Mon, 6 Mar 2023 09:54:57 +0000 (09:54 +0000)]
Fix the ofw parent check in arm64 nexus

OF_parent returns 0 for no parent. Fix the check in teh arm64
nexus_fdt_activate_resource.

Sponsored by: Arm Ltd

16 months agoxen: take struct size into account for video information
Roger Pau Monné [Mon, 13 Mar 2023 14:17:21 +0000 (15:17 +0100)]
xen: take struct size into account for video information

The xenpf_dom0_console_t structure can grow as more data is added, and
hence we need to check that the fields we accesses have been filled by
Xen.  The only extra field FreeBSD currently uses is the top 32 bits
for the frame buffer physical address.

Note that this field is present in all the versions that make the
information available from the platform hypercall interface, so the
check here is mostly cosmetic, and to remember us that newly added
fields require checking the size of the returned data.

Fixes: 6f80738b228c ('xen: fetch dom0 video console information from Xen')
Sponsored by: Citrix Systems R&D

16 months agoAdd GNU glibc compatible secure_getenv
lucy [Mon, 13 Mar 2023 22:01:12 +0000 (16:01 -0600)]
Add GNU glibc compatible secure_getenv

Add mostly glibc and msl compatible secure_getenv. Return NULL if
issetugid() indicates the process is tainted, otherwise getenv(x).  The
rational behind this is the fact that many Linux applications use this
function instead of getenv() as it's widely consider a, "best
practice".

Reviewed by: imp, mjg (feedback)
Pull Request: https://github.com/freebsd/freebsd-src/pull/686
Signed-off-by: Lucy Marsh <seafork@disroot.org>
16 months agoarm64: Delete redundant badly formatted and capitalised comment
Jessica Clarke [Tue, 14 Mar 2023 04:15:03 +0000 (04:15 +0000)]
arm64: Delete redundant badly formatted and capitalised comment

Fixes: 9729f076e4d9 ("arm64: Hyper-V: enablement for ARM64 in Hyper-V (Part 3, final)")

16 months agoarm64: Move Azure-specific config from std.hyperv to std.azure
Jessica Clarke [Tue, 14 Mar 2023 04:12:31 +0000 (04:12 +0000)]
arm64: Move Azure-specific config from std.hyperv to std.azure

Hyper-V does not provide Mellanox hardware, some of Azure's instances
do, thus the configuration to enable them does not belong in the generic
std.hyperv config.

Fixes: 15e7fa83ef3c ("arm64: Hyper-V: Add vPCI and Mellanox driver modules into build")

16 months agoParse /kboot.conf
Warner Losh [Tue, 14 Mar 2023 02:33:35 +0000 (20:33 -0600)]
Parse /kboot.conf

If there's a kboot.conf, prase it after the command line args are
parsed. It's not always easy to get all the right command line args
depending on the environment. Allow an escape hatch. While we can't do
everything one might like in this file, we can do enough.

Sponsored by: Netflix

16 months agomakefs: do not call brelse if bread returns an error
Ed Maste [Mon, 13 Mar 2023 20:51:51 +0000 (16:51 -0400)]
makefs: do not call brelse if bread returns an error

If bread returns an error there is no bp to brelse.  One of these
changes was taken from NetBSD commit 0a62dad69f62 ("This works well
enough to populate..."), the rest were found by looking for the same
pattern.

Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39069

16 months agoarm: generic_timer: use interrupt-names when available
Kyle Evans [Sun, 5 Mar 2023 00:49:04 +0000 (18:49 -0600)]
arm: generic_timer: use interrupt-names when available

Offsets for all of thse can be a bit complicated as not all interrupts
will be present, only phys and virt are actually required, and sec-phys
could optionally be specified before phys.  Push idx/name pairs into
a new config struct and maintain the old indices while still getting the
correct timers.

Split fdt/acpi attach out independently and allocate interrupts before
we head into the common attach().  The secure physical timer is also
optional there, so mark it so to avoid erroring out if we run into
problems.

Reviewed by: andrew
Differential Revision: https://reviews.freebsd.org/D38911

16 months agomakefs: make msdos creation go fast
Warner Losh [Mon, 13 Mar 2023 20:28:51 +0000 (14:28 -0600)]
makefs: make msdos creation go fast

Add missing brelse(bp). Without it the cache grows and we have a n^2
lookup.  I'm not entirely sure why we read the block before we write it
back out, since the only side effect of that is to allocate memory,
clear the memory, read it in from disk, throw it away with the contents
of the file being written out. We likely should just do a getblk() here
instead, but even with all that, this takes the time it takes to create
a 150MB msdos fs image down from 5 minutes to 30 seconds.

Old: 317.663u 0.685s 5:18.34 100.0% 198+360k 0+19io 1009pf+0w
New: 7.330u 23.841s 0:31.17 100.0% 198+360k 0+250522io 4pf+0w

See code review for how we got this. tl;dr: netbsd move brelse
into bwrite and we picked up msdos code after that, but not the
move. That change should be picked up later.

Sponsored by: Netflix
Reviewed by: emaste
MFC After: 1 day (13.2 is coming fast)
Differential Revision: https://reviews.freebsd.org/D39025

16 months agonet.inet6.ip6.log_interval: use ppsratecheck(9) internally
Pawel Biernacki [Mon, 13 Mar 2023 16:39:20 +0000 (16:39 +0000)]
net.inet6.ip6.log_interval: use ppsratecheck(9) internally

Reported by: mjg
Differential Revision: https://reviews.freebsd.org/D38758

16 months agonetinet6: allow disabling excess log messages
Pawel Biernacki [Mon, 13 Mar 2023 16:36:11 +0000 (16:36 +0000)]
netinet6: allow disabling excess log messages

RFC 4443 specifies cases where certain packets, like those originating from
local-scope addresses destined outside of the scope shouldn't be forwarded.
The current practice is to drop them, send ICMPv6 message where appropriate,
and log the message:

cannot forward src fe80:10::426:82ff:fe36:1d8, dst 2001:db8:db8::10, nxt
58, rcvif vlan5, outif vlan2

At times the volume of such messages cat get very high. Let's allow local
admins to disable such messages on per vnet basis, keeping the current
default (log).

Reported by: zarychtam@plan-b.pwste.edu.pl
Reviewed by: zlei (previous version), pauamma (docs)
Differential Revision: https://reviews.freebsd.org/D38644

16 months agotftp: Add test cases for URL mode.
Dag-Erling Smørgrav [Mon, 13 Mar 2023 16:16:10 +0000 (16:16 +0000)]
tftp: Add test cases for URL mode.

Sponsored by: Klara, Inc.
Reviewed by: asomers
Differential Revision: https://reviews.freebsd.org/D39014

16 months agodtrace/powerpc: Remove accidental commented out line
Justin Hibbits [Mon, 13 Mar 2023 15:33:17 +0000 (11:33 -0400)]
dtrace/powerpc: Remove accidental commented out line

Fixes: 3e1155ade1b

16 months agonetinet: Disallow unspecified addresses in ICMP-embedded packets
Mark Johnston [Mon, 13 Mar 2023 14:45:56 +0000 (10:45 -0400)]
netinet: Disallow unspecified addresses in ICMP-embedded packets

Reported by: glebius
Reported by: syzbot+981c528ccb5c5534dffc@syzkaller.appspotmail.com
Reviewed by: tuexen, glebius
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D38936

16 months agoepair: Remove unneeded includes and sort some of the rest
Mark Johnston [Mon, 13 Mar 2023 13:27:47 +0000 (09:27 -0400)]
epair: Remove unneeded includes and sort some of the rest

No functional change intended.

MFC after: 1 week

16 months agosmr: Remove the return value from smr_wait()
Mark Johnston [Tue, 7 Feb 2023 21:38:07 +0000 (16:38 -0500)]
smr: Remove the return value from smr_wait()

This is supposed to be a blocking version of smr_poll(), so there's no
need for a return value.  No functional change intended.

MFC after: 1 week

16 months agosendfile tests: Mount filesystems under the test workdir
Mark Johnston [Sun, 12 Mar 2023 18:50:14 +0000 (14:50 -0400)]
sendfile tests: Mount filesystems under the test workdir

Otherwise they can't be run in parallel as they share a mount point.

MFC after: 1 week

16 months agozfs: Use .section .rodata instead of .rodata on FreeBSD
Dimitry Andric [Sat, 25 Feb 2023 00:45:48 +0000 (01:45 +0100)]
zfs: Use .section .rodata instead of .rodata on FreeBSD

In commit 0a5b942d4 the FreeBSD SECTION_STATIC macro was set to
".rodata". This assembler directive is supported by LLVM (as a
convenience alias for ".section .rodata") by not by GNU as.

This caused the FreeBSD builds that are done with gcc to fail.
Therefore, use ".section .rodata" instead, similar to the other
asm_linkage.h headers.

[mjg: cherry-picked from upstream zfs bf1bec394e715de9f7ac4a54b5b1b884d7e41a32
 to unbreak gcc12 build]

Reviewed-by: Mateusz Guzik <mjguzik@gmail.com>
Reviewed-by: Attila Fülöp <attila@fueloep.org>
Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Signed-off-by: Dimitry Andric <dimitry@andric.com>
Closes #14526

16 months agovm: consistently prefix fault helpers with vm_fault_
Mateusz Guzik [Sun, 12 Mar 2023 18:38:29 +0000 (18:38 +0000)]
vm: consistently prefix fault helpers with vm_fault_

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D39029

16 months agotests: fix python parsing of netlink nested attributes
Alexander V. Chernikov [Mon, 13 Mar 2023 10:17:36 +0000 (10:17 +0000)]
tests: fix python parsing of netlink nested attributes

MFC after: 2 weeks

16 months agoarm64: Hyper-V: Add vPCI and Mellanox driver modules into build
Wei Hu [Mon, 13 Mar 2023 02:55:04 +0000 (02:55 +0000)]
arm64: Hyper-V: Add vPCI and Mellanox driver modules into build

These changes in conf and std.hyperv files got missed in previous commit.
Reviewed by: whu
Tested by: whu
Obtained from: Souradeep Chakrabarti <schakrabarti@microsoft.com>
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D38529

16 months agoDocument gethostbyname_r's public exposure in 6.2.
David E. O'Brien [Mon, 13 Mar 2023 01:43:05 +0000 (18:43 -0700)]
Document gethostbyname_r's public exposure in 6.2.

16 months agoLook in getlocalbase() for the calendar-data package data
David E. O'Brien [Wed, 8 Mar 2023 03:51:27 +0000 (19:51 -0800)]
Look in getlocalbase() for the calendar-data package data

Fix d20d6550187a95a78bb532909aad8ef7ac62be66 where getlocalbase()
wasn't used to fill out the printf(3) format of _PATH_INCLUDE_LOCAL.

Differential Revision: https://reviews.freebsd.org/D38975
Reviewed by: imp

16 months agoRELNOTES: Add an entry for NFS server support in vnet prisons
Rick Macklem [Sun, 12 Mar 2023 21:55:46 +0000 (14:55 -0700)]
RELNOTES: Add an entry for NFS server support in vnet prisons

16 months agolib/csu: do not compile the body of handle_static_init() for PIC build at all
Konstantin Belousov [Sun, 12 Mar 2023 01:45:37 +0000 (03:45 +0200)]
lib/csu: do not compile the body of handle_static_init() for PIC build at all

The referenced symbols that provide init array boundaries are weak,
hidden, and undefined.  The code that iterates over that arrays is not
used for the case when libc is compiled as dso.

This should fix linking with ld.bfd.

Sponsored by: The FreeBSD Foundation
MFC after: 3 weeks

16 months agolibc/csu: add powerpcspe
Konstantin Belousov [Sun, 12 Mar 2023 09:59:16 +0000 (11:59 +0200)]
libc/csu: add powerpcspe

Reported and tested by: alfredo
Sponsored by: The FreeBSD Foundation
MFC after: 3 weeks

16 months agorc.d: Fix NFS server startup scripts to enable vnet prison use
Rick Macklem [Sun, 12 Mar 2023 21:34:25 +0000 (14:34 -0700)]
rc.d: Fix NFS server startup scripts to enable vnet prison use

Now that commit cbbb22031f9b is in main,
it is possible to run nfsd(8), nfsuserd(8), mountd(8),
gssd(8) and rpc.tlsservd(8) in an appropriately configured vnet
prison if the "allow.nfsd" option is specified in jail.conf.

This patch fixes the rc scripts for this.
Mostly just replaces the "nojail" KEYWORD with "nojailvnet",
but also avoids setting vfs.nfsd.srvmaxio in a prison, since it
must be set outside of the prisons and applies to all
nfsd(8) instances.

Reviewed by: jamie
MFC after: 3 months
Differential Revision: https://reviews.freebsd.org/D38809

16 months agovfs: whack leftover cn_origflags
Mateusz Guzik [Sun, 12 Mar 2023 19:06:46 +0000 (19:06 +0000)]
vfs: whack leftover cn_origflags

Unused since 5b5b7e2ca2fa9a24 ("vfs: always retain path buffer after lookup")

Reported by: dchagin

16 months agodaemon: move variables into struct daemon_state
Ihor Antonov [Sun, 12 Mar 2023 16:07:34 +0000 (10:07 -0600)]
daemon: move variables into struct daemon_state

The fact that most of the daemon's state is stored on the stack
of the main() makes it hard to split the logic smaller chunks.
Which in turn leads to huge main func that does a a lot of things.
struct log_params existed because some variables need to be passed
into other functions together.

This change renames struct log_params into daemon_state
and moves the rest of the variables into it. This is a necessary
preparation step for further refactroing.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/687

16 months agopowerpc/pmap: Add pmap_sync_icache() for radix pmap
Justin Hibbits [Sun, 12 Mar 2023 15:46:57 +0000 (11:46 -0400)]
powerpc/pmap: Add pmap_sync_icache() for radix pmap

DTrace pid provider writes to user space to set breakpoints.  Failing to
sync the icache can lead to SIGTRAP.  Radix pmap is the only one missing
a pmap_sync_icache() method, so the pid provider would only potentially
crash a process on a POWER9 or later system.

16 months agopowerpc: enable ZFS on 32 bit powerpc/powerpcspe
Alfredo Dal'Ava Junior [Sun, 12 Mar 2023 06:20:11 +0000 (03:20 -0300)]
powerpc: enable ZFS on 32 bit powerpc/powerpcspe

Enable ZFS on powerpc 32 bit since it appears to build and work
correctly.

MFC after: 3 weeks
Relnotes: yes

16 months agolibc/csu: rename ignore_init.c to libc_start1.c
Konstantin Belousov [Sat, 11 Mar 2023 22:56:46 +0000 (00:56 +0200)]
libc/csu: rename ignore_init.c to libc_start1.c

The current name was a historical curiosity that started when init array
support was added, and then the file appeared a convenient place for the
addition of the MI common code to csu.  It is now referenced by name in
single place and the rename is easy, so do it.

Sponsored by: The FreeBSD Foundation
MFC after: 3 weeks

16 months agolibc: move declaration of 'char **environ' to common private header
Konstantin Belousov [Sun, 6 Nov 2022 04:08:36 +0000 (06:08 +0200)]
libc: move declaration of 'char **environ' to common private header

Suggested by: imp
Reviewed by: markj
Tested by: markj (aarch64)
Sponsored by: The FreeBSD Foundation
MFC after: 3 weeks
Differential revision: https://reviews.freebsd.org/D37220

16 months agox86: microoptimize static PIE startup
Konstantin Belousov [Tue, 1 Nov 2022 01:42:50 +0000 (03:42 +0200)]
x86: microoptimize static PIE startup

Do not call CPUID on each ireloc, instead call it once and cache
results, similar to how it is done on powerpc64.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 3 weeks
Differential revision: https://reviews.freebsd.org/D37220

16 months agocsu: move common code to libc
Konstantin Belousov [Sun, 30 Oct 2022 23:47:44 +0000 (01:47 +0200)]
csu: move common code to libc

Why? Most trivial point, it shaves around 600 bytes from the dynamic
binaries on amd64. Less trivial, the removed code is no longer part of
the ABI, and we can ship updates to it with libc updates. Right now most
of the csu is linked into the binaries and require us to do somewhat
tricky ABI compat when it needs to change. For instance, the init_array
change would be much simpler and does not require note tagging if we
have init calling code in libc.

This could be improved more, by splitting dynamic and static
initialization. For instance, &_DYNAMIC tests can be removed then.
Such change, nonetheless, would require building libc three times.
I left this for later, after this change stabilizes, if ever.

Reviewed by: markj
Discussed with: jrtc27 (some objections, see the review), imp
Tested by: markj (aarch64)
Sponsored by: The FreeBSD Foundation
MFC after: 3 weeks
Differential revision: https://reviews.freebsd.org/D37220

16 months agovm: avoid lock upgrade if possible in vm_fault_next
Mateusz Guzik [Sat, 11 Mar 2023 20:57:24 +0000 (20:57 +0000)]
vm: avoid lock upgrade if possible in vm_fault_next

In my tests during buildkernel fs->m was always NULL at that stage.

Note the change has no impact on vm obj contention during said workload.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D39027

16 months agorc.conf.5: a stray whitespace removed
Maxim Konovalov [Sat, 11 Mar 2023 21:08:04 +0000 (21:08 +0000)]
rc.conf.5: a stray whitespace removed

PR: 270124

16 months agonetmap: get rid of WNA() macro
Vincenzo Maffione [Sat, 11 Mar 2023 17:19:01 +0000 (17:19 +0000)]
netmap: get rid of WNA() macro

MFC after: 7 days

16 months agodtrace/powerpc: "Fix" stack traces across trap frames
Justin Hibbits [Sat, 11 Mar 2023 16:30:00 +0000 (11:30 -0500)]
dtrace/powerpc: "Fix" stack traces across trap frames

In function boundary tracing the link register is not yet saved to the
save stack location, so the save point contains whatever the previous
'lr' save was, or even garbage, at the time the trap is taken.  Address
this by explicitly loading the link register from the trap frame instead
of the stack, and propagate that out.

16 months agodtrace/powerpc: Adjust AFRAMES for fbt and profile
Justin Hibbits [Sat, 11 Mar 2023 16:23:38 +0000 (11:23 -0500)]
dtrace/powerpc: Adjust AFRAMES for fbt and profile

FBT_AFRAMES was skipping over too many frames, while PROFILE_AFRAMES was
skipping over too few.  Adjust them empirically.

16 months agophyp_llan: Mechanically convert to IfAPI
Justin Hibbits [Sat, 11 Mar 2023 16:25:25 +0000 (11:25 -0500)]
phyp_llan: Mechanically convert to IfAPI

Sponsored by: Juniper Networks, Inc.

16 months agodtsec: Complete mechanical conversion to IfAPI
Justin Hibbits [Tue, 7 Mar 2023 20:41:38 +0000 (15:41 -0500)]
dtsec: Complete mechanical conversion to IfAPI

Some changes were missed in 0083fc5c76.

Sponsored by: Juniper Networks, Inc.

16 months agorc.conf.5: fix typo of route6d that I introduced while nitpicking
Ceri Davies [Sat, 11 Mar 2023 14:56:40 +0000 (14:56 +0000)]
rc.conf.5: fix typo of route6d that I introduced while nitpicking

16 months agorc.conf.5: dhclient came from OpenBSD, but now isn't the OpenBSD client
Ceri Davies [Sat, 11 Mar 2023 14:54:11 +0000 (14:54 +0000)]
rc.conf.5: dhclient came from OpenBSD, but now isn't the OpenBSD client

16 months agovm: read-locked fault handling for backing objects
Mateusz Guzik [Tue, 7 Mar 2023 20:56:54 +0000 (20:56 +0000)]
vm: read-locked fault handling for backing objects

This is almost the simplest patch which manages to avoid write locking
for backing objects, as a result mostly fixing vm object contention
problems.

What is not fixed:
1. cacheline ping pong due to read-locks
2. cacheline ping pong due to pip
3. cacheling ping pong due to object busying
4. write locking on first object

On top of it the use of VM_OBJECT_UNLOCK instead of explicitly tracking
the state is slower multithreaded that it needs to be, done for
simplicity for the time being.

Sample lock profiling results doing -j 104 buildkernel on tmpfs:
before:
71446200 (rw:vmobject)
14689706 (sx:vm map (user))
4166251 (rw:pmap pv list)
2799924 (spin mutex:turnstile chain)

after:
19940411 (rw:vmobject)
8166012 (rw:pmap pv list)
6017608 (sx:vm map (user))
1151416 (sleep mutex:pipe mutex)

Reviewed by: kib
Reviewed by: markj
Tested by: pho
Differential Revision: https://reviews.freebsd.org/D38964

16 months agovm: add VM_OBJECT_UNLOCK
Mateusz Guzik [Tue, 7 Mar 2023 20:47:44 +0000 (20:47 +0000)]
vm: add VM_OBJECT_UNLOCK

Reviewed by: kib
Reviewed by: markj
Tested by: pho
Differential Revision: https://reviews.freebsd.org/D38964