Commit graph

21017 commits

Author SHA1 Message Date
John Baldwin
22956bc9dc pac: Consistently use item count as the first argument to calloc
Reported by:	GCC 14 -Wcalloc-transposed-args
2025-01-03 10:44:27 -05:00
John Baldwin
f94513a3a3 pac: Use strdup and asprintf in place of dubious string building
GCC 14 warned about transposed arguments to calloc, but these cases
are better served by more abstract string functions.
2025-01-03 10:44:22 -05:00
Mark Johnston
526bd072b3 syslogd: Fix resource leaks
- nvlist_append_nvlist_array() makes a copy of the input nvlist, so the
  pattern of nvlist_append_nvlist_array(... cfline(...)) would leak
  memory and descriptors.  Pass the entire config nvlist to cfline()
  instead since this is needed for a future change.
- In parse_action(), free the linked list returned by getaddrinfo().
- Remove some checks at the beginning of close_filed().  For some log
  types we'll always have f->f_file == -1, in which case we wouldn't
  release other resources, such as forwarding sockets.
- After converting a filed to an nvlist, free the filed resources.

Fixes:	2567168dc4 ("syslogd: Refresh configuration using libcasper")
Reviewed by:	jfree
Differential Revision:	https://reviews.freebsd.org/D48250
2025-01-03 01:51:19 +00:00
Mark Johnston
1da99b479a syslogd tests: Permit starting syslogd with multiple -b options 2025-01-03 01:50:59 +00:00
Mark Johnston
3fb2371efd syslogd tests: Use atf_check when sending SIGHUP to syslogd 2025-01-03 01:50:39 +00:00
Ruslan Bukin
9be0058ea0 riscv vmm: virtual timer support.
Add a virtual timer implementation based on SBI Time extension.
This is needed for Eswin EIC7700 SoC which does not include the newer SSTC
extension.

Timer interrupt pending bit (STIP) could not be cleared in the guest system,
so rework interrupts handling: add new "interrupts_pending" field. Use it
for timer interrupt only for now, but later we can extend to store all
pending interrupts (Timer, IPI and External).

With this I'm able to boot FreeBSD (SMP) guest on HiFive Premier P550,
which is the first real hardware with RISC-V 'H'-spec included.

Differential Revision: https://reviews.freebsd.org/D48133
2025-01-02 16:02:39 +00:00
Kyle Evans
3d0a0dda3a pkg: finish adding the ECC signer and signature type bits
Signature types need to be parsed out of the key/signature information
that we are presented with from the files we download.  We use that to
understand whicher signer we need to dispatch to.

The ECC signer is more-or-less lifted from pkg(8), with some changes to
slim it down for pkg(7).

Reviewed by:	bapt
Differential Revision:	https://reviews.freebsd.org/D48108
2025-01-01 15:11:24 -06:00
Kyle Evans
2e065d74a5 pkg: add a pkgsign_verify_data callback
This will be used to verify raw payloads, as if signed by pkg-key(8).
It will be used specifically in pkg(7) to verify .pubkeysig as published
by poudriere.

Amend verify_pubsignature() now to use it.  For the RSA signer, we need
to verify using a sha256 of the data instead of the data itself.

Reviewed by:	bapt
Differential Revision:	https://reviews.freebsd.org/D48109
2025-01-01 15:11:23 -06:00
Kyle Evans
2ecfc040a0 pkg: refactor out a pkg_read_fd()
We already have to do this for reading the pubkey, just pull it out for
other uses.  The ECC signer will use this to verify the bootstrap if
the PUBKEY mechanism is used.

Reviewed by:	bapt, emaste
Differential Revision:	https://reviews.freebsd.org/D48107
2025-01-01 15:11:23 -06:00
Kyle Evans
5862580ded pkg: abstract rsa out behind a pkgsign API
This mirrors a change we made in pkg(8), and will be used to next add
another signer that does ECC.

Reviewed by:	bapt, emaste
Differential Revision:	https://reviews.freebsd.org/D48106
2025-01-01 15:11:23 -06:00
Kyle Evans
2629e90dd0 pkg: pull rsa bits out of pkg.c
We'll eventually add a pkgsign abstraction over these similar to how we do
in pkg(8), but start by isolating these parts.

Reviewed by:	bapt, emaste
Differential Revision:	https://reviews.freebsd.org/D48105
2025-01-01 15:11:22 -06:00
Ed Maste
1f31d43742 makefs: Fix cd9660 duplicate directory names
Previously we could create cd9660 images with duplicate short (level 2)
names.

