Commit graph

19838 commits

Author SHA1 Message Date
Mark Johnston
a9184e99af kthread: Set *newtdp earlier in kthread_add1()
syzbot reported a single boot-time crash in g_event_procbody(), a page
fault when dereferencing g_event_td.  g_event_td is initialized by the
kproc_kthread_add() call which creates the GEOM event thread:

  kproc_kthread_add(g_event_procbody, NULL, &g_proc, &g_event_td,
      RFHIGHPID, 0, "geom", "g_event");

I believe that the caller of kproc_kthread_add() was preempted after
adding the new thread to the scheduler, and before setting *newtdp,
which is equal to g_event_td.  Thus, since the first action of the GEOM
event thread is to lock itself, it ended up dereferencing a NULL
pointer.

Fix the problem simply by initializing *newtdp earlier.  I see no harm
in that, and it matches kproc_create1().  The scheduler provides
sufficient synchronization to ensure that the store is visible to the
new thread, wherever it happens to run.

Reported by:	syzbot+5397f4d39219b85a9409@syzkaller.appspotmail.com
Reviewed by:	kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D42986

(cherry picked from commit ae77041e0714627f9ec8045ca9ee2b6ea563138e)
2023-12-17 21:20:13 -05:00
Mark Johnston
c07ebf5bec kmsan: Add kmsan_check_uio()
This was handy for some ad-hoc debugging and fits in with other
kmsan_check_*() routines which operate on some kind of data container.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit be5464ae233ada46a778cc82f7107a10a7d5343b)
2023-12-14 09:44:38 -05:00
Mark Johnston
df81b15118 tty: Avoid a kernel memory discloure via kern.ttys
Four pad bytes at the end of each xtty structure were not being cleared
before being copied out.  Fix this by clearing the whole structure
before populating fields.

MFC after:	3 days
Reported by:	KMSAN

(cherry picked from commit 3c0fb026b2fc998fa9bea8aed76e96c58671aee3)
2023-12-14 09:29:15 -05:00
Brooks Davis
3ad2fd6fb1 makesyscalls: don't make syscall.mk by default
We only want to produce syscall.mk for the main syscall table so default
to not producing it (send it to /dev/null) and add a syscalls.conf to
sys/kern to trigger the creation of sys/sys/syscall.mk.  This eliminates
the need for entries in other syscalls.conf files and is a cleaner
pattern going forward.

Reviewed by:	kevans, imp
Differential Revision:	https://reviews.freebsd.org/D42663

(cherry picked from commit 54d487c4d01d68ef0ac03eae1fc574f7533d46f6)
2023-12-13 23:07:06 +00:00
Mitchell Horne
c27113379e kern_reboot(): don't clear kdb_active
It is possible to reach this function from ddb via the "reset" command.
When this happens, we don't actually exit kdb, meaning we never execute
the latter steps of kdb_break() to restore the system state (e.g.
re-enable scheduler).

Therefore, we should not clear the kdb_active flag in this function, as
the debugger is still active. Put differently, kern_reboot() is not an
authority on kdb state, and should not touch it. The original motivation
for this assignment is not clear; I have checked thoroughly and I am
convinced it is not required by any reset code.

This fixes an edge case where a panic can be triggered during reset from
ddb:
 1. Enter ddb via keyboard break sequence (KERNEL_PANICKED() == false &&
    td->td_critnest > 0)
 2. Execute the "reset" command
 3. kern_reboot() sets kdb_active = false
 4. A witness_checkorder() call via shutdown handler sees !kdb_active
    and panics

Reviewed by:	imp, markj
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D42684

(cherry picked from commit 4e78a766f607192698514d970ff4e9fa91d0482d)
2023-12-08 18:02:45 -04:00
Mitchell Horne
08b952c56b shutdown: tweak kproc/kthread shutdown check
This is to handle the case where the system has not panicked but the
debugger is active, where we still can't wait for thread termination.

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

