#
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 ...
|
Revision tags: release/12.3.0 |
|
#
cffb55f0 |
| 29-Nov-2021 |
Brooks Davis <brooks@FreeBSD.org> |
syscalls: normalize exit
Declare the exit system call normally. This results in the implementation being named sys_exit rather than sys_sys_exit and being decalred as returning an int. Infact it d
syscalls: normalize exit
Declare the exit system call normally. This results in the implementation being named sys_exit rather than sys_sys_exit and being decalred as returning an int. Infact it does not return at all because exit1 does not, so add an __unreachable() to let the compiler know that.
Reviewed by: kib, imp
show more ...
|
#
e02f64d9 |
| 17-Nov-2021 |
Brooks Davis <brooks@FreeBSD.org> |
freebsd32: add real abort2
Previously, the code would copy twice as many pointers as specified and print pairs of them a single 64-bit pointer.
abort2 doesn't return so make the return type void
f
freebsd32: add real abort2
Previously, the code would copy twice as many pointers as specified and print pairs of them a single 64-bit pointer.
abort2 doesn't return so make the return type void
freebsd32_abort2 is in it's own file with a 2-clause BSD license based on a discussion with Wojciech many years ago.
Reviewed by: kevans
show more ...
|
#
1c696903 |
| 20-Oct-2021 |
Konstantin Belousov <kib@FreeBSD.org> |
Unmap shared page manually before doing vm_map_remove() on exit or exec
This allows the pmap_remove(min, max) call to see empty pmap and exploit empty pmap optimization.
Reviewed by: markj Tested b
Unmap shared page manually before doing vm_map_remove() on exit or exec
This allows the pmap_remove(min, max) call to see empty pmap and exploit empty pmap optimization.
Reviewed by: markj Tested by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D32569
show more ...
|
#
351d5f7f |
| 23-Oct-2021 |
Konstantin Belousov <kib@FreeBSD.org> |
exec: store parent directory and hardlink name of the binary in struct proc
While doing it, also move all the code to resolve pathnames and obtain text vp and dvp, into single place. Besides simpl
exec: store parent directory and hardlink name of the binary in struct proc
While doing it, also move all the code to resolve pathnames and obtain text vp and dvp, into single place. Besides simplifying the code, it avoids spurious vnode relocks and validates the explanation why a transient text reference on the script vnode is not harmful.
Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D32611
show more ...
|
#
46dd801a |
| 16-Oct-2021 |
Colin Percival <cperciva@FreeBSD.org> |
Add userland boot profiling to TSLOG
On kernels compiled with 'options TSLOG', record for each process ID: * The timestamp of the fork() which creates it and the parent process ID, * The first path
Add userland boot profiling to TSLOG
On kernels compiled with 'options TSLOG', record for each process ID: * The timestamp of the fork() which creates it and the parent process ID, * The first path passed to execve(), if any, * The first path resolved by namei, if any, and * The timestamp of the exit() which terminates the process.
Expose this information via a new sysctl, debug.tslog_user.
On kernels lacking 'options TSLOG' (the default), no information is recorded and the sysctl does not exist.
Note that recording namei is needed in order to obtain the names of rc.d scripts being launched, as the rc system sources them in a subshell rather than execing the scripts.
With this commit it is now possible to generate flamecharts of the entire boot process from the start of the loader to the end of /etc/rc. The code needed to perform this processing is currently found in github: https://github.com/cperciva/freebsd-boot-profiling
Reviewed by: mhorne Sponsored by: https://www.patreon.com/cperciva Differential Revision: https://reviews.freebsd.org/D32493
show more ...
|
#
af29f399 |
| 29-Jul-2021 |
Dmitry Chagin <dchagin@FreeBSD.org> |
umtx: Split umtx.h on two counterparts.
To prevent umtx.h polluting by future changes split it on two headers: umtx.h - ABI header for userspace; umtxvar.h - the kernel staff.
While here fix umtx_k
umtx: Split umtx.h on two counterparts.
To prevent umtx.h polluting by future changes split it on two headers: umtx.h - ABI header for userspace; umtxvar.h - the kernel staff.
While here fix umtx_key_match style.
Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D31248 MFC after: 2 weeks
show more ...
|
#
28a66fc3 |
| 01-Jul-2021 |
Konstantin Belousov <kib@FreeBSD.org> |
Do not call FreeBSD-ABI specific code for all ABIs
Use sysentvec hooks to only call umtx_thread_exit/umtx_exec, which handle robust mutexes, for native FreeBSD ABI. Similarly, there is no sense in
Do not call FreeBSD-ABI specific code for all ABIs
Use sysentvec hooks to only call umtx_thread_exit/umtx_exec, which handle robust mutexes, for native FreeBSD ABI. Similarly, there is no sense in calling sigfastblock_clear() for non-native ABIs.
Requested by: dchagin Reviewed by: dchagin, markj (previous version) Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D30987
show more ...
|
#
55976ce1 |
| 01-Jul-2021 |
Konstantin Belousov <kib@FreeBSD.org> |
Move sv_onexit() sysentvec hook slightly later
after itimers are stopped. This makes it more usable for e.g. native FreeBSD ABI sysentvecs.
Reviewed by: dchagin, markj Sponsored by: The FreeBSD Fo
Move sv_onexit() sysentvec hook slightly later
after itimers are stopped. This makes it more usable for e.g. native FreeBSD ABI sysentvecs.
Reviewed by: dchagin, markj Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D30987
show more ...
|
#
a12e901a |
| 05-Jun-2021 |
Konstantin Belousov <kib@FreeBSD.org> |
Add a knob to disable dequeueing SIGCHLD on waiting for live process
It seems that Linux does not dequeue siginfo for SIGCHLD when wait*(2) reports status of the running process. In particular, sig
Add a knob to disable dequeueing SIGCHLD on waiting for live process
It seems that Linux does not dequeue siginfo for SIGCHLD when wait*(2) reports status of the running process. In particular, sigwaitinfo(2) and other signal querying syscalls can observe the siginfo after wait.
FreeBSD dequeued siginfo from the beginning, so we cannot change the default ABI to be more compatible. Still, add a knob to enable to change to the other behavior for debugging purposes.
Reported by: dchagin Reviewed by: dchagin, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D30675
show more ...
|
#
fd3ac06f |
| 18-May-2021 |
Konstantin Belousov <kib@FreeBSD.org> |
ptrace: add an option to not kill debuggees on debugger exit
Requested by: markj Reviewed by: jhb (previous version) Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differrenti
ptrace: add an option to not kill debuggees on debugger exit
Requested by: markj Reviewed by: jhb (previous version) Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differrential revision: https://reviews.freebsd.org/D30351
show more ...
|
Revision tags: release/13.0.0 |
|
#
47877889 |
| 01-Jan-2021 |
John Baldwin <jhb@FreeBSD.org> |
ddb ps: Use the pidhash to enumerate processes not in allproc.
Exiting processes that have been removed from allproc but are still executing are not yet marked PRS_ZOMBIE, so they were not listed (f
ddb ps: Use the pidhash to enumerate processes not in allproc.
Exiting processes that have been removed from allproc but are still executing are not yet marked PRS_ZOMBIE, so they were not listed (for example, if a thread panics during exit1()). To detect these processes, clear p_list.le_prev to NULL explicitly after removing a process from the allproc list and check for this sentinel rather than PRS_ZOMBIE when walking the pidhash.
While here, simplify the pidhash walk to use a single outer loop.
Reviewed by: kib Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D27824
show more ...
|
#
87a9b18d |
| 23-Nov-2020 |
Konstantin Belousov <kib@FreeBSD.org> |
Provide ABI modules hooks for process exec/exit and thread exit.
Exec and exit are same as corresponding eventhandler hooks.
Thread exit hook is called somewhat earlier, while thread is still owned
Provide ABI modules hooks for process exec/exit and thread exit.
Exec and exit are same as corresponding eventhandler hooks.
Thread exit hook is called somewhat earlier, while thread is still owned by the process and enough context is available. Note that the process lock is owned when the hook is called.
Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D27309
show more ...
|
#
e68c6191 |
| 21-Nov-2020 |
Konstantin Belousov <kib@FreeBSD.org> |
Stop using eventhandlers for itimers subsystem exec and exit hooks.
While there, do some minor cleanup for kclocks. They are only registered from kern_time.c, make registration function static. Rem
Stop using eventhandlers for itimers subsystem exec and exit hooks.
While there, do some minor cleanup for kclocks. They are only registered from kern_time.c, make registration function static. Remove event hooks, they are not used by both registered kclocks. Add some consts.
Perhaps we can stop registering kclocks at all and statically initialize them.
Reviewed by: mjg Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D27305
show more ...
|
#
85078b85 |
| 17-Nov-2020 |
Conrad Meyer <cem@FreeBSD.org> |
Split out cwd/root/jail, cmask state from filedesc table
No functional change intended.
Tracking these structures separately for each proc enables future work to correctly emulate clone(2) in linux
Split out cwd/root/jail, cmask state from filedesc table
No functional change intended.
Tracking these structures separately for each proc enables future work to correctly emulate clone(2) in linux(4).
__FreeBSD_version is bumped (to 1300130) for consumption by, e.g., lsof.
Reviewed by: kib Discussed with: markj, mjg Differential Revision: https://reviews.freebsd.org/D27037
show more ...
|
#
19d3e47d |
| 16-Nov-2020 |
Mateusz Guzik <mjg@FreeBSD.org> |
select: call seltdfini on process and thread exit
Since thread_zone is marked NOFREE the thread_fini callback is never executed, meaning memory allocated by seltdinit is never released.
Adding the
select: call seltdfini on process and thread exit
Since thread_zone is marked NOFREE the thread_fini callback is never executed, meaning memory allocated by seltdinit is never released.
Adding the call to thread_dtor is not sufficient as exiting processes cache the main thread.
show more ...
|
#
f5297909 |
| 11-Nov-2020 |
Mark Johnston <markj@FreeBSD.org> |
Fix a pair of races in SIGIO registration
First, funsetownlst() list looks at the first element of the list to see whether it's processing a process or a process group list. Then it acquires the gl
Fix a pair of races in SIGIO registration
First, funsetownlst() list looks at the first element of the list to see whether it's processing a process or a process group list. Then it acquires the global sigio lock and processes the list. However, nothing prevents the first sigio tracker from being freed by a concurrent funsetown() before the sigio lock is acquired.
Fix this by acquiring the global sigio lock immediately after checking whether the list is empty. Callers of funsetownlst() ensure that new sigio trackers cannot be added concurrently.
Second, fsetown() uses funsetown() to remove an existing sigio structure from a file object. However, funsetown() uses a racy check to avoid the sigio lock, so two threads may call fsetown() on the same file object, both observe that no sigio tracker is present, and enqueue two sigio trackers for the same file object. However, if the file object is destroyed, funsetown() will only remove one sigio tracker, and funsetownlst() may later trigger a use-after-free when it clears the file object reference for each entry in the list.
Fix this by introducing funsetown_locked(), which avoids the racy check.
Reviewed by: kib Reported by: pho Tested by: pho MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D27157
show more ...
|
Revision tags: release/12.2.0 |
|
#
844219f4 |
| 16-Sep-2020 |
Konstantin Belousov <kib@FreeBSD.org> |
proc_realparent: if p_oppid does not match pid of the current parent for non-orphaned process, return reaper instead of init.
Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Di
proc_realparent: if p_oppid does not match pid of the current parent for non-orphaned process, return reaper instead of init.
Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D26416
show more ...
|
#
e2515283 |
| 27-Aug-2020 |
Glen Barber <gjb@FreeBSD.org> |
MFH
Sponsored by: Rubicon Communications, LLC (netgate.com)
|
#
c5bc28b2 |
| 22-Aug-2020 |
Konstantin Belousov <kib@FreeBSD.org> |
Fix several issues with process group orphanage.
Attempt of adding assertions that pgrp->pg_jobc counters do not underflow in r361967, reverted in r362910, points out bugs in the handling of job con
Fix several issues with process group orphanage.
Attempt of adding assertions that pgrp->pg_jobc counters do not underflow in r361967, reverted in r362910, points out bugs in the handling of job control. Peter Holm was able to narrow down the problem to very easy reproduction with timeout(1) which uses reaping.
The following list of problems with calculation of pg_jobs which directs SIGHUP/SIGCONT delivery for orphaned process group was identified: - Re-calculation of the orphaned status for children of exiting parent was wrong, but mostly unnoticed when all children were reparented to init(8). When child can be reparented to a different process which could affect the child' job control state, it was not properly accounted for in pg_jobc. - Lockless check for exiting process' parent process group is racy because nothing prevents the parent from changing its group membership. - Exited process is left in the process group, until waited. This affects other calculations of pg_jobc.
Split handling of job control status on process changing its process group, and process exiting. Calculate increments and decrements for pg_jobs by exact checking the orphanage instead of assuming process group membership for children and parent. Move the call to killjobc() later under the proctree_lock. Mark exiting process in killjobc() with a new flag P_TREE_GRPEXITED and skip it for all pg_jobc calculations after the flag is set.
Add checker that independently recalculates pg_jobc value and compares it with the memoized process group state. This is enabled under INVARIANTS.
Reviewed by: jilles Discussed with: kevans Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D26116
show more ...
|
Revision tags: release/11.4.0 |
|
#
5a90435c |
| 25-May-2020 |
Mateusz Guzik <mjg@FreeBSD.org> |
proc: refactor clearing credentials into proc_unset_cred
|
#
8de97f39 |
| 09-Apr-2020 |
Rick Macklem <rmacklem@FreeBSD.org> |
Remove the old NFS lock device driver that uses Giant.
This NFS lock device driver was replaced by the kernel NLM around FreeBSD7 and has not normally been used since then. To use it, the kernel had
Remove the old NFS lock device driver that uses Giant.
This NFS lock device driver was replaced by the kernel NLM around FreeBSD7 and has not normally been used since then. To use it, the kernel had to be built without "options NFSLOCKD" and the nfslockd.ko had to be deleted as well. Since it uses Giant and is no longer used, this patch removes it.
With this device driver removed, there is now a lot of unused code in the userland rpc.lockd. That will be removed on a future commit.
Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D22933
show more ...
|
#
59838c1a |
| 01-Apr-2020 |
John Baldwin <jhb@FreeBSD.org> |
Retire procfs-based process debugging.
Modern debuggers and process tracers use ptrace() rather than procfs for debugging. ptrace() has a supserset of functionality available via procfs and new deb
Retire procfs-based process debugging.
Modern debuggers and process tracers use ptrace() rather than procfs for debugging. ptrace() has a supserset of functionality available via procfs and new debugging features are only added to ptrace(). While the two debugging services share some fields in struct proc, they each use dedicated fields and separate code. This results in extra complexity to support a feature that hasn't been enabled in the default install for several years.
PR: 244939 (exp-run) Reviewed by: kib, mjg (earlier version) Relnotes: yes Differential Revision: https://reviews.freebsd.org/D23837
show more ...
|
#
bc02c18c |
| 07-Feb-2020 |
Dimitry Andric <dim@FreeBSD.org> |
Merge ^/head r357408 through r357661.
|
#
58aa35d4 |
| 03-Feb-2020 |
Warner Losh <imp@FreeBSD.org> |
Remove sparc64 kernel support
Remove all sparc64 specific files Remove all sparc64 ifdefs Removee indireeect sparc64 ifdefs
|