Commit Graph
100 Commits
Author SHA1 Message Date
Konstantin Belousov a1aa26b7db tests/sys/posixshm/posixshm_test.c::accounting fix after st_size changes
st_blksize is defined by POSIX as the 'preferred I/O block size for this
object.' It is wrong to use st_blksize as the unit for st_blocks and
expect it to be equal to the object size regardless of the change of
st_blksize.

Fixes:	3a1bf59d19 ("shmfd: consistently return size in 512 byte blocks for fstat(2) st_blocks")
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D59014
2026-08-21 04:31:50 +03:00
Konstantin Belousov fdcb52d036 ofed/ipoib: convert to timer_setup linuxKPI
Reviewed by:	bz
Sponsored by:	NVidia networking
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58941
2026-08-20 02:16:53 +03:00
Konstantin Belousov 814cd91998 mlx5(4): convert to timer_setup() linuxKPI
Reviewed by:	bz
Sponsored by:	NVidia networking
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58941
2026-08-20 02:16:53 +03:00
Konstantin Belousov 3a1bf59d19 shmfd: consistently return size in 512 byte blocks for fstat(2) st_blocks
This is ABI-breaking change that could be considered as the bug fix.

Requested by:	David Timber <[email protected]>
Reviewed by:	emaste, markj
Sponsored by:	The FreeBSD Foundation
Relnotes:	yes
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58942
2026-08-19 17:46:34 +03:00
Konstantin Belousov 4b17776d9a compat/freebsd32: set uio_rw for trailer's uio in freebsd32_sendfile()
PR:	297516
Reported by:	asomers
Fixes:	dfad790c8c ("sendfile: stop abusing kern_writev()")
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2026-08-14 17:35:39 +03:00
Konstantin Belousov 1a71d24ecd kern/sys_process.c: make vmspace_rwmem() similar to io functions
In particular, if there were any bytes moved, and then vm_fault()
faulted, do not return an error, but report the short io instead.

PR:	297512
Reviewed by:	markj
Tested by:	Stéphane D'Alu <[email protected]>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58838
2026-08-14 17:35:38 +03:00
Konstantin Belousov f6000e9dd9 kern/kern_proc.c: do not throw out read data in get_ps_strings()
Since vmspace_iop()/proc_readmem() might return -1 on error from
vmspace_rwmem(), account for this and stop reading but return already
accumulated data if any, instead of returning an error.

PR:	297512
Reported and tested by:	Stéphane D'Alu <[email protected]>
Reviewed by:	markj
Fixes:	e1b0d051bb ("proc: Allow to make proc_rwmem() operate on a consistent address space")
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58838
2026-08-14 17:35:38 +03:00
Konstantin Belousov 01d4e3c1d3 netipsec/xform_ipcomp.c: fix sockaddr type set in ipcomp6_nonexp_encapcheck()
Noted and reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58646
2026-08-14 17:35:38 +03:00
Konstantin Belousov cba481a7bf PF_KEY socket: limit the length of copied socket address
for SADB_UPDATE op SADB_X_EXT_NEW_ADDRESS_SRC/DST extensions, by
checking the sa_len matching the address family requirements before
doing the copy.

Also convert KEY_SETSECASIDX() and KEY_SETSECSPIDX() to functions and
apply the sa_len clamping there.

See https://github.com/0xdeadbeefnetwork/pfkey-sadb-overflow

PR:	297264
Tested by:	Wafa Hamzah <[email protected]> (previous version)
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58646
2026-08-14 17:35:38 +03:00
Konstantin Belousov fbe9aa7ebf netipsec/key.c::key_checksockaddrs(): constify src/dst address buffer pointers
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58646
2026-08-14 17:35:38 +03:00
Konstantin Belousov 6747bf7e22 linuxkpi: stop inlining accesses to curthread->td_lkpi_task
This should provide much higher resistence against struct thread layout
changes for out-of-tree modules depending on linuxkpi.

Reviewed by:	bz
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58733
2026-08-13 18:29:14 +03:00
Konstantin Belousov e2cfbd498a tty: do not recurse on ttydev_close()
When the terminal cdev is closed due to revoke, ttydev_close() destroys
t_inpoll and t_outpoll selinfos.  Since corresponding knotes reference
files pointing to the same tty cdev, it fdrop()s them.  But then the
VOP_CLOSE() call would recurse into the ttydev_close() for the same tty.
More, because the devfs vnode is already doomed, each close call gets
the FREVOKE flag set.