(cherry picked from commit 960612a19f009df602a4cb008fa90a45a6e869bb)
2023-12-08 18:02:45 -04:00
Mitchell Horne
bbfd41d430 alq, siftr: add panic/debugger checks to shutdown hooks
Don't try to gracefully terminate the pkt_manager thread if the
scheduler is not running.

We should not attempt to shutdown ald if RB_NOSYNC is set, and must not
if the scheduler is stopped (the function calls wakeup()).

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

(cherry picked from commit d79a9edb5ce162c1ba49e12e5c93b894e6a25ad2)
2023-12-08 18:02:44 -04:00
Konstantin Belousov
c99f50351c vn_copy_file_range(): provide ENOSYS fallback to vn_generic_copy_file_range()
(cherry picked from commit c5405d1c850765d04f74067ebb71f57e9a26b8ea)
2023-12-05 02:43:27 +02:00
Konstantin Belousov
7dc643fe15 vn_copy_file_range(): find write vnodes on which to call the VOP
(cherry picked from commit a9bc8637690ce29496650a41d3c25e225ed22e3d)
2023-12-05 02:43:27 +02:00
Konstantin Belousov
6bed0f65fb VFS: add VOP_GETLOWVNODE()
(cherry picked from commit 4cbe4c48a7e574ec1bb919351d7a57d252b00b62)
2023-12-05 02:43:27 +02:00
Konstantin Belousov
71f01edb54 EVFILT_TIMER: intialize stop timer list in type-stable proc init, instead of fork
(cherry picked from commit 171f0832c5b15f2f66d2fe59967348a42814b0c1)
2023-12-05 02:43:27 +02:00
Konstantin Belousov
24346a2f77 EVFILT_SIGNAL: do not use target process pointer on detach
PR:	275286

(cherry picked from commit ed410b78edc53e17b5a3e93ace2adbeb3a734ae9)
2023-12-05 02:43:27 +02:00
Brooks Davis
01df347671 auxv: make AT_BSDFLAGS unsigned
AT_BSDFLAGS shouldn't be sign extended on 64-bit systems so use a
uint32_t instead of an int.

Reviewed by:	imp, kib
Differential Revision:	https://reviews.freebsd.org/D42365

(cherry picked from commit 326bf5089ca788d5ff1951eed7a9067281a2b65e)
2023-12-02 00:03:25 +00:00
Mateusz Guzik
746b0f70a2 vfs: dodge locking for lseek(fd, 0, SEEK_CUR)
It is very common and according to dtrace while running poudriere almost
all calls with SEEK_CUR pass 0.

(cherry picked from commit 305a2676ae93fb50a623024d51039415521cb2da)
2023-11-29 10:58:16 +00:00
Konstantin Belousov
c4a62edfe2 sysctl kern.supported_archs: return correct value
(cherry picked from commit 26b36a64be410cacbec1a5cabec091bf7de2b251)
2023-11-28 13:39:38 +02:00
Rick Macklem
a7c25f0d06 nfsd: Fix NFS access to .zfs/snapshot snapshots
When a process attempts to access a snapshot under
/<dataset>/.zfs/snapshot, the snapshot is automounted.
However, without this patch, the automount does not
set mnt_exjail, which results in the snapshot not being
accessible over NFS.

This patch defines a new function called vfs_exjail_clone()
which sets mnt_exjail from another mount point and
then uses that function to set mnt_exjail in the snapshot
automount.  A separate patch that is currently a pull request
for OpenZFS, calls this function to fix the problem.

PR:	275200

(cherry picked from commit f5f277728adec4c5b3e840a1fb16bd16f8cc956d)
2023-11-25 16:53:29 -08:00
Mike Karels
3569e21f07 khelp: suppress useless warning message on shutdown
If a module (e.g. the ertt hhook for TCP) can't clean up at
shutdown, there is nothing to be done about it.  In the ertt case,
cleanup is just shutting down a UMA zone, which doesn't need to be
done.  Suppress EBUSY warnings on shutdown.