cd9660_level2_convert_filename used a 30-character limit (for files and
directories), not including the '.' separator.  cd9660_rename_filename
used a 31-character limit, including the '.'.  Directory names 31
characters or longer (without '.') were shortened to 30 characters, and
if a collision occurred cd9660_rename_filename uniquified them starting
with the 31st character.  Unfortunately the directory record's name_len
was already set, so the unique part of the name was stripped off.

Directories are up to 31 d-characters (i.e., A-Z 0-9 and _); there is no
provision for a '.' in a directory name.  Increase the name length limit
to 31 for directories, and exclude '.'s.

This name mapping and deduplication code is still fragile and convoluted
and would beenfit from a more holistic effort.

PR:		283238, 283112
Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48251
2024-12-30 14:48:44 -05:00
John Baldwin
365b89e8ea nvmf: Switch several ioctls to using nvlists
For requests that handoff queues from userspace to the kernel as well
as the request to fetch reconnect parameters from the kernel, switch
from using flat structures to nvlists.  In particular, this will
permit adding support for additional transports in the future without
breaking the ABI of the structures.

Note that this is an ABI break for the ioctls used by nvmf(4) and
nvmft(4).  Since this is only present in main I did not bother
implementing compatability shims.

Inspired by:	imp (suggestion on a different review)
Reviewed by:	imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D48230
2024-12-30 13:52:21 -05:00
Pat Maddox
10fa3f2518 certctl: Set METALOG ownership to root:wheel
This sets the correct ownership values when building base.txz

PR:		283340
Reviewed by:	allanjude
Pull request:	https://github.com/freebsd/freebsd-src/pull/1550

Signed-off-by: Pat Maddox <pat@patmaddox.com>
2024-12-30 12:32:23 -05:00
Ed Maste
788e1eb7c1 makefs: Remove impossible if condition
This test is inside the else block for `if (*oldname == '.')`, so
*oldname cannot be '.' here.

Reviewed by:	kevans
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48243
2024-12-29 15:28:32 -05:00
Rick Macklem
295934eaa9 exports.5: Document the current behavior of -alldirs
Commit 07cd69e272 adds a new "-a" mountd option,
which changes the behavior of mountd when file systems
are exported via -alldirs.

This patch updates the man page to reflect the actual
behavior when -alldirs is used when mountd is started
with/without -a.  Prior to the above commit, exports(5)
documented that, when -alldirs was specified, the exports
line would fail unless the directory was a server file
system mount point.  This behavior was only documented
in the Examples section and has not been implemented
since a change between FreeBSD 1 and FreeBSD 2 was done.

This is a contents change.

PR:	282995
Reviewed by:	markj
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D48139
2024-12-28 13:51:08 -08:00
Rick Macklem
6db916d21a mound.8: Document the new -a command line option
Commit 07cd69e272 adds a new "-a" mountd option.

This patch updates the man page for it.

This is a content change.

PR:	282995
Reviewed by:	gbe (manpages)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D48138
2024-12-28 13:30:56 -08:00
Rick Macklem
07cd69e272 mountd.c: Define a new -a command line option
Bugzilla PR#282995 reported that, when a file system was
exported with the "-alldirs" flag, the export succeeded even
if the directory path was not a server file system mount point.

This behaviour for "-alldirs" was only documented in the
Example section of exports(5) and had not been enforced
since FreeBSD2. (A patch applied between FreeBSD1 and
FreeBSD2 broke the check for file system mount point.)

Since the behaviour of allowing the export has existed since
FreeBSD2, the concensus on a mailing list was that it would
be a POLA violation to change it now.
Therefore, this patch adds a new "-a" mountd command line
option to enforce a check for the exported directory being a
server file system mount point.

PR:	282995
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D48137
2024-12-28 13:24:51 -08:00
Ed Maste
2e09cef8dc makefs: Fix cd9660 filename buffer maximum length
The maximum length is 30 characters for name and extension, two
separators (. and ;) and 5 characters for file version from 1 to 32767,
which is 37 characters.  Add one for the null term as we treat these
buffers as C strings.

This is not an issue in practice, as the file version is always 1 in
makefs.

While here, drop `_WITH_PADDING` from the macro name and update the
previously-unused ISO_FILENAME_MAXLENGTH for the corrected length.
A 0x00 padding byte is used by ISO9660 when needed for alignment, which
can be the null byte at the end of the string.

Use sizeof where appropriate.