As result, the kernel is recursing as deep into the ttydev_close() as
there are opened files referencing the same tty, which have the knotes
installed.  Basically, the recursion level is controlled by userspace.

Prevent it by marking the tty that is handled by ttydev_close(), with
the TF_INDEVCLOSE flag.  Do nothing in ttydev_close() when the flag is
already set, avoiding recursion.

Fixes:	acd5638e26 ("tty: delete knotes when TTY is revoked")
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58706
2026-08-13 18:29:14 +03:00
Konstantin Belousov 6a8558cf9f vm/vm_phys.c: allow PHYS_TO_VM_PAGE(0) for registered fictitious page @0
PR:	296348
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58785
2026-08-11 16:26:35 +03:00
Konstantin Belousov 9f5c4ef328 dounmount(9): temporarily enable recursion for the covered vnode lock
For some complex nullfs mount configurations, it is possible to get the
covered vnode lock for the mount shared with some inside-mount vnode
lock.  Then at unmount time, vflush() would recurse on the covered vnode
lock when reclaiming the vnode.

Work around it, by temprorarily allowing recursion on the covered vnode
lock.  Disable recursion after the unmount if it was not enabled before.

PR:	297174
Reviewed by:	jah
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58567
2026-08-07 12:09:50 +03:00
Konstantin Belousov 1d97ad676d lockmgr(9): add lockcanrecurse(9)
Also add vnode locking wrappers for lockcanrecurse(9) and
lockdisablerecurse(9).

Reviewed by:	jah
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58567
2026-08-07 12:09:50 +03:00
Konstantin Belousov b0a85cb9df ptrace_test: require debug.ptrace_transparent_attach enabled for its test
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2026-08-07 02:11:10 +03:00
Konstantin Belousov d3c3a705b5 autofs: try to avoid waiting for timeouts of in-flight requests for forced unmounts
Do the advisory aborts of the in-flight requests before flushing the
vnodes.  It should mostly eliminate the waits due to requests busying
the mp.

Reported and reviewed by:	rew
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58637
2026-08-06 11:54:47 +03:00
Konstantin Belousov dfdd8af5a8 pddupfd.2: fix errno value returned for non-procdesc argument
Noted  and reviewed by:	lwhsu
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58666
2026-08-05 21:16:08 +03:00
Konstantin Belousov e8b9b6b9f3 pdkill(2), pdgetpid(2): return EBADF if the file type is not procdesc
For pdwait(2) and pddupfd(2), the returned error is kept EINVAL.

PR:	297293
Reviewed by:	lwhsu, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58666
2026-08-05 21:15:54 +03:00
Konstantin Belousov b95a859483 autofs_lookup(): busy the mount point around autofs_trigger()
Since autofs_lookup() calls into autofs_trigger_vn() to perform
automounting, and autofs_trigger_vn() unlocks the vnode, it is possible
for the unmount to start meantime.  Then autofs_trigger() accesses freed
memory.

At this point, busy can be only done unblocking, and the transient
failure must abort the trigger operation.  This would cause spurious
automounter errors, but at least should prevent accesses to the freed
memory.

PR:	294361
Reviewed by:	markj, rew
Tested by:	rew
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58626
2026-08-05 01:36:13 +03:00
Konstantin Belousov 4c58eef12d stat.2: enhance the description of st_blocks
Reviewed by:	emaste, mckusick
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Differential revision:	https://reviews.freebsd.org/D58592
2026-08-03 01:17:28 +03:00
Konstantin Belousov 77d6c45afd tests/sys/capsicum: adjust tests for the new reaping behavior
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58569
2026-08-01 13:42:04 +03:00
Konstantin Belousov a96f285b59 tests/sys/kern: adjust tests for the new reaping behavior
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58530
2026-08-01 13:42:01 +03:00
Konstantin Belousov c49198534a pdwait(2), wait(2): document interaction between pdopenpid() and waitpid()
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58264
2026-08-01 13:41:54 +03:00
Konstantin Belousov bcdb6ba94d processes: add zombie references, each of them prevents reap
Add the p_zombieref bitmask into struct proc, which enumerates all
legitimate waiters on the process exit status. Among them are parent
for PZOMBIEREF_PARENT, and the holder of the process descriptor for
PZOMBIEREF_PROCDESC, if the process was created by pdfork().