PR:		271677
Reviewed by:	tuexen, imp
Differential Revision:	https://reviews.freebsd.org/D42650

(cherry picked from commit 415c1c748d5492e41328fedf96b6bf3c9be94595)
2023-11-24 12:11:16 -06:00
Alexander Motin
a2bb07585b ktls: Remove unneeded vm/uma_dbg.h include
It was used in original implementation, but is no longer.

MFC after:	2 weeks

(cherry picked from commit 1f8a5187ffdd9eb7d78e699f948f7bab3abf60e9)
2023-11-23 10:48:08 -05:00
Konstantin Belousov
3114e149b0 vn_lock_pair(): reasonably handle vp1 == vp2 case
(cherry picked from commit 22bac49b09a9f975330dc0d811436599ce740890)
2023-11-23 06:00:36 +02:00
Konstantin Belousov
9d7412604d kernel: add missed FEATUREs compat_freebsd 8-14
(cherry picked from commit e256f71389fbf0ef6cf8f547342d5f789e69f918)
2023-11-23 06:00:36 +02:00
Bojan Novković
ae8387cc81 tty: properly check character position when handling IUTF8 backspaces
The tty_rubchar() code handling backspaces for UTF-8 characters didn't
properly check whether the beginning of the current line was reached.
This resulted in a kernel panic in ttyinq_unputchar() when prodded with
certain malformed UTF-8 sequences.

PR:		275009
Reviewed by:	christos
Differential Revision:	https://reviews.freebsd.org/D42564

(cherry picked from commit c6d7be214811c315d234d64c6cbaa92d4f55d2c1)
2023-11-20 18:54:54 +02:00
Konstantin Belousov
0784b5768e vn_copy_file_range(): busy both in and out mp around call to VOP_COPY_FILE_RANGE()
(cherry picked from commit 23210f538a008788b2e16b9eddafa4f598a21663)
2023-11-20 03:39:22 +02:00
Konstantin Belousov
1703a823c5 vn_copy_file_range(): use local variables for invp/outvp vnodes v_mounts
(cherry picked from commit 89188bd6ba8d8332c65498f2b71c90e5ed4b9dae)
2023-11-20 03:39:22 +02:00
Olivier Certner
e191c0283e Ensure 'struct thread' is aligned to a cache line
Using the new UMA_ALIGN_CACHE_AND_MASK() facility, which allows to
simultaneously guarantee a minimum of 32 bytes of alignment (the 5 lower
bits are always 0).

For the record, to this day, here's a (possibly non-exhaustive) list of
synchronization primitives using lower bits to store flags in pointers
to thread structures:
- lockmgr, rwlock and sx all use the 5 bits directly.
- rmlock indirectly relies on sx, so can use the 5 bits.
- mtx (non-spin) relies on the 3 lower bits.

Reviewed by:            markj, kib
MFC after:              2 week
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D42266

(cherry picked from commit 7d1469e555bdce32b3dfc898478ae5564d5072b1)
2023-11-16 10:07:30 -05:00
Jason A. Harmening
66b8f5484c vfs_lookup_cross_mount(): restore previous do...while loop
When the cross-mount walking logic in vfs_lookup() was factored into
a separate function, the main cross-mount traversal loop was changed
from a do...while loop conditional on the current vnode having
VIRF_MOUNTPOINT set to an unconditional for(;;) loop.  For the
unionfs 'crosslock' case in which the vnode may be re-locked, this
meant that continuing the loop upon finding inconsistent
v_mountedhere state would no longer branch to a check that the vnode
is in fact still a mountpoint.  This would in turn lead to over-
iteration and, for INVARIANTS builds, a failed assert on the next
iteration.

Fix this by restoring the previous loop behavior.

Reported by:	pho
Tested by:	pho
Fixes:		80bd5ef070