Reviewed by:	kevans
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48193
2024-12-26 11:44:36 -05:00
Craig Leres
ca7e12f7df bsdinstall zfsboot: Add an option to edit the ZFS pool creation options
This allows the default options (-O compress=lz4 -O atime=off) to be
overridden, before the ZFS boot pool is created. For example, to set the
compression algorithm to something different.

Reviewed by:	jhb, dim
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D47478
2024-12-26 15:44:24 +01:00
Ed Maste
b45f84cc62 makefs: Exit with error if writing cd image fails
Obtained from:	OpenBSD c8f48d9b1ea9
Sponsored by:	The FreeBSD Foundation
2024-12-23 11:03:36 -05:00
Michal Scigocki
8cc248fb92 syslogd: Add rfc3164-strict format option
The syslogd bsd/rfc3164 message format does not strictly conform to the
format recommended in RFC 3164 when syslog messages are forwarded from
remote hosts.

The new rfc3164-strict format generates messages that conform with the
RFC 3164 recommended format. The existing format is maintained for
backwards compatibility.

PR:		220246
Reviewed by:	markj
MFC after:	3 weeks
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1536
2024-12-23 15:46:14 +00:00
Michal Scigocki
65c61840ee syslogd: Add syslog relayed message format tests
Reviewed by:	markj
MFC after:	3 weeks
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1536
2024-12-23 15:45:59 +00:00
Michal Scigocki
ee75c991ac syslogd: Add syslog forwarded message format tests
Reviewed by:	markj
MFC after:	3 weeks
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1536
2024-12-23 15:45:45 +00:00
Michal Scigocki
66a022a30d syslogd: Add syslog basic message format tests
RFC 3164 and RFC 5424 syslog message format tests and minor refactor of
existing tests to reuse components in new tests.

Reviewed by:	markj
MFC after:	3 weeks
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1536
2024-12-23 15:45:12 +00:00
Michal Scigocki
aa94868f5e syslogd: Remove is_exclusive metadata from tests
- Tests have been updated to use "jail" execution environment,
  is_exclusive="true" is no longer required.
- tests/Makefile update to style.Makefile(5).

Reviewed by:	markj
MFC after:	3 weeks
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1536
2024-12-23 15:44:17 +00:00
Ed Maste
2069f6ecb1 makefs: Crudely fix a sprintf warning
Reviewed by:	kevans
Obtained from:	OpenBSD d95291fdb2dc
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48178
2024-12-23 10:30:03 -05:00
Richard Scheffenegger
31034044ff tcp: cleanup of nits after use of accessor tcp_get_flags
Remove unneeded th_x2 initalization, use named constants
instead of magic numbers (fixing one oversight) and add
some line breaks. Expand one man page slightly.

No functional change intended.

Reviewed By: tuexen, cc
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D48065
2024-12-19 16:37:24 +01:00
Ruslan Bukin
a7bf553d17 riscv vmm: add SSTC extension check.
Check if RISC-V SSTC is available and advertise to the guest.

This is needed for Eswin EIC7700 that does not include SSTC.

As we don't have a mechanism for reporting extension presence
from the kernel to userspace, then use vm_cap_type for now.

Reviewed by: mhorne, markj
Differential Revision: https://reviews.freebsd.org/D48058
2024-12-17 10:35:44 +00:00
Olivier Certner
e87848a815
mountd(8): Allow to pass {NGROUPS_MAX} + 1 groups
NGROUPS_MAX is just the minimum maximum of the number of allowed
supplementary groups.  The actual runtime value may be greater.  Allow
more groups to be specified accordingly (now that, a few commits ago,
nmount(2) has been changed similarly).

To this end, we just allocate once and for all a static array called
'tmp_groups' big enough to hold {NGROUPS_MAX} + 1 groups (the maximum
number of supplementary groups plus the effective GID, which we store in
a variable named 'tngroups_max' to avoid confusion with the kernel
variable 'ngroups_max' holding only the maximum number of
*supplementary* groups) in main() and use this temporary space in
get_exportlist_one(), do_opt() and parsecred().  Doing so in passing
fixes a (benign) memory leak in case "-maproot" and/or "-mapall" were
specified multiple times and the first option comprised more than
SMALLNGROUPS.

parsecred() does not use 'cr_smallgrps' anymore, but we have kept
'cr_smallgrps'/SMALLNGROUPS as 'struct expcred' is also included in
'struct exportlist' and 'struct grouplist', and thus this preallocated
field still results in an optimization for the common case of small
number of groups (although its real impact is probably negligible and
arguably was not worth the trouble).