Require all zombie refs to be cleared to reap zombie. This prevents
stealing the exit status from the parent by pdwait()ing on a procdesc
obtained by pdopenpid(), or by waitpid() by debugger from the real
parent.

Reviewed by:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58264
2026-08-01 13:41:45 +03:00
Konstantin Belousov 7da4edd300 pdwait(2): change handling of the exited processes
Instead of accessing the struct proc and gathering data from it,
memoize the data needed for pdwait() on exited process in struct
procdesc, at the time of process termination.

This allows unlimited number of calls to pdwait(2) on procdesc for
terminated process.

Change the locking requirements for pd_flags to proctree_lock. This does
not modify the pre-patch locking regime, but the change requires it.

Reviewed by:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58407
2026-08-01 13:41:35 +03:00
Konstantin Belousov a24674ecab kern/kern_exit.c: make wait_fill_siginfo/wrusage global
Reviewed by:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58407
2026-08-01 13:41:28 +03:00
Konstantin Belousov 833bdae6c5 proc_realparent(): do not mark the child as orphan when reparenting to p_opptr pid
Reported and reviewed by:	markj
Fixes:	8cef3c9b76 ("proc_realparent(): assert that an orphaned child has real parent != parent")
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58566
2026-07-31 18:57:31 +03:00
Konstantin Belousov 72952bf6a3 amd64: try to fix the build with old clang that does not know about FRED
Reported by:	jhb
Reviewed by:	jhb, jrtc27
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58550
2026-07-30 20:08:24 +03:00
Konstantin Belousov cef05c5a62 amd64: do not allow to set reserved bits in MXCSR for ptrace(PT_SETFPREGS)
Also do not mask bits in the mxcsr_mask.  It is ignored by FRSTOR/XRSTOR.

Reported by:	markj
Reviewed by:	jhb, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58548
2026-07-30 20:08:24 +03:00
Konstantin Belousov 930f2e4da9 kern_execve(): avoid storing non-VDIR into p_textdvp
Reported by:	Nick Price
Tested by:	pho
Reviewed by:	jah, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58506
2026-07-30 05:56:30 +03:00
Konstantin Belousov b72f9bfc45 statfs(2): allow to interrupt busying
There are probably more places which could benefit from allowing to
interrupt vfs_busy() calls at syscalls top level.

Requested by:	Peter Eriksson <[email protected]>
Reviewed by:	jah, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58477
2026-07-29 08:20:12 +03:00
Konstantin Belousov fb4d7bd4b7 vfs_busy(): add MBF_PCATCH flag to allow interrupting the sleep
Reviewed by:	jah, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58477
2026-07-29 08:20:07 +03:00
Konstantin Belousov 2e259c209f kern_pdwait(): print the process pointer through pd
to avoid using uninitialized value in the KASSERT() statement on the first
iteration.

Also, do the assert under the proctree_lock, which is not critical but
satisfies the invariants.

Noted and reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58505
2026-07-28 22:45:52 +03:00
Konstantin Belousov 8cef3c9b76 proc_realparent(): assert that an orphaned child has real parent != parent
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58504
2026-07-28 22:45:47 +03:00
Konstantin Belousov a3b5937da6 mknod.2: properly document root requirements
Submitted by:	Martijn Dekker <[email protected]>
PR:	297082
Fixes:	4090d103b0 ("mknod.2: update the man page")
MFC after:	3 days
2026-07-28 04:01:52 +03:00
Konstantin Belousov 34ca5a9e73 geom_zero(4): reset the uio vector on each uiomove()
PR:	297062
Tested by:	Jordan Gordeev <[email protected]>
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58472
2026-07-27 21:46:32 +03:00
Konstantin Belousov 10ea2300bf tests/libpthread: add pthread_cond_clockwait(3) tests
Reviewed by:	markj, ngie
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58458
2026-07-27 19:17:29 +03:00
Konstantin Belousov e7015a3834 pthread_cond_timedwait.3: document pthread_cond_clockwait(3)
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58463
2026-07-27 19:17:29 +03:00
Konstantin Belousov 6d3db07a2e pthread_cond_timedwait.3: use .Fo/.Fc for long arguments list
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58463
2026-07-27 19:17:29 +03:00
Konstantin Belousov e1136fbcab libthr: implement pthread_cond_clockwait(3)
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58463
2026-07-27 19:17:28 +03:00
Konstantin Belousov 149d3e5fcb libthr/thread/thr_cond.c: some style
Also use bool for the 'cancel' argument for cond_wait_common().

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58463
2026-07-27 19:17:28 +03:00
Konstantin Belousov 196cc005b1 libthr/thread/thr_umtx.c: style _thr_ucond_wait()
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58463
2026-07-27 19:17:28 +03:00
Konstantin Belousov f4a05f3793 _umtx_op.2: document the CVWAIT_UMTX_TIME flag for the UMTX_OP_CV_WAIT_UC request
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58463
2026-07-27 19:17:28 +03:00
Konstantin Belousov d738f66fab umtx_op(2): add the CVWAIT_UMTX_TIME flag for the UMTX_OP_CV_WAIT_UC request
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58463
2026-07-27 19:17:28 +03:00
Konstantin Belousov 4090d103b0 mknod.2: update the man page
State that FIFOs can be created, document the requirement that
dev must be zero then.  Mention whiteouts.