(cherry picked from commit 586fed0b03561558644eccc37f824c7110500182)
2023-11-11 20:38:26 -06:00
Konstantin Belousov
d0b4efe6d2 vfs_domount_update(): ensure that 'goto end' works
PR:	274992

(cherry picked from commit ede4c412b3ea9289ef42c664b01b6b5ff7eac434)
2023-11-12 02:31:13 +02:00
Mark Johnston
5d15f0d540 kmsan: Correct the origin address in kmsan_shadow_check()
Otherwise a KMSAN report (which panics the system by default) could
trigger a recursive panic.

MFC after:	1 week
Fixes:	ca6cd604c8 ("kmsan: Use the correct origin bytes in kmsan_check_arg()")

(cherry picked from commit 346134f19aa9ba38a0384244609e2bcd4f7838f4)
2023-11-11 12:30:37 -05:00
Mark Johnston
8da1c37151 reboot: Avoid unlocking Giant if the scheduler is stopped
When the scheduler is stopped, mtx_unlock() turns into a no-op, so the
loop

    while (mtx_owned(&Giant))
	    mtx_unlock(&Giant);

runs forever if the calling thread has Giant locked.

Reviewed by:	mhorne
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D42460

(cherry picked from commit deacab756026f86515781944a9e0271e8db9f86b)
2023-11-06 19:23:38 -05:00
Zhenlei Huang
5019a5acc5 Giant: Postpone removal of Giant-locked drivers until 15
Reviewed by:	imp
MFC after:	1 day
Differential Revision:	https://reviews.freebsd.org/D42401

(cherry picked from commit a8bd34bfc0db38c1c11e9c36b7dd849d607c17a8)
2023-11-02 00:22:22 +08:00
Konstantin Belousov
4b2694fbcf user stack randomization: only enable by default for 64bit processes
(cherry picked from commit 1798b44fda382c473c9fc7762e162613a39dc23c)
2023-10-31 02:46:10 +02:00
John Baldwin
83a00a92da Move kern_extattr_* prototypes to <sys/syscallsubr.h>
All of the kern_* prototypes belong in this header.  While here, sort
the prototypes by function name.

Reviewed by:	dchagin
Fixes:		6453d4240f vfs: Export exattr methods to reuse by Linuxulator
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D41766

(cherry picked from commit 3555be0124a4f105c72d932f00071f332691e8cf)
2023-10-24 10:00:57 -07:00
Mark Johnston
53f62d1c9a witness: Unconditionally initialize out-params for witness_save()
As of LLVM 16, the -fsanitize-memory-param-retval option is set to true
by default, meaning that MSan will eagerly report uninitialized function
parameters and return values, even if they are not used.  A
witness_save()/witness_restore() call pair fails this test since
witness_save() may return before saving file and line number
information.

Modify witness_save() to initialize the out-params unconditionally; this
appears to be the only instance of the problem triggered when booting to
a login prompt, so let's just address it directly.

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

(cherry picked from commit 7123222220aa563dc16bf1989d335722e4ff57a6)
2023-10-24 09:20:55 -04:00
Mark Johnston
2d49b111a3 uiomove: Add some assertions
Make sure that we don't try to copy with a negative resid.

Make sure that we don't walk off the end of the iovec array.

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

(cherry picked from commit 8fd0ec53deaad34383d4b344714b74d67105b258)
2023-10-24 09:19:01 -04:00
Mark Johnston
688c44068a kmsan: Use __builtin_memset to initialize per-thread state
Accesses to KMSAN's TLS block are not instrumented, so there's no need
to use kmsan_memset().  No functional change intended.

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

(cherry picked from commit e5caed14067b40f1454d74e99789a28508d0eea3)
2023-10-24 09:17:44 -04:00
Konstantin Belousov
be2333b68d nmount(MNT_UPDATE): add optional generid fsid parameter
(cherry picked from commit 9ef7a491a4236810e50f0a2ee8d52f5c4bb02c64)
2023-10-24 03:46:01 +03:00
Dmitry Chagin
b84a836ef0 vfs cache: Fallback to namei to resolve symlinks with leading / in target for non-native ABI
This is a temporary solution to fix PR before release.
During 15.0 it's necessary to refactor symlinks handling
between vfs & namecache.