While here, in do_mount(), remove some unnecessary groups array
allocation and copying.

Reviewed by:    rmacklem (older version)
Approved by:    markj (mentor)
MFC after:      2 weeks
Relnotes:       yes
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D47016
2024-12-16 15:42:31 +01:00
Olivier Certner
a20d50245f
mountd(8): parsecred(): Re-order operations for clarity
No functional change (intended).

Reviewed by:    rmacklem (older version)
Approved by:    markj (mentor)
MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D47015
2024-12-16 15:42:31 +01:00
Olivier Certner
0b011b5cdd
mountd(8): parsecred(): Remove comment on non-existent bug
'name' can never be NULL, as it is equal to 'names' and 'namelist',
which was passed by do_cred() only if the actual parameter wasn't NULL.

Reviewed by:    rmacklem
Approved by:    markj (mentor)
MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D47014
2024-12-16 15:42:31 +01:00
Olivier Certner
7f7f3b6caf
mountd(8): parsecred(): Groups limit: NGROUPS_MAX => NGROUPS_MAX + 1
Lift this unnecessary limitation.

Approved by:    markj (mentor)
MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D46921
2024-12-16 15:42:30 +01:00
Olivier Certner
2ef608de90
exports(5): -maproot, -mapall: Explain the fallback on no group
Reviewed by:    rmacklem (older version)
Approved by:    markj (mentor)
MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D47012
2024-12-16 15:42:30 +01:00
Olivier Certner
bdc259ef38
mountd(8): parsecred(): Fallback to "nogroup" or GID_NOGROUP
In the 'uid:gid:gid:...' case (for '-maproot' or '-mapall'), if no GID
is specified at all (i.e., input is of the form 'uid:', with the colon
at the end), mountd(8) would pass credentials with an empty array of
groups to the kernel.