PR:	297082
Reviewed by:	emaste
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Differential revision:	https://reviews.freebsd.org/D58478
2026-07-27 19:12:13 +03:00
Konstantin Belousov 3c6f63902b pthread_cond_wait.3: describe spurious wakeups
Reviewed by:	markc
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58458
2026-07-27 19:12:12 +03:00
Konstantin Belousov 8f320c2bc4 getpgrp(2), getsid(2): allow to call on zombies
Also be more protective in getsid().

Reported by:	arrowd
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differrential revision:	https://reviews.freebsd.org/D58393
2026-07-24 02:50:13 +03:00
Konstantin Belousov eca7b25c10 kern/sys_ptrace: do not skip P2_PTRACEREQ wait for PT_CLEARSTEP/PT_GET_CHILDREN
Reported and reviewed by:	markj
Fixes:	d3b7bbee92 ("ptrace(2): add PT_GET_CHILDREN")
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58364
2026-07-21 05:58:30 +03:00
Konstantin Belousov 29d1a3248a lookup: do not return vp_crossmp as dvp for mount over the reg file
Return the covered vnode instead.

Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58191
2026-07-21 00:55:39 +03:00
Konstantin Belousov 6e93f5e4d6 amd64: FRED support
FRED support as defined starting from the SDM rev. 90, requires a new
'events' entry point to receive user and kernel mode exceptions and
interrupts notifications from the hardware.  A minimal asm trampoline is
enough, rest can be implemented in C due to the clean FRED organization
of the event reporting.

The syscall entry is handled by a microptimized assembly path, directly
calling into the amd64_syscall() handler, instead of the generic events
entry point.

Tested by:	emaste
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D55829
2026-07-21 00:51:02 +03:00
Konstantin Belousov 0e5b1384df x86 xen: provide the prototype for xen_arch_intr_handle_upcall() in x86/apicvar.h
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D56005
2026-07-21 00:49:26 +03:00
Konstantin Belousov 6dbeaf1afa ptrace.2: document PT_GET_CHILDREN
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58315
2026-07-20 23:19:12 +03:00
Konstantin Belousov d3b7bbee92 ptrace(2): add PT_GET_CHILDREN
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58315
2026-07-20 23:19:12 +03:00
Konstantin Belousov b328975b9d procdesc: report NOTE_PDSIGCHLD for traced and stopped process
on attach of the knote.  It is same as for NOTE_EXIT when attaching to
the exiting process.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58327
2026-07-20 05:00:02 +03:00
Konstantin Belousov 3f88f6b899 kqueue.2: document EVFILT_PROCDESC support for NOTE_FORK
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58292
2026-07-19 23:39:29 +03:00
Konstantin Belousov e8d4d754e1 EVFILT_PROCDESC: support NOTE_FORK
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58292
2026-07-19 23:39:29 +03:00
Konstantin Belousov 9b21a52495 kern_ptrace(): reduce code duplication
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58334
2026-07-19 17:48:46 +03:00
Konstantin Belousov 2038232e3e thread_stopped(): style
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2026-07-18 19:50:28 +03:00
Konstantin Belousov f967dd04c8 ptrace.2: Document PT_SET_SC_RET
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58247
2026-07-17 01:22:55 +03:00
Konstantin Belousov fd5faa5629 ptrace(2): PT_SET_SC_RET request
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58247
2026-07-17 01:22:55 +03:00
Konstantin Belousov a2f50c4b32 amd64 efirt: register all runtime regions as fictitious
This is needed for VM_PHYS_TO_PAGE() to work, which is needed for
pmap_map_io_transient() to work, which is needed for uiomove_fromphys()
to work.

