History log of /openbsd-src/sys/kern/kern_fork.c (Results 26 – 50 of 268)
Revision Date Author Comments
# f11c99e6 02-Nov-2022 guenther <guenther@openbsd.org>

Clean up more ancient history: since 2015 the libc stubs for
fork/vfork/__tfork haven't cared about the second return register.
So, stop setting retval[1] in kern_fork.c and stop setting the
second r

Clean up more ancient history: since 2015 the libc stubs for
fork/vfork/__tfork haven't cared about the second return register.
So, stop setting retval[1] in kern_fork.c and stop setting the
second return register in the MD child_return() routines.

With the above, we have no multi-register return values on LP64,
so stop touching that register in the trapframe on those archs.

testing miod@ and aoyama@
ok miod@

show more ...


# 0d280c5f 14-Aug-2022 jsg <jsg@openbsd.org>

remove unneeded includes in sys/kern
ok mpi@ miod@


# 608889eb 23-Jul-2022 cheloha <cheloha@openbsd.org>

kernel: remove global "randompid" toggle

Apparently, we used to created several kthreads before the kernel
random number generator was up and running. A toggle, "randompid",
was needed to tell allo

kernel: remove global "randompid" toggle

Apparently, we used to created several kthreads before the kernel
random number generator was up and running. A toggle, "randompid",
was needed to tell allocpid() whether it made sense to attempt to
allocate random PIDs.

However, these days we get e.g. arc4random(9) into a working state
before any kthreads are spawned, so the toggle is no longer needed.

Thread: https://marc.info/?l=openbsd-tech&m=165541052614453&w=2

Very nice historical context provided by miod@.

probably ok miod@ deraadt@

show more ...


# 77aba2be 13-May-2022 claudio <claudio@openbsd.org>

Use the process ps_mtx to protect the process sigacts structure.
With this cursig(), postsig() and trapsignal() become safe to be called
without KERNEL_LOCK. As a side-effect sleep with PCATCH no lon

Use the process ps_mtx to protect the process sigacts structure.
With this cursig(), postsig() and trapsignal() become safe to be called
without KERNEL_LOCK. As a side-effect sleep with PCATCH no longer needs
the KERNEL_LOCK either. Since sending a signal can happen from interrupt
context raise the ps_mtx IPL to high.
Feedback from mpi@ and kettenis@
OK kettenis@

show more ...


# a97e0511 17-Mar-2022 visa <visa@openbsd.org>

Use the refcnt API with struct ucred.

OK bluhm@


# 6ac18ccb 10-Dec-2021 guenther <guenther@openbsd.org>

Revert "kbind(2): disable system call if not initialized before
first __tfork(2)"

The immediate issue is that a process linked with -znow will still
perform lazy relocation on objects loaded with dl

Revert "kbind(2): disable system call if not initialized before
first __tfork(2)"

The immediate issue is that a process linked with -znow will still
perform lazy relocation on objects loaded with dlopen(), but there
are possibly other dark corners to plumb to find a better invariant.

Problem reported by thfr@

show more ...


# f745c206 05-Dec-2021 cheloha <cheloha@openbsd.org>

kbind(2): disable system call if not initialized before first __tfork(2)

To unlock kbind(2) we need to protect ps_kbind_addr and
ps_kbind_cookie.

The simplest way to do this is to disallow kbind(2)

kbind(2): disable system call if not initialized before first __tfork(2)

To unlock kbind(2) we need to protect ps_kbind_addr and
ps_kbind_cookie.

The simplest way to do this is to disallow kbind(2) initialization
after the first __tfork(2) call. If the first thread does not
initialize the kbind(2) variables before __tfork(2) then we disable
kbind(2) during that first __tfork(2) call.

This is guenther@'s patch, I'm just committing it.

Discussed with guenther@, deraadt@, kettenis@, and mpi@.

ok kettenis@, positive response from mpi@, "I am busy" guenther@

show more ...


# 4b2f352d 19-Jun-2021 cheloha <cheloha@openbsd.org>