PR:			273414
Reported by:		Vincent Milum Jr, Dan Kotowski, glebius
Tested by:		Dan Kotowski, glebius
Reviewed by:
Differential Revision:	https://reviews.freebsd.org/D41806
MFC after:		3 days

(cherry picked from commit bb8ecf259f96510b9c2146d846403393543061b7)
2023-10-22 09:55:53 +03:00
Bojan Novković
72a8e373f2 tty/teken: fix UTF8 sequence validation logic
This patch fixes UTF-8 sequence validation logic in
teken_utf8_bytes_to_codepoint() and fixes fallback behaviour in
ttydisc_rubchar() when an invalid UTF8 sequence is encountered. The code
previously used __bitcount() to extract sequence length information from
the leading byte. However, this assumption breaks for certain code
points that have additional bits set in the first half of the leading
byte (e.g. Cyrillic characters). This lead to incorrect behaviour when
deleting those characters using backspaces. The code now checks the
number of consecutive set bits in the leading byte starting from the
MSB, as per RFC 3629.

Reviewed by:	christos
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D42147

(cherry picked from commit 2fed1c579c52d63b72fc08ffcc652ba0183f9254)
2023-10-21 17:28:35 +03:00
Bojan Novković
8177011232 tty: fix improper backspace behaviour for UTF8 characters when in canonical mode
This patch adds additional logic in ttydisc_rubchar() to properly handle
backspace behaviour for UTF-8 characters.