PR:	296348
Reported and tested by:	Anton Saietskii <[email protected]>
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58274
2026-07-16 18:32:50 +03:00
Konstantin Belousov e18844223d fget_procdesc(): change error for non-procdesc type from EBADF to EINVAL
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2026-07-16 10:51:18 +03:00
Konstantin Belousov fed49793dd kern/sys_process.c: remove extra ()
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2026-07-16 00:02:20 +03:00
Konstantin Belousov a48a275325 sys/proc.h: remove spurious blank lines
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2026-07-15 21:05:28 +03:00
Konstantin Belousov 1f5fe8ad52 kern: change several int types to bools
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2026-07-15 21:05:25 +03:00
Konstantin Belousov 4c9f648852 init(8): extract reroot transient code into reroot_seed
Since init become dynamically linked, reroot appeared to be broken
because init copies itself into a transient tmpfs mount to continue
controlling execution right after the reboot(REROOT) syscall.  Because
the binary is dynamically linked, it cannot be properly executed.

Provide a minimal static binary 'reroot_seed' embedded into the init as
byte stream, which performs what the 'init -r' did, namely, the second
phase reroot.

For the static build of init as part of the /rescue crunch, keep the
inline reroot code.

Reported and tested by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58164
2026-07-14 18:43:45 +03:00
Konstantin Belousov 97de8330e1 kern: add fget_procdesc()
Convert several callers to use fget_procdesc().
Eliminate procdesc_find() and directly use fget_procdesc() in
sys_pdkill().  Previous code structure required to fdrop() procdesc
while the process is locked.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58117
2026-07-13 16:28:59 +03:00
Konstantin Belousov 0f1718e0d5 pdwait(2): make debugging events functional
We need to wake up the pdwait(2) waiters when procdesc event is
reported.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58172
2026-07-13 06:12:39 +03:00
Konstantin Belousov 4cd67a0eea kqueue.2: document NOTE_PDSIGCHLD
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58123
2026-07-13 06:12:39 +03:00
Konstantin Belousov 2a5e58c596 procdesc: add NOTE_PDSIGCHLD
The note type wakes up when there is something for pdwait(2) to report
on the process descriptor.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58123
2026-07-13 06:12:39 +03:00
Konstantin Belousov 7e06c33151 tmpfs: implement AT_RENAME_EXCHANGE
Reviewed by:	mckusick
Discussed with:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D57658
2026-07-12 01:04:43 +03:00
Konstantin Belousov 5e0b96e728 tmpfs: extract tmpfs_rename_check/set_parent() from tmpfs_rename()
Reviewed by:	mckusick
Discussed with:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D57658
2026-07-12 01:04:43 +03:00
Konstantin Belousov 631b8ff931 tmpfs_rename(): style
Reviewed by:	mckusick
Discussed with:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D57658
2026-07-12 01:04:43 +03:00
Konstantin Belousov 3055c47f60 rename.2: Document AT_RENAME_EXCHANGE
Reviewed by:	mckusick
Discussed with:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D57658
2026-07-12 01:04:43 +03:00
Konstantin Belousov 8e6e77ec25 renameat(2): add AT_RENAME_EXCHANGE flag
Currently no filesystems support it.

Reviewed by:	mckusick
Discussed with:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D57658
2026-07-12 01:04:43 +03:00
Konstantin Belousov 8a36572392 kern_execve.c: simplify execve_block_wait()
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58147
2026-07-10 23:36:17 +03:00
Konstantin Belousov 3defe81956 infiniband/core/ib_addr.c: fix typo
We should exit the net epoch instead of acquiring one more entry.

Reported by:	Wafa Hamzah <[email protected]>
Reviewed by:	jhb
Sponsored by:	Nvidia networking
Fixes:	4726b80d93 ("OFED: Various changes from Linux 4.20")
Differential revision:	https://reviews.freebsd.org/D58127
2026-07-09 18:41:50 +03:00
Konstantin Belousov 1364d8fd9b kern_writefile(): fix several regressions
sendfile(): for trailers uio, set uio_rw to UIO_WRITE instead of checking it
kern_filewrite(): remove unused argument offset
kern_writev(): the check should compare cnt against zero, not uio_resid

