Revision tags: release/14.2.0, release/13.4.0 |
|
#
d2be7ed6 |
| 02-Aug-2024 |
Olivier Certner <olce@FreeBSD.org> |
cred: proc_set_cred(), proc_unset_cred(): Update user's process count
As a process really changes credentials at the moment proc_set_cred() or proc_unset_cred() is called, these functions are the pr
cred: proc_set_cred(), proc_unset_cred(): Update user's process count
As a process really changes credentials at the moment proc_set_cred() or proc_unset_cred() is called, these functions are the proper locations to perform the update of the new and old real users' process count (using chgproccnt()).
Before this change, change_ruid() instead would perform that update, although it operates only on a passed credential which is a priori not tied to the calling process (or not to any process at all). This was arguably a flaw of commit b1fc0ec1a7a49ded, r77183, based on its commit message, and in particular the portion "(...) In each case, the call now acts on a credential not a process (...)".
Fixing this makes using change_ruid() more natural when building candidate credentials that in the end are not applied to a process, e.g., because of some intervening privilege check. Also, it removes a hack around this unwanted process count change in unionfs.
We also introduce the new proc_set_cred_enforce_proc_lim() so that callers can respect the per-user process limit, and will use it for the upcoming setcred(). We plan to change all callers of proc_set_cred() to call this new function instead at some point. In the meantime, both proc_set_cred() and the new function will coexist.
As detailed in some proc_set_cred_enforce_proc_lim()'s comment, checking against the process limit is currently flawed as the kernel doesn't really maintain the number of processes per UID (besides RLIMIT_NPROC, this in fact also applies to RLIMIT_KQUEUES, RLIMIT_NPTS, RLIMIT_SBSIZE and RLIMIT_SWAP). The applied limit is currently that of the old real UID. Root (or a process granted with PRIV_PROC_LIMIT) is not subject to this limit.
Approved by: markj (mentor) Fixes: b1fc0ec1a7a49ded MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D46923
show more ...
|
#
d0675399 |
| 27-Aug-2024 |
Edward Tomasz Napierala <trasz@FreeBSD.org> |
capsicum: allow subset of wait4(2) functionality
The usual way of handling process exit exit in capsicum(4) mode is by using process descriptors (pdfork(2)) instead of the traditional fork(2)/wait4(
capsicum: allow subset of wait4(2) functionality
The usual way of handling process exit exit in capsicum(4) mode is by using process descriptors (pdfork(2)) instead of the traditional fork(2)/wait4(2) API. But most apps hadn't been converted this way, and many cannot because the wait is hidden behind a library APIs that revolve around PID numbers and not descriptors; GLib's g_spawn_check_wait_status(3) is one example.
Thus, provide backwards compatibility by allowing the wait(2) family of functions in Capsicum mode, except for child processes created by pdfork(2).
Reviewed by: brooks, oshogbo Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D44372
show more ...
|
Revision tags: release/14.1.0, release/13.3.0 |
|
#
877ef685 |
| 28-Nov-2023 |
Konstantin Belousov <kib@FreeBSD.org> |
Revert "kqueue: on process exit, force-clear its registered signal events"
This reverts commit 393ac29f0b8be068c8e46f76c2eeee07d20ea4df. A different fix is following, which preserves semantic, requ
Revert "kqueue: on process exit, force-clear its registered signal events"
This reverts commit 393ac29f0b8be068c8e46f76c2eeee07d20ea4df. A different fix is following, which preserves semantic, required by the sys.kqueue.proc3_test.proc3 test.
Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week PR: 275286 Differential revision: https://reviews.freebsd.org/D42777
show more ...
|
#
29363fb4 |
| 23-Nov-2023 |
Warner Losh <imp@FreeBSD.org> |
sys: Remove ancient SCCS tags.
Remove ancient SCCS tags from the tree, automated scripting, with two minor fixup to keep things compiling. All the common forms in the tree were removed with a perl s
sys: Remove ancient SCCS tags.
Remove ancient SCCS tags from the tree, automated scripting, with two minor fixup to keep things compiling. All the common forms in the tree were removed with a perl script.
Sponsored by: Netflix
show more ...
|
#
393ac29f |
| 24-Nov-2023 |
Konstantin Belousov <kib@FreeBSD.org> |
kqueue: on process exit, force-clear its registered signal events
Normally, process already has all its kqueue fds destroyed at the moment p_klist is detached in exit flow. But, if the process was c
kqueue: on process exit, force-clear its registered signal events
Normally, process already has all its kqueue fds destroyed at the moment p_klist is detached in exit flow. But, if the process was created with rfork(2) with shared file descriptors, its signal knotes can survive. Then, knlist_detach() does not destroy non-empty knlist. Later, when owning kqueue is closed, we access freed (or rather, reused, because struct proc is type-stable) memory by referencing p->p_klist from such knote.
Handle this situation by deleting all knotes hanging from p_klist.
PR: 275286 Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D42745
show more ...
|
#
0a713948 |
| 22-Nov-2023 |
Alexander Motin <mav@FreeBSD.org> |
Replace random sbuf_printf() with cheaper cat/putc.
|
#
9b57e30c |
| 14-Nov-2023 |
John Baldwin <jhb@FreeBSD.org> |
abort2: Generate a core dump
Call sigexit rather than exit1 so that a core is generated.
If running the SIGABRT handler is desired, this would need to use kern_psignal() instead. In that case a us
abort2: Generate a core dump
Call sigexit rather than exit1 so that a core is generated.
If running the SIGABRT handler is desired, this would need to use kern_psignal() instead. In that case a userspace wrapper in libc would be needed to force an exit if the handler doesn't exit. Given that abort2(2)'s intended use case is when userland is in a sufficiently bad state such that it can't safely call syslog(3) before abort(3), a userspace abort2(3) wrapper in libc might be dubious.
Reviewed by: Olivier Certner <olce.freebsd@certner.fr>, emaste Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D42163
show more ...
|
Revision tags: release/14.0.0 |
|
#
685dc743 |
| 16-Aug-2023 |
Warner Losh <imp@FreeBSD.org> |
sys: Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
|
#
28b36ecf |
| 09-Aug-2023 |
Konstantin Belousov <kib@FreeBSD.org> |
Revert "exit1(): Revert sparc64 workaround"
This reverts commit 96c76d930656f13d3c041dc8d8f2fc3dd1e5e05a.
There are other relatively common reasons why init might get killed during reboot, the work
Revert "exit1(): Revert sparc64 workaround"
This reverts commit 96c76d930656f13d3c041dc8d8f2fc3dd1e5e05a.
There are other relatively common reasons why init might get killed during reboot, the workaround was really not sparc64-specific.
Discussed with: marius Sponsored by: The FreeBSD Foundation
show more ...
|
#
96c76d93 |
| 06-Aug-2023 |
Marius Strobl <marius@FreeBSD.org> |
exit1(): Revert sparc64 workaround
If this still is a problem on other architectures, it should be fixed properly.
This reverts commit 5486ffc898503a846ecaf3f5ef9f9269beb4540e.
|
#
452661c9 |
| 03-Aug-2023 |
Igor Ostapenko <pm@igoro.pro> |
exit1(): fix a comment typo
Signed-off-by: Igor Ostapenko <pm@igoro.pro> Reviewed by: emaste Pull Request: https://github.com/freebsd/freebsd-src/pull/809
|
#
aaa92413 |
| 20-Jul-2023 |
Konstantin Belousov <kib@FreeBSD.org> |
Revert "killpg(): close a race with fork(), part 2"
This reverts commits 81a37995c757b4e3ad8a5c699864197fd1ebdcf5 and 565a343ae3a30bc2973182ff8dfd2fa37d7f615f.
There is still a leakage of the p_kil
Revert "killpg(): close a race with fork(), part 2"
This reverts commits 81a37995c757b4e3ad8a5c699864197fd1ebdcf5 and 565a343ae3a30bc2973182ff8dfd2fa37d7f615f.
There is still a leakage of the p_killpg_cnt, some but not all sources of which were identified.
Second, and more important, is that there is a fundamental issue with blocked signals having KSI_KILLPG flag set. Queueing of such signal increments p_killpg_cnt, but it cannot be decremented until the signal is delivered. If, for instance, a single-threaded process with blocked signal receives killpg-kill and executes fork(2), the fork enter check returns with ERESTART. And since signal is blocked, the condition cannot be cleared.
Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D41128
show more ...
|
#
81a37995 |
| 16-Jun-2023 |
Konstantin Belousov <kib@FreeBSD.org> |
killpg(): close a race with fork(), part 2
When we are sending terminating signal to the group, killpg() needs to guarantee that all group members are to be terminated (it does not need to ensure th
killpg(): close a race with fork(), part 2
When we are sending terminating signal to the group, killpg() needs to guarantee that all group members are to be terminated (it does not need to ensure that they are terminated on return from killpg()). The pg_killsx change eliminates the largest window there, but still, if a multithreaded process is signalled, the following could happen: - thread 1 is selected for the signal delivery and gets descheduled - thread 2 waits for pg_killsx lock, obtains it and forks - thread 1 continue executing and terminates the process This scenario allows the child to escape still.
To fix it, count the number of signals sent to the process with killpg(2), in p_killpg_cnt variable, which is incremented in killpg() and decremented after signal handler frame is created or in exit1() after single-threading. This way we avoid forking if the termination is due.
Noted and reviewed by: markj (previous version) Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D40493
show more ...
|
Revision tags: release/13.2.0 |
|
#
80cf427b |
| 29-Mar-2023 |
Mateusz Guzik <mjg@FreeBSD.org> |
proc: shave a lock trip on exit if possible
... which happens to be vast majority of the time
|
Revision tags: release/12.4.0, release/13.1.0 |
|
#
5ecb5444 |
| 10-Mar-2022 |
Mateusz Guzik <mjg@FreeBSD.org> |
jail: add process linkage
It allows iteration over processes belonging to given jail instead of having to walk the entire allproc list.
Note the iteration can miss processes which remains bug-compa
jail: add process linkage
It allows iteration over processes belonging to given jail instead of having to walk the entire allproc list.
Note the iteration can miss processes which remains bug-compatible with previous code.
Reviewed by: jamie (previous version), markj (previous version) Differential Revision: https://reviews.freebsd.org/D34522
show more ...
|
#
49a033d8 |
| 04-Sep-2022 |
Gordon Bergling <gbe@FreeBSD.org> |
kern: Correct some typos in source code comments
- s/occured/occurred/ - s/the the/the/
MFC after: 3 days
|
#
49afea10 |
| 25-Aug-2022 |
Mateusz Guzik <mjg@FreeBSD.org> |
proc: read the pid prior to unlocking in report_alive_proc1
In principle another thread could have reaped the process by that time.
|
#
5e5675cb |
| 12-Aug-2022 |
Konstantin Belousov <kib@FreeBSD.org> |
Remove struct proc p_singlethr member
It does not serve any purpose after we stopped doing thread_single(SINGLE_ALLPROC) from stoppable user processes.
Reviewed by: markj Tested by: pho Sponsored b
Remove struct proc p_singlethr member
It does not serve any purpose after we stopped doing thread_single(SINGLE_ALLPROC) from stoppable user processes.
Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D36207
show more ...
|
#
cc29f221 |
| 17-Aug-2022 |
Konstantin Belousov <kib@FreeBSD.org> |
ksiginfo_alloc(): change to directly take M_WAITOK/NOWAIT flags
Also style, and remove unneeded cast.
Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Diffe
ksiginfo_alloc(): change to directly take M_WAITOK/NOWAIT flags
Also style, and remove unneeded cast.
Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D36207
show more ...
|
#
30b16a6b |
| 12-Aug-2022 |
Konstantin Belousov <kib@FreeBSD.org> |
exit1(): update comment about thread_single()
We do not check single-threading conditions in trap, or when sleeping uninterruptible.
Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC afte
exit1(): update comment about thread_single()
We do not check single-threading conditions in trap, or when sleeping uninterruptible.
Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 3 days Differential revision: https://reviews.freebsd.org/D36207
show more ...
|
#
c6d31b83 |
| 18-Jul-2022 |
Konstantin Belousov <kib@FreeBSD.org> |
AST: rework
Make most AST handlers dynamically registered. This allows to have subsystem-specific handler source located in the subsystem files, instead of making subr_trap.c aware of it. For inst
AST: rework
Make most AST handlers dynamically registered. This allows to have subsystem-specific handler source located in the subsystem files, instead of making subr_trap.c aware of it. For instance, signal delivery code on return to userspace is now moved to kern_sig.c.
Also, it allows to have some handlers designated as the cleanup (kclear) type, which are called both at AST and on thread/process exit. For instance, ast(), exit1(), and NFS server no longer need to be aware about UFS softdep processing.
The dynamic registration also allows third-party modules to register AST handlers if needed. There is one caveat with loadable modules: the code does not make any effort to ensure that the module is not unloaded before all threads processed through AST handler in it. In fact, this is already present behavior for hwpmc.ko and ufs.ko. I do not think it is worth the efforts and the runtime overhead to try to fix it.
Reviewed by: markj Tested by: emaste (arm64), pho Discussed with: jhb Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D35888
show more ...
|
#
4493a13e |
| 15-May-2022 |
Konstantin Belousov <kib@FreeBSD.org> |
Do not single-thread itself when the process single-threaded some another process
Since both self single-threading and remote single-threading rely on suspending the thread doing thread_single(), it
Do not single-thread itself when the process single-threaded some another process
Since both self single-threading and remote single-threading rely on suspending the thread doing thread_single(), it cannot be mixed: thread doing thread_suspend_switch() might be subject to thread_suspend_one() and vice versa.
In collaboration with: pho Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D35310
show more ...
|
#
d3000939 |
| 05-May-2022 |
Konstantin Belousov <kib@FreeBSD.org> |
P2_WEXIT: avoid thread_single() for exiting process earlier
before the process itself does thread_single(SINGLE_EXIT). We cannot single-thread such process in ALLPROC (external) mode, and properly
P2_WEXIT: avoid thread_single() for exiting process earlier
before the process itself does thread_single(SINGLE_EXIT). We cannot single-thread such process in ALLPROC (external) mode, and properly detect and report the failure to do so due to the process becoming zombie is easier to prevent than handle.
In collaboration with: pho Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D35310
show more ...
|
#
b9294a3e |
| 26-Apr-2022 |
Konstantin Belousov <kib@FreeBSD.org> |
reaper_abandon_children(): upgrade proctree_lock assert to exclusive
p_reapsibling linkage is protected by proctree_lock, and it is modified there.
Suggested and reviewed by: markj Tested by: pho S
reaper_abandon_children(): upgrade proctree_lock assert to exclusive
p_reapsibling linkage is protected by proctree_lock, and it is modified there.
Suggested and reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D35014
show more ...
|
#
b3191718 |
| 23-Mar-2022 |
Mark Johnston <markj@FreeBSD.org> |
setitimer: Fix exit race
We use the p_itcallout callout, interlocked by the proc lock, to schedule timeouts for the setitimer(2) system call. When a process exits, the callout must be stopped befor
setitimer: Fix exit race
We use the p_itcallout callout, interlocked by the proc lock, to schedule timeouts for the setitimer(2) system call. When a process exits, the callout must be stopped before the process struct is recycled.
Currently we attempt to stop the callout in exit1() with the call _callout_stop_safe(&p->p_itcallout, CS_EXECUTING). If this call returns 0, then we sleep in order to drain the callout. However, this happens only if the callout is not scheduled at all. If the callout thread is blocked on the proc lock, then exit1() will not block and the callout may execute after the process has fully exited, typically resulting in a panic.
I cannot see a reason to use the CS_EXECUTING flag here. Instead, use the regular callout_stop()/callout_drain() dance to halt the callout.
Reported by: ler Tested by: ler, pho MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D34625
show more ...
|