Commit graph

286636 commits

Author SHA1 Message Date
Colin Percival e6eeac9b71 release/Makefile.vm: Add support for CW flavours
There are two "Vagrant" images right now: "Vagrant Image for VirtualBox"
and "Vagrant Image for VMWare".  Rather than listing these separately in
a CLOUDWARE list, place "VAGRANT" into a CLOUDWARE_TYPES list and then
use a VAGRANT_FLAVOURS variable to identify the two versions.  Add make
logic to allow defaults (in this case, image format and filesystem) to
be specified once for VAGRANT and inherited by both flavours.

This will make future work to add flavoured EC2 images simpler.

releng/14.0 candidate.

Discussed with:	gjb
Reviewed by:	imp
MFC after:	5 days
Sponsored by:	https://www.patreon.com/cperciva
Differential Revision:	https://reviews.freebsd.org/D41790
2023-09-28 15:18:46 -07:00
Colin Percival fcbeeb5ff4 release/Makefile.vm: Garbage collect unused bits
The cw*-package targets were introduced in February 2015 as part of
adding support for building GCE images; but GCE support was reworked
in June 2015 and the cw*-package targets were in fact never used.
Remove them.

The *_DISK variables were introduced in February 2015 as part of
adding the cloudware-install target; this was removed in May 2016 as
the cloudware images are published via the respective cloud systems
and not published as disk images via the FreeBSD FTP site.  As such,
the *_DISK variables are not unused; remove them.

releng/14.0 candidate.

Discussed with:	gjb
Reviewed by:	imp
MFC after:	5 days
Sponsored by:	https://www.patreon.com/cperciva
Differential Revision:	https://reviews.freebsd.org/D41789
2023-09-28 15:18:46 -07:00
Sergey A. Osokin 992ec09f37 bsd-family-tree: add macOS 14
MFC after:	3 days
2023-09-28 17:42:08 -04:00
Simon J. Gerraty 0f87915f43 Remove unnecessary -isystem for host
Turns out we do not need -isystem/usr/include and
it can interfere with newer toolchains.

Reviewed by:	stevek
2023-09-28 14:19:25 -07:00
John Hay d33a4ae8ba x86: Properly align interrupt vectors for MSI
MSI (not MSI-X) interrupt vectors must be allocated in groups that are
powers of 2, and the block of IDT vectors must be aligned to the size
of the request.

The code in native_apic_alloc_vectors() does an alignment check in the loop:

    if ((vector & (align - 1)) != 0)
        continue;
    first = vector;

But it adds APIC_IO_INTS to the value it returns:

    return (first + APIC_IO_INTS);

The problem is that APIC_IO_INTS is not a multiple of 32. It is 48:

As a result, a request for 32 vectors (the max supported by MSI), was
not always aligned.  To fix, check the alignment of
'vector + APIC_IO_INTS' in the loop.

PR:		274074
Reviewed by:	jhb
2023-09-28 14:08:08 -07:00
Simon J. Gerraty b45ab4b000 Move the adding of CFLAGS_LAST to bsd.sys.mk
The point of CFLAGS_LAST is to be the last thing in CFLAGS
so add it last.

For DIRDEPS_BUILD this can best be done via local.dirdeps-build.mk
which is guaranteed to be the last makefile read, but that does nothing
for non-DIRDEPS_BUILD

bsd.sys.mk is close enough to the end.

Reviewed by:	obrien
Differential Revision:	https://reviews.freebsd.org/D42001
2023-09-28 14:01:56 -07:00
Mark Johnston b6da7f2fd1 makefs/zfs tests: Add a test case which appends to a file after import
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2023-09-28 16:36:12 -04:00
Mark Johnston ef20cd33d3 makefs/zfs: Ensure that the last block of a file has the right size
When copying a file's contents into the pool, a loop copies blocks of
the maximum size (128KB), allocating space from the vdev for each block.
The space allocator rounds up to the nearest block size, but for files
larger than the maximum size, this can result in the last block having a
smaller logical size than the rest of the blocks belonging to that
dnode.  This violates some ZFS invariants when appending to that file.

Modify fs_populate_file() to use the same block size for the final
block.

Reported by:	cperciva
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2023-09-28 16:16:17 -04:00
Dag-Erling Smørgrav d9d69a6f6f split: Improve GNU compatibility.
* Like GNU split, turn autoextend back on if given -a0.
* Add a test case that verifies that -a<non-zero> turns autoextend off.
* Add a test case that verifies that -a0 turns autoextend back on.