timeout(9): change argument order for timeout_set_kclock()

Move the kclock argument before the flags argument. XORing a bunch of
flags together may "sprawl", and I'd rather have any sprawl at the e

timeout(9): change argument order for timeout_set_kclock()

Move the kclock argument before the flags argument. XORing a bunch of
flags together may "sprawl", and I'd rather have any sprawl at the end
of the parameter list.

timeout_set_kclock() is undocumented and there is only one caller, so
no big refactor required.

Best to do this argument order shuffle before any bigger refactors of
e.g. timeout_set(9).

show more ...


# af896491 23-Mar-2021 mpi <mpi@openbsd.org>

Make a child execute fork_return() only if PTRACE_FORK has been specified.

fork_return() does an additional check to send a SIGTRAP (for a debugger)
but this signal might overwrite the SIGSTOP gener

Make a child execute fork_return() only if PTRACE_FORK has been specified.

fork_return() does an additional check to send a SIGTRAP (for a debugger)
but this signal might overwrite the SIGSTOP generated by the parent doing
a PT_ATTACH before the child has a change to execute any instruction.

Prevent a race visible only on SP system with regress/sys/kern/ptrace2.

ok kettenis@

show more ...


# 86c58351 15-Feb-2021 mpi <mpi@openbsd.org>

Move single_thread_set() out of KERNEL_LOCK().

Use the SCHED_LOCK() to ensure `ps_thread' isn't being modified by a sibling
when entering tsleep(9) w/o KERNEL_LOCK().

ok visa@


# 7af3a068 11-Feb-2021 otto <otto@openbsd.org>

"proc: table is full" actually means thread table is full; ok mpi@ sthen@


# 193f316c 08-Feb-2021 mpi <mpi@openbsd.org>

Revert the convertion of per-process thread into a SMR_TAILQ.

We did not reach a consensus about using SMR to unlock single_thread_set()
so there's no point in keeping this change.


# 9e1c4ad6 17-Jan-2021 mvs <mvs@openbsd.org>

Cache parent's pid as `ps_ppid' and use it instead of `ps_pptr->ps_pid'.
This allows us to unlock getppid(2).

ok mpi@


# b21c774f 07-Dec-2020 mpi <mpi@openbsd.org>

Convert the per-process thread list into a SMR_TAILQ.

Currently all iterations are done under KERNEL_LOCK() and therefor use
the *_LOCKED() variant.

From and ok claudio@


# f75b2ed9 04-Dec-2020 mpi <mpi@openbsd.org>

Prevent a TOCTOU race in single_thread_set() by extending the scope of the lock.

Make sure `ps_single' is set only once by checking then updating it without
releasing the lock.

Analyzed by and ok c

Prevent a TOCTOU race in single_thread_set() by extending the scope of the lock.

Make sure `ps_single' is set only once by checking then updating it without
releasing the lock.

Analyzed by and ok claudio@

show more ...


# 3ba77c92 02-Dec-2020 mpi <mpi@openbsd.org>

Revert previous extension of the SCHED_LOCK(), the state isn't passed down.

Panic reported by dhill@


# 1ea95950 02-Dec-2020 mpi <mpi@openbsd.org>

Prevent a TOCTOU race in single_thread_set() by extending the scope of the lock.

Make sure `ps_single' is set only once by checking then updating it without
releasing the lock.

Analyzed by and ok c

Prevent a TOCTOU race in single_thread_set() by extending the scope of the lock.

Make sure `ps_single' is set only once by checking then updating it without
releasing the lock.

Analyzed by and ok claudio@

show more ...


# 56119134 25-Oct-2020 cheloha <cheloha@openbsd.org>

setitimer(2): ITIMER_REAL: use kclock timeouts

Reimplement the ITIMER_REAL interval timer with a kclock timeout.

Couple things of note:

- We need to use the high-res nanouptime(9) call, not the lo

setitimer(2): ITIMER_REAL: use kclock timeouts