Reported by:	markj
Fixes:	dfad790c8c ("sendfile: stop abusing kern_writev()")
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2026-07-09 07:53:23 +03:00
Konstantin Belousov b72397da27 kern_filewrite(): unconditionally calculate cnt, it is used by callers
Reported by:	dhw, madpilot
Tested by:	dhw
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Fixes:	dfad790c8c ("sendfile: stop abusing kern_writev()")
2026-07-08 20:01:09 +03:00
Konstantin Belousov e75fa2a613 Regen syscalls tables.
This catches up with 692b0ef150 which added CAPENABLED to
clock_nanosleep(). Curiously recent additions of the pdopenpid(2) and
pddupfd(2) were done before the cited commit, and that regen did not
included the change.

Sponsored by:	The FreeBSD Foundation
2026-07-08 18:26:57 +03:00
Konstantin Belousov a2426d1cd8 pdfork.2: grammar
Submitted by:	des
MFC after:	1 week
2026-07-08 09:09:32 +03:00
Konstantin Belousov 23e94b040b pddupfd(2): add basic test
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D57163
2026-07-08 02:18:01 +03:00
Konstantin Belousov f87f97d4c9 kern/sys_process.c: clean up includes
Order them alphabetically.
Remove redundand sys/param.h.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2026-07-08 01:03:53 +03:00
Konstantin Belousov 080a7fe981 Regen. 2026-07-08 01:03:53 +03:00
Konstantin Belousov c20558e5c9 pdfork.2: document pddupfd()
Reviewed by:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D57163
2026-07-08 01:03:53 +03:00
Konstantin Belousov 2a41a8f64b libsys: export pddupfd(2)
Reviewed by:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D57163
2026-07-08 01:03:53 +03:00
Konstantin Belousov 1ad21a6521 kern: add pddupfd(2)
Reviewed by:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D57163
2026-07-08 01:03:53 +03:00
Konstantin Belousov 046a4efe78 Add CAP_PDDUPFD capability
Reviewed by:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D57163
2026-07-08 01:03:52 +03:00
Konstantin Belousov 193fd49699 sys/capsicum.h: fix comment for CAP_PDWAIT
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D57163
2026-07-08 00:54:41 +03:00
Konstantin Belousov 77b6adbe5e fget_remote(): return fcaps and fde_flags if requested
Reviewed by:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D57163
2026-07-08 00:54:35 +03:00
Konstantin Belousov dfad790c8c sendfile: stop abusing kern_writev()
Provide convenient wrapper kern_filewrite() around fo_write().
Switch to use it in vn_sendfile().  This allows to avoid duplicate
fget() when we already have the reference to the file, which creates a
correctness race with the userspace.  Also td_retval[0] clearing hack
can be removed.

Reviewed by:	glebius, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58035
2026-07-08 00:47:18 +03:00
Konstantin Belousov 716bb8d3d4 mlx5: extend mlx5_ib_create_cq struct with fields from the current Linux ABI
This is backward ABI-compatible, because the only place in kernel that
uses the structure, namely the mlx5_ib_cq.c:mlx5_ib_create_cq()
function, copies in as much structure members as provided by userspace.

Tested by:	Wafa Hamzah <[email protected]>
Sponsored by:	Nvidia networking
MFC after:	1 month
2026-07-07 14:24:11 +03:00
Konstantin Belousov 849a51ac83 pdfork.2: grammar
Submitted by:	des
MFC after:	1 week
2026-07-07 11:07:04 +03:00
Konstantin Belousov f7675fab20 Regen 2026-07-07 04:27:16 +03:00
Konstantin Belousov 3e8b68c26e pdfork.2: document pdopenpid(2)
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D57124
2026-07-07 04:27:16 +03:00
Konstantin Belousov 5a5affd457 pdfork.2: clarify that PD_DAEMON acts on current file
Also do not start a new list for each flag item.

Reviewed by:    markj
MFC after:      1 week
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D57124
2026-07-07 04:27:13 +03:00
Konstantin Belousov 1cced49328 pdfork.2: document EINVAL for pdwait(2)
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D57124
2026-07-07 04:27:10 +03:00
Konstantin Belousov d6ff3bb3de libsys: export pdopenpid(2)
Reviewed by:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D57124
2026-07-07 04:25:26 +03:00
Konstantin Belousov 606061ea46 sys: add AUE_PDOPENPID
Reviewed by:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D57124
2026-07-07 04:25:08 +03:00