Sponsored by:	Klara, Inc.
Reviewed by:	christos, kevans
Differential Revision:	https://reviews.freebsd.org/D42011
2023-09-28 18:30:16 +02:00
Dag-Erling Smørgrav d7399551b0 split: Further option parsing improvements.
* Whenever possible, use strtonum() to parse numeric arguments.
* Improve usefulness and consistency of error messages.
* While here, fix some type and style issues.

Sponsored by:	Klara, Inc.
Reviewed by:	christos, kevans
Differential Revision:	https://reviews.freebsd.org/D42010
2023-09-28 18:30:15 +02:00
Jake Freeland 94cae4cb33 syslogd: Do not add shutdown sockets to the kqueue
If syslogd is in secure mode, all INET sockets are shutdown. Do not
add these to the kqueue because we can't read from them.

Also, remove the listen() call when setting up sockets. Syslogd
exclusively uses SOCK_DGRAM sockets, so calling listen() is useless.

Reviewed by:	markj
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41526
2023-09-28 11:51:54 -04:00
Jake Freeland 8536447a07 syslogd: Use pipe to communicate with daemon
Previously, syslogd's daemon process would signal that it had finished
initialization using SIGALRM. In capability mode, signal delivery is not
allowed, so use a pipe to indicate that it is ready to accept messages.

Reviewed by:	markj
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41459
2023-09-28 11:51:54 -04:00
Jake Freeland 4ac6582472 syslogd: Ignore signals in sigcatch[]
Instead of blocking signals in sigcatch[], just ignore them. This frees
up some space on the proc's sigqueue.

Reviewed by:	markj
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41433
2023-09-28 11:51:54 -04:00
Jake Freeland 7428ebfe7e syslogd: Pre-open null file descriptor
Open _PATH_DEVNULL before entering capability mode. Access to /dev/null
is needed for dup2() when piping commands.

Reviewed by:	markj
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41381
2023-09-28 11:51:54 -04:00
Jake Freeland c3175a6e1c syslogd: Do not open console descriptor
Setup consfile filed for logging while Initialized is false, but do not
bother opening the console. Close console/tty descriptors after parsing,
as well. The ttymsg() function will re-open these descriptors for us.

Also, remove references to the ctty global variable since it will always
be _PATH_CONSOLE.

Reviewed by:	markj
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41380
2023-09-28 11:51:54 -04:00
Jake Freeland 5b44c24f85 syslogd: unlink() -> unlinkat()
Save basename and dirname for use in unlinkat() when removing UNIX
sockets from fs.

Reviewed by:	markj, emaste
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41379
2023-09-28 11:51:53 -04:00
Jake Freeland 3854dd52a3 syslogd: Add closelogfiles() function
The closelogfiles() function completely disassembles the global filed
list by freeing all filed components and removing them from the list.

Reviewed by:	markj
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41388
2023-09-28 11:51:53 -04:00
Jake Freeland 09080d8ec5 syslogd: Fix sizeof() styling
Use parentheses when applying sizeof() per style(9).

Reviewed by:	markj, emaste
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41376
2023-09-28 11:51:53 -04:00
Jake Freeland 8f49f83ef5 syslogd: Move action parsing into its own function
Clean up the cfline() function by moving action parsing into its own
function.

Reviewed by:	markj
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41375
2023-09-28 11:51:53 -04:00
Jake Freeland f4b4a10abb syslogd: Move selector parsing into its own function
Clean up the cfline() function by moving selector parsing into its
own function.

Reviewed by:	markj
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41374
2023-09-28 11:51:53 -04:00
Jake Freeland 688ecad8e1 syslogd: Move prop_filter allocation into function
Clean up the cfline() function by moving the prop_filter memory
allocation into the prop_filter_compile() function.

Reviewed by:	markj
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41373
2023-09-28 11:51:53 -04:00
Jake Freeland cd90f3afb7 syslogd: Do not print bad data
If errno is zero, then buf is never filled and we're printing
uninitialized data. Print the msg buffer instead to mitigate this.

Reviewed by:	markj, emaste
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41371
2023-09-28 11:51:53 -04:00
Jake Freeland bbde787c66 syslogd: Merge loops
Merge the two loops that traverse the global filed queue. Both loops'
actions are not dependent on the other, so combining them is safe.