Currently, typing in a backspace after a UTF8 character will delete only
one byte from the byte sequence, leaving garbled output in the tty's
output queue. With this change all of the character's bytes are deleted.
This change is only active when the IUTF8 flag is set (see
19054eb6053189144aa962b2ecc1bf5087758a3e "(s)tty: add support for IUTF8
input flag")

The code uses the teken_wcwidth() function to properly handle character
column widths for different code points, and adds the
teken_utf8_bytes_to_codepoint() function that converts a UTF-8 byte
sequence to a codepoint, as specified in RFC3629.

Reported by:    christos
Reviewed by:    christos, imp
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D42067

(cherry picked from commit 9e589b0938579f3f4d89fa5c051f845bf754184d)
2023-10-21 17:28:34 +03:00
Bojan Novković
b53fe14843 (s)tty: add support for IUTF8 input flag
This patch adds the necessary kernel and stty code to support setting
the IUTF8 flag for ttys. It is the first of two patches that fix
backspace behaviour for UTF-8 encoded characters when in canonical mode.

Reported by:	christos
Reviewed by:	christos, imp
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D42066

(cherry picked from commit 128f63cedc14ae21b35f74e11e2fe1a5659c58e8)
2023-10-21 17:28:34 +03:00
Mark Johnston
eb965d4f03 ktrace: Handle uio_resid underflow via MSG_TRUNC
When recvmsg(2) is used with MSG_TRUNC on an atomic socket type (DGRAM
or SEQPACKET), soreceive_generic() and uipc_peek_dgram() may
intentionally underflow uio_resid so that userspace can find out how
many bytes it should have asked for.

If this happens, and KTR_GENIO is enabled, ktrgenio() will attempt to
copy in beyond the end of the output buffer's iovec.  In general this
will silently cause the ktrace operation to fail since it'll result in
EFAULT from uiomove().  Let's be more careful and make sure not to try
and copy more bytes than we have.

Fixes:		be1f485d7d ("sockets: add MSG_TRUNC flag handling for recvfrom()/recvmsg().")
Reported by:	syzbot+30b4bb0c0bc0f53ac198@syzkaller.appspotmail.com
Reviewed by:	kib
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D42099

(cherry picked from commit 761ae1ce798add862d78728cc5ac5240ce7db779)
2023-10-20 12:02:05 -04:00
Konstantin Belousov
d4ee047036 arm64: do not disable the kern.kstack_pages tunable on arm64
(cherry picked from commit 39cddbd7a07c182c4f121bea5a6effa36862fc63)
2023-10-20 18:55:45 +03:00
Zhenlei Huang
1b289728e9 kmsan: Add corresponding sysctl knob for loader tunable
The loader tunable 'debug.kmsan.disabled' does not have corresponding
sysctl MIB entry. Add it so that it can be retrieved, and `sysctl -T`
will also report it correctly.

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

(cherry picked from commit 1d2b743784f7527a6840fe35ddb7e34cd41bc17a)
2023-10-19 22:00:56 +08:00
Zhenlei Huang
6f8ef4d6e4 kasan: Add corresponding sysctl knob for loader tunable
The loader tunable 'debug.kasan.disabled' does not have corresponding
sysctl MIB entry. Add it so that it can be retrieved, and `sysctl -T`
will also report it correctly.

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

(cherry picked from commit db5d0bc868be669ed6588ebeccf8c02e76aabc41)
2023-10-19 22:00:56 +08:00
Zhenlei Huang
c525ec74b4 boottrace: Add corresponding sysctl knob for loader tunable
The loader tunable 'kern.boottrace.table_size' does not have
corresponding sysctl MIB entry. Add it so that it can be retrieved,
and `sysctl -T` will also report it correctly.

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

(cherry picked from commit 51dc362d1a148362dc4cfacaa3629db928523204)
2023-10-19 22:00:50 +08:00
Olivier Certner
07c60e6323 Make cr_bsd_visible()'s sub-functions internal
cr_canseeotheruids(), cr_canseeothergids() and cr_canseejailproc()
should not be used directly now.  cr_bsd_visible() has to be called
instead.

Reviewed by:            mhorne
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40629

(cherry picked from commit 91e9d669b475d1900e8dc01a49ad90a621c4a068)
2023-10-18 13:24:48 -03:00
Olivier Certner
b6b76c1c09 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
Differential Revision:  https://reviews.freebsd.org/D40959

(cherry picked from commit ffd3ef8ee0253ffaf214cf711251d112f6a2bcf6)
(cherry picked from commit 845b7c80887ac84c82ee776836ef86d68ea71c94)
2023-10-17 16:42:59 -03:00
Olivier Certner
f482bc9584 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
Differential Revision:  https://reviews.freebsd.org/D40644

(cherry picked from commit 91658080f1a598ddda03943a783c9a941199f7d2)
(cherry picked from commit 0452dd841336cea7cd979b13ef12b6ea5e992eff)
2023-10-17 16:42:59 -03:00
Olivier Certner
d1fde7841f 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
Differential Revision:  https://reviews.freebsd.org/D40643

(cherry picked from commit 2a2bfa6ad92e9c82dcc55733ad2fd58fd2ea7559)
(cherry picked from commit 5d9f38405a10fdcd9fc108c940dcf2642e9f1833)
2023-10-17 16:42:59 -03:00
Olivier Certner
f3de805ace 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

(cherry picked from commit b725f232f3b09b4bcbc426854fe1545234c66965)
2023-10-17 16:42:59 -03:00
Olivier Certner
e1153205a7 Fix 'security.bsd.see_jail_proc' by using cr_bsd_visible()
As implemented, this security policy would only prevent seeing processes
in sub-jails, but would not prevent sending signals to, changing
priority of or debugging processes in these, enabling attacks where
unprivileged users could tamper with random processes in sub-jails in
particular circumstances (conflated UIDs) despite the policy being
enforced.

PR:                     272092
Reviewed by:            mhorne
MFC after:              2 weeks
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40628

(cherry picked from commit 5817169bc4a06a35aa5ef7f5ed18f6cb35037e18)
2023-10-17 16:42:58 -03:00