Reimplement the ITIMER_REAL interval timer with a kclock timeout.

Couple things of note:

- We need to use the high-res nanouptime(9) call, not the low-res
getnanouptime(9).
- The code is simpler now that we aren't working with ticks.

Misc. thoughts:

- Still unsure if "kclock" is the right name for these things.
- MP-safely cancelling a periodic timeout is very difficult.

show more ...


# 3d15958b 20-Mar-2020 claudio <claudio@openbsd.org>

Use atomic operations to update ps_singlecount. This makes
single_thread_check() safe to be called without KERNEL_LOCK().
single_thread_wait() needs to use sleep_setup() and sleep_finish()
instead of

Use atomic operations to update ps_singlecount. This makes
single_thread_check() safe to be called without KERNEL_LOCK().
single_thread_wait() needs to use sleep_setup() and sleep_finish()
instead of tsleep() to make sure no wakeup() is lost.
Input kettenis@, with and OK visa@

show more ...


# 8fb2af3a 16-Mar-2020 mpi <mpi@openbsd.org>

Keep track of traced child under a list of orphans while they are being
reparented to a debugger process.

Also re-parent exiting traced processes to their original parent, if it
is still alive, afte

Keep track of traced child under a list of orphans while they are being
reparented to a debugger process.

Also re-parent exiting traced processes to their original parent, if it
is still alive, after the debugger has seen the exit status.

Logic comes from FreeBSD pointed out by guenther@.

While here rename proc_reparent() into process_reparent() and get rid of
superfluous checks.

ok visa@

show more ...


# 3d8a8d53 21-Feb-2020 claudio <claudio@openbsd.org>

Remove sigacts structure sharing. The only process that used sharing was
proc0 which is used for kthreads and idle threads. proc0 and all those
other kernel threads don't handle signals so there is n

Remove sigacts structure sharing. The only process that used sharing was
proc0 which is used for kthreads and idle threads. proc0 and all those
other kernel threads don't handle signals so there is no benefit in sharing.
Simplifies the code a fair bit since the refcnt is gone.
OK kettenis@

show more ...


# 24e0bd45 30-Jan-2020 mpi <mpi@openbsd.org>

Split `p_priority' into `p_runpri' and `p_slppri'.

Using different fields to remember in which runqueue or sleepqueue
threads currently are will make it easier to split the SCHED_LOCK().

With this

Split `p_priority' into `p_runpri' and `p_slppri'.

Using different fields to remember in which runqueue or sleepqueue
threads currently are will make it easier to split the SCHED_LOCK().

With this change, the (potentially boosted) sleeping priority is no
longer overwriting the thread priority. This let us get rids of the
logic required to synchronize `p_priority' with `p_usrpri'.

Tested by many, ok visa@

show more ...


# 1021dd3d 21-Jan-2020 visa <visa@openbsd.org>

Make __thrsleep(2) and __thrwakeup(2) MP-safe

Threads in __thrsleep(2) are tracked using queues, one queue per each
process for synchronization between threads of a process, and one
system-wide queu

Make __thrsleep(2) and __thrwakeup(2) MP-safe

Threads in __thrsleep(2) are tracked using queues, one queue per each
process for synchronization between threads of a process, and one
system-wide queue for the special ident -1 handling. Each of these
queues has an associated rwlock that serializes access.

The queue lock is released when calling copyin() and copyout() in
thrsleep(). This preserves the existing behaviour where a blocked copy
operation does not prevent other threads from making progress.

Tested by anton@, claudio@
OK anton@, claudio@, tedu@, mpi@

show more ...


# e6dd1245 06-Jan-2020 visa <visa@openbsd.org>

Make kqlist part of filedesc and serialize access to it using fdplock.
This choice of locking is guided by knote_fdclose().

OK mpi@, anton@


# babb761d 19-Dec-2019 mpi <mpi@openbsd.org>

Convert infinite sleeps to {m,t}sleep_nsec(9).

ok visa@


1234567891011