Reviewed by:	markj
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41370
2023-09-28 11:51:53 -04:00
Jake Freeland fe233250d6 syslogd: Do not reap child processes
Use the SA_NOCLDWAIT sigaction() flag to disable the creation of
zombie processes. This leaves no reason to wait() on children, so
remove the reaping routine.

Previously, deadq entries were removed in reapchild(). Move deadq
removal into markit() after SIGKILL is sent.

Reviewed by:	markj
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41415
2023-09-28 11:51:53 -04:00
Jake Freeland 95381c0139 syslogd: Use process descriptors
Prepare for program Capsicumization by storing process descriptors
instead of pids. Signal delivery is not permitted in capability mode,
so we can use pdkill(2) to terminate child processes.

Reviewed by:	markj
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41369
2023-09-28 11:51:53 -04:00
Jake Freeland 599db1e026 syslogd: Simplify filed structure
Rearrange fields and add some comments.

Reviewed by:	markj
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41368
2023-09-28 11:51:53 -04:00
Jake Freeland 929568b9d5 syslogd: Style fixes
Reviewed by:	markj, emaste
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41367
2023-09-28 11:51:53 -04:00
Jake Freeland fcc1e1777d syslogd: Simplify property filters
* Use enums for property filter properties and comparisons.
* Rename property and comparison values.

Reviewed by:	markj
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41366
2023-09-28 11:51:53 -04:00
Jake Freeland b772f1ce14 syslogd: Clean up allowedpeer structure
* Use boolean values in validate() and struct allowedpeer.
* Remove useless peer count loop.

Reviewed by:	markj, emaste
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41365
2023-09-28 11:51:53 -04:00
Jake Freeland f30b063ee6 syslogd: Only use peerlist during flag parsing
Add logging sockets directly to the socklist, unless parsing flags. The
peerlist is still needed to temporarily hold socket information until
the configuration flags have been parsed.

It is tempting to remove the entire peerlist, but addsock() can not
determine if syslogd is in secure mode unless the flags have been
parsed.

Also, call pidfile_open() right after flag parsing so we can terminate
if another syslogd instance is already running.

Reviewed by:	markj
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41364
2023-09-28 11:51:52 -04:00
Jake Freeland 1bb61348e6 syslogd: Use boolean reload parameter for init()
Replace init()'s integer "signo" parameter with boolean "reload"
for clarity.

Reviewed by:	markj, emaste
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41416
2023-09-28 11:51:52 -04:00
Jake Freeland f804f23650 syslogd: Centralize operations into a kevent loop
Use kqueue(2) for socket I/O and signal notification. Previously,
select(2) and traditional signal handlers were being used.

This change centralizes all of the async notification delivery into a
single loop so future Capsicum sandboxing will be easier. It also
simplifies the code by removing boiler-plate cruft that comes with the
older interfaces.

Reviewed by:	Slawa Olhovchenkov, markj, emaste
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41363
2023-09-28 11:51:52 -04:00
Jake Freeland 3f8b49dd1a syslogd: Replace int with bool, where applicable
Many of syslogd's global configuration options are declared as integers
but are treated as booleans. Declare those options as booleans instead.

Reviewed by:	markj, emaste
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41362
2023-09-28 11:51:52 -04:00
Jake Freeland 8113e030f9 syslogd: Move fhead under filed struct declaration
Reviewed by:	markj, emaste
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41360
2023-09-28 11:51:52 -04:00
Jake Freeland 2d69e4c373 syslogd: Remove addfile() and free up some memory
cfline() already allocates a filed structure on the heap, so we can
avoid redundant memory allocations by skipping a second calloc() inside
addfile().

addfile() can be removed altogether since a simple STAILQ_INSERT_TAIL()
will add the filed to the global filed list.

Reviewed by:	markj, emaste
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41359
2023-09-28 11:51:52 -04:00
Jake Freeland 931d05fc08 syslogd: Read configuration outside of init loop
Move all configuration-file code outside of the initialization loop and
into its own set of functions. Create a readconfigfile() to open the
config and call parseconfigfile() to parse it.

The init() function no longer returns if there was a failure to open the
configuration file. Initialization will be finished, using the backup
logging rules: *.ERR to /dev/console and *.PANIC to all logged in users.