For security reasons, we have put in place a kernel fallback a while
ago, which is to use the single group GID_NOGROUP (see commits
cfbe7a62dc ("nfs, rpc: Ensure kernel credentials have at least one
group") and 5169d4307e ("nfs: Fallback to GID_NOGROUP on no groups")).
Here, as we are in userland, we first try to find the GID number
corresponding to "nogroup", and only then fall back to GID_NOGROUP, as
nfsuserd(8) does.

Approved by:    markj (mentor)
MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D47011
2024-12-16 15:42:30 +01:00
Olivier Certner
f2d2318faf
mountd(8): parsecred(): Remove "duplicate compression"
No functional change (intended).

This code dates back to 4.4BSD, became wrong after some getgrouplist()
(nssswitch-related) change in 2007, was fixed only in 2020 and since
then underwent cosmetic changes.

It is likely that in fact it never served any useful purpose in FreeBSD,
except perhaps at the very beginning.  It's most probably not the case
today: NFS credentials are normally only used to check for file
accesses, whose group is checked against all groups of a credentials
indiscriminately (except for the real GID).  Consequently, having
a single duplicate, which the code would actually remove only if in the
first supplementary group slot, doesn't change behavior.  Moreover, we
are going to regain one slot in a subsequent commit.

Discussed with: rmacklem
Approved by:    markj (mentor)
MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D46920
2024-12-16 15:42:29 +01:00
Olivier Certner
ae22a4bb74
mountd(8): parsecred(): uid:gid:... loop: Simplify a bit
No functional change intended.

Reviewed by:    rmacklem (older version)
Approved by:    markj (mentor)
MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D46919
2024-12-16 15:42:29 +01:00
John Baldwin
34fbc9e421 cxgbetool.8: Consistently use .Cm for loader tunables
Sponsored by:	Chelsio Communications
2024-12-10 15:34:10 -05:00
John Baldwin
9065218823 cxgbe: Tidy TOE tunables under hw.cxgbe
- Only two of these tunables are used for RATELIMIT without
  TCP_OFFLOAD.

- Mark t4_tmr_idx_ofld and t4_pktc_idx_ofld static.

- Move hw.cxgbe.cop_managed_offloading under hw.cxgbe.toe since it is
  specific to TOE.

Reviewed by:	np
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D47765
2024-12-10 15:32:07 -05:00
Damjan Jovanovic
cb21fa3d0d ppp: Enable support for EIM NAT
Enable support for endpoint-independent mapping ("full cone NAT") via
Libalias's UDP NAT.

Reviewed by:    igoro, thj
Differential Revision:  https://reviews.freebsd.org/D46689
2024-12-06 09:22:51 +00:00
Robert Wing
6830340cfa fstyp: search for file system headers with the largest offset first
fstyp can misidentify a UFS file system as MS-DOS if the device was
repurposed from MS-DOS to UFS via newfs.

This happens for the following reasons:
    - the header for MS-DOS begins at offset 0
    - the superblock for UFS begins at offset 64k, 8k, 0k, or 256k
    - newfs does not clear the area in front of UFS's superblock,
      leaving the MS-DOS header intact.
    - fstyp searches for file system headers alphabetically

To avoid this misidentification, have fstyp search for file system
headers with the largest offset first instead of alphabetically.

The implemented fix was suggested by reporter, Richard M. Kreuter.

PR:             252787
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D47855
2024-12-03 23:45:09 -09:00
Jose Luis Duran
f7cf62cf72 pw: tests: add a test for -M with a pre-existing home directory
Previous versions of pw(8) wouldn't chmod the home directory if it
already existed prior to user creation, rendering adduser(8) -M
ineffective in some cases.  Add a test to cover that situation.

PR:		280099
Reviewed by:	kevans
2024-12-01 13:10:35 -06:00
Kyle Evans
6a7238fd7c pw: set the user's home directory mode if it existed
The adduser(8) prompt allows one to set the mode of a new home
directory, but pw(8) doesn't honor the -M mode if the home directory
already exists at creation time.  It doesn't seem to make sense to
ignore the mode (which may lead to a security issue on the system being
configured) when we'll happily chown an existing directory, so fix the
inconsistency.

PR:		280099
Reviewed by:	des, jlduran (previous version)
Differential Revision:	https://reviews.freebsd.org/D46443
2024-12-01 13:08:31 -06:00
Dmitry Morozovsky
7aa7f4b5c3 services: fix typo ucp -> udp
Fix two proto name typos

MFC after:	2 weeks
2024-12-01 00:53:47 +03:00
Mark Johnston
fe29114148 syslogd: Fix issues reported by gcc
- When forwaring a message, don't assume that f->f_num_addr_fds > 0.
- Avoid calling free() on a stack-allocated object.

Fixes:	4ecbee2760 ("syslogd: Open forwarding socket descriptors")
Fixes:	f4b4a10abb ("syslogd: Move selector parsing into its own function")

Reviewed by:	jfree
Differential Revision:	https://reviews.freebsd.org/D47844
2024-11-30 18:52:34 +00:00
Richard Scheffenegger
347dd0539f tcp: add TH_AE capabilities to ppp and pf
Add support for the AE Flag in the TCP header to pf and ppp.
Commonalize to the use of "E"(ECE), "W"(CWR) and "e"(AE)
for the TCP header flags, in line with tcpdump.

Reviewers: kp, cc, tuexen, cy, #transport!
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D47106
2024-11-29 10:04:31 +01:00
Richard Scheffenegger
0fc7bdc978 tcp: extend the use of the th_flags accessor function
Formally, there are 12 bits for TCP header flags.
Use the accessor functions in more (kernel) places.

No functional change.

Reviewed By: cc, #transport, cy, glebius, #iflib, kbowling
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D47063
2024-11-29 09:48:23 +01:00
Li-Wen Hsu
af2015b01f
newsyslog.conf(5): Remove duplicate word
Reported by:	jlduran
Fixes:	1f78bbb5c4 newsyslog.conf(5): Accept human unit suffix in the size filed
2024-11-29 13:00:54 +08:00
Jake Freeland
b872bb7206 syslogd: Split up basic test case
The basic case previously tested if messages are correctly logged over
UNIX, INET, and INET6 transport. This single case can be split up into
three separate cases to decrease code complexity and offer more granular
results.

Both INET and INET6 cases will be skipped if the kernel does not
support the corresponding transport.

Reviewed by:	zlei, markj
Differential Revision:	https://reviews.freebsd.org/D47650
2024-11-27 16:26:16 -06:00
Jake Freeland
8b63477e5e syslogd: Add host forwarding test
Test communication between hosts by setting up two syslogd instances,
each binded to their own addresses, and sending a message from one to
the other. The tests passes if the message was delivered and logged
successfully.

This required some tweaking to the syslogd start and stop routines so
they could handle launching multiple syslogd instances with different
runtime files.

Run the tests in jails with an isolated VNET so they don't fail due to
an address bind collision in the host's VNET.

Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D47649
2024-11-27 16:26:10 -06:00