Reviewed by:	markj, emaste
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41358
2023-09-28 11:51:52 -04:00
Mark Johnston 518bd54167 syslogd: Fix fd type, add enum for filed types
Reviewed by:	markj, emaste
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41357
2023-09-28 11:51:52 -04:00
Olivier Certner 8d7a48d367 sysctl(8): Mention more security.bsd knobs; Refer to security(7)
Reviewed by:            mhorne, pauamma_gundo.com, emaste
MFC after:              2 weeks
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D41113
2023-09-28 12:05:47 -03:00
Olivier Certner d952820105 ptrace(2): Disabling: Describe influence of security.bsd.see_jail_proc
Reviewed by:            mhorne, emaste, pauamma_gundo.com
MFC after:              2 weeks
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D41109
2023-09-28 12:05:47 -03:00
Olivier Certner 61b6e00bee security(7): security.bsd.see*: Be more accurate
Reviewed by:            mhorne, pauamma_gundo.com
MFC after:              2 weeks
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D41108
2023-09-28 12:05:47 -03:00
Olivier Certner 845b7c8088 groupmember(9), realgroupmember(9): Impact of signature change
Reviewed by:            mhorne
MFC after:              2 weeks
MFC to:                 stable/14 releng/14.0
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40959
2023-09-28 12:05:46 -03:00
Olivier Certner ffd3ef8ee0 groupmember(), realgroupmember(): Return a bool instead of an int
Requested by:           mhorne
Reviewed by:            mhorne
MFC after:              2 weeks
MFC to:                 stable/14 releng/14.0
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40958
2023-09-28 12:05:46 -03:00
Olivier Certner 0452dd8413 cr_canseeothergids(): Policy change's manual pages impact
See previous commit that made cr_canseeothergids() use the new
realgroupmember() function, taking into account real group IDs instead
of effective ones.

PR:                     272093
Reviewed by:            pauamma_gundo.com, mhorne
MFC after:              2 weeks
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40644
2023-09-28 12:05:46 -03:00
Olivier Certner 5d9f38405a realgroupmember(9): Link to groupmember(9), document the function
Reviewed by:            bcr (older version), mhorne
MFC after:              2 weeks
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40643
2023-09-28 12:05:46 -03:00
Olivier Certner 91658080f1 cr_canseeothergids(): Use real instead of effective group membership
Using the effective group and not the real one when testing membership
has the consequence that unprivileged processes cannot see setuid
commands they launch until these have relinquished their privileges.
This is also in contradiction with how the similar cr_canseeotheruids()
works, i.e., by taking into account real user IDs.

Fix this by substituting groupmember() with realgroupmember().  While
here, simplify the code.

PR:                     272093
Reviewed by:            mhorne
MFC after:              2 weeks
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40642
2023-09-28 12:05:46 -03:00
Olivier Certner 2a2bfa6ad9 New realgroupmember()
Like groupmember(), but taking into account the real group instead of
the effective group.  Leverages the new supplementary_group_member()
function.

Reviewed by:            mhorne
MFC after:              2 weeks
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40641
2023-09-28 12:05:46 -03:00
Olivier Certner b725f232f3 groupmember(): Extract the supplementary group search in a separate function
This is in preparation for the introduction of the new realgroupmember()
function, which does the same search into supplementary groups as
groupmember().

Reviewed by:            mhorne
MFC after:              2 weeks
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40640
2023-09-28 12:05:46 -03:00
Olivier Certner e9fdd49453 prison_check(9): Bring up-to-date with hierarchical jails
Reviewed by:            bcr, emaste, pauamma_gundo.com, mhorne
MFC after:              2 weeks
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40639
2023-09-28 12:05:46 -03:00
Olivier Certner eb94f24fab p_candebug(9): cr_bsd_visible() impacts, misc fixes
Mention cr_bsd_visible(9).  Remove references to cr_canseeothergids(9)
and cr_canseeotheruids(9), as well as indirect references not
immediately useful.

Fix description of credentials checks to match reality.

Re-order errors to match code's check order.

Reviewed by:            bcr, pauamma_gundo.com
MFC after:              2 weeks
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40638
2023-09-28 12:05:46 -03:00
Olivier Certner 2ede38aff5 p_cansee(9): Bring up-to-date, misc fixes
Essentially defer to cr_cansee(9), except for the specifics.

Be more specific on the return codes.

Reviewed by:            bcr, pauamma_gundo.com
MFC after:              2 weeks
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40637
2023-09-28 12:05:46 -03:00