History log of /openbsd-src/sys/kern/kern_sig.c (Results 1 – 25 of 359)
Revision Date Author Comments
# d479e871 25-Jan-2025 claudio <claudio@openbsd.org>

Drop flag argument from single_thread_clear(). It is no longer used.
OK mpi@


# b991c667 24-Jan-2025 claudio <claudio@openbsd.org>

Make process_continue take a process as argument.

If curproc is part of the process to continue then that thread is already
running and should be skipped. On top of this add an extra check to only

Make process_continue take a process as argument.

If curproc is part of the process to continue then that thread is already
running and should be skipped. On top of this add an extra check to only
continue threads in state SSTOP to prevent a possible panic in setrunnable.

OK mpi@

show more ...


# e7b80bfb 22-Jan-2025 claudio <claudio@openbsd.org>

Move the if (deep) code block out of the do { } while loop.
If deep the code will now always return and no longer switch or exit.
OK mpi@


# 3f55b3a8 22-Jan-2025 claudio <claudio@openbsd.org>

Make single_thread_check() always return when deep is true and not suspend
the curproc.

There are only two cases where deep != 0. One is the sleep API the other
is single_thread_set depending on fla

Make single_thread_check() always return when deep is true and not suspend
the curproc.

There are only two cases where deep != 0. One is the sleep API the other
is single_thread_set depending on flag. For single_thread_set() the error
never matters if SINGLE_DEEP is set. The call in exec will always return
ERESTART and the ones for pledge et al. do no error checking at all.

For the sleep API sleep_signal_check() now checks the returned errno and
for the new EWOULDBLOCK case it will either stop or ignore the error
depending on the nostop flag.

Also just return ERESTART for the unwind and exit cases since there is
no need to differentiate between the two.

On top of this check the proc p_stat before returning EWOULDBLOCK and
return 0 in case the thread is already stopped. This happens when a
thread calls sleep_setup() and then right after that single_thread_set()
is executed by another thread. The first thread is then immediatly put
to SSTOP and so sleep_signal_check() no longer needs to do something.
sleep_finish() will take care. This should fix debugging of multithreaded
processes.

OK mpi@

show more ...


# f3c984cf 06-Jan-2025 claudio <claudio@openbsd.org>

Rework SIGCONT handling.

Instead of sending SIGCONT to all threads only send the signal to one thread.
This thread will then continue the whole process. This is done by a new
function process_contin

Rework SIGCONT handling.

Instead of sending SIGCONT to all threads only send the signal to one thread.
This thread will then continue the whole process. This is done by a new
function process_continue() which is also now used by single_thread_clear().

With this a multithreaded process using a SIGCONT handler will only get the
signal delivered once instead of to every thread.

OK mpi@

show more ...


# c7672172 28-Dec-2024 mvs <mvs@openbsd.org>

Unlock KERN_NOSUIDCOREDUMP.

`nosuidcoredump' is atomically accessed integer. coredump() reads it
multiple times, so cache value to `nosuidcoredump_local'.

ok bluhm


# 0c9ac863 17-Dec-2024 claudio <claudio@openbsd.org>

Mark processes that are stopped because of a ptrace trap as PS_TRAPPED.

Use this flag instead of ps_single in dowait6() to decide if a process
was stopped because of a ptrace event.
OK mpi@


# d17ca878 24-Nov-2024 claudio <claudio@openbsd.org>

Do not clear P_WSLEEP in ptsigna's SIGCONT handling. cursig() no longer
stops threads while called during the sleep transition and so there is
no need to clear P_WSLEEP.
OK mpi@


# 315d09db 20-Nov-2024 claudio <claudio@openbsd.org>

No need to call unsleep() if p_wchan is NULL.
OK mpi@


# 74531700 16-Nov-2024 claudio <claudio@openbsd.org>

Adjust deep logic in cursig() to handle sig_stop specially.

If any other signal is pending the stop signal should be deferred.
Now cursig() uses ffs() to select the signal and so higher numbered
sig

Adjust deep logic in cursig() to handle sig_stop specially.

If any other signal is pending the stop signal should be deferred.
Now cursig() uses ffs() to select the signal and so higher numbered
signals like SIGUSR1 would be ignored when going to sleep.
So handle default stop signals specially in the deep case, stash them
and only use them if no other signal is pending.

Fix for signal-stress regress (problem reported by anton@)
With and OK mpi@

show more ...


# feb640d4 16-Nov-2024 claudio <claudio@openbsd.org>

Remove unreachable check for orphaned process groups in cursig.

setsigctx() now does this check and clears sig_stop in that case and
instead set sig_ignore. So the check in cursig that is based on s

Remove unreachable check for orphaned process groups in cursig.

setsigctx() now does this check and clears sig_stop in that case and
instead set sig_ignore. So the check in cursig that is based on sig_stop
can never be true.
OK mpi@

show more ...


# c387b132 06-Nov-2024 claudio <claudio@openbsd.org>

Factor out the ptrace trap into proc_trap() and simplify the signal
delivery in cursig() a lot since most of that is no longer needed.
On top of this properly handle sending a blocked signal from gdb

Factor out the ptrace trap into proc_trap() and simplify the signal
delivery in cursig() a lot since most of that is no longer needed.
On top of this properly handle sending a blocked signal from gdb to
the debugged process by putting the signal into to proc p_siglist.
OK kettenis@

show more ...


# 2de7505c 05-Nov-2024 claudio <claudio@openbsd.org>

Unlock ptsignal by using the ps_mtx instead of KERNEL_LOCK to ensure
the process is not modified during signal delivery.
This also unlocks psignal and prsignal since those are simple wrappers
around

Unlock ptsignal by using the ps_mtx instead of KERNEL_LOCK to ensure
the process is not modified during signal delivery.
This also unlocks psignal and prsignal since those are simple wrappers
around ptsignal.

OK mpi@

show more ...


# af61481e 05-Nov-2024 jsg <jsg@openbsd.org>

remove VATTR_NULL() define, directly call vattr_null()

There used to be a predefined null vattr for !DIAGNOSTIC
but that was removed in vnode.h rev 1.84 in 2007.

ok semarie@ miod@


# fe1c98ea 04-Nov-2024 claudio <claudio@openbsd.org>

Properly handle stop signals in cursig if deep.

In setsigctx() set sig_stop to 1 if the process should be stopped.
In cursig() still return early if deep but then in sleep_signal_check()
use this in

Properly handle stop signals in cursig if deep.

In setsigctx() set sig_stop to 1 if the process should be stopped.
In cursig() still return early if deep but then in sleep_signal_check()
use this information to call proc_stop and stop the proc.
This should fix the problem in the waitid regress test.
OK mpi@

show more ...


# 07d26032 22-Oct-2024 claudio <claudio@openbsd.org>

Protect the ps_pgrp pointer by either the KERNEL_LOCK or the ps_mtx.

This should be enough to be on the safe side when unlocking ptsignal
where a pr->ps_pgrp->pg_jobc == 0 check happens.
OK mpi@ ket

Protect the ps_pgrp pointer by either the KERNEL_LOCK or the ps_mtx.

This should be enough to be on the safe side when unlocking ptsignal
where a pr->ps_pgrp->pg_jobc == 0 check happens.
OK mpi@ kettenis@

show more ...


# 3b30ff2a 17-Oct-2024 claudio <claudio@openbsd.org>

Shortcut cursig when called during sleep setup.

Add deep flag as function argument which is used by the sleep API but
nowhere else. Both calls to sleep_signal_check() should skip the ugly
bits of cu

Shortcut cursig when called during sleep setup.

Add deep flag as function argument which is used by the sleep API but
nowhere else. Both calls to sleep_signal_check() should skip the ugly
bits of cursig().

In cursig() if deep once it is clear a signal will be taken keep the
signal on the thread siglist and return. sleep_signal_check() will then
return EINTR or ERESTART based on the signal context. There is no reason
to do more in this special case. Especially stop/cont and the ptrace trap
must be skipped here. Once the call makes it to userret the signal will be
picked up again and handled in a safe location.

Stopping singals need some additional logic since we don't want to abort
the sleep just to stop a process. Since our SIGSTOP handling requires
a major rewrite this will be posponed until then.

OK mpi@

show more ...


# c3476037 15-Oct-2024 claudio <claudio@openbsd.org>

Indicate that a process has stopped by setting PS_STOPPED flag

The checks in dowait6 and orphanpg using ps_mainproc are flawed and
fail if the mainproc called pthread_exit before the other threads.

Indicate that a process has stopped by setting PS_STOPPED flag

The checks in dowait6 and orphanpg using ps_mainproc are flawed and
fail if the mainproc called pthread_exit before the other threads.
Adding the flag in proc_stop_sweep is racy but the best we have right now.
This fixes regress/sys/kern/signal/sig-stop3.

OK mpi@

show more ...


# 133ff0d4 09-Oct-2024 claudio <claudio@openbsd.org>

Clear ps_xsig when continuing after a PS_TRACED stop.

Also remove the ps_xsig handling in setrunnable() it is in the wrong spot
and causes signals to be delivered over and over again.

Attaching to

Clear ps_xsig when continuing after a PS_TRACED stop.

Also remove the ps_xsig handling in setrunnable() it is in the wrong spot
and causes signals to be delivered over and over again.

Attaching to an already stopped process is affected by this. The SIGSTOP
sent by ptrace is now ignored in ptsignal() and as a result gdb will hang
in wait4() until a SIGCONT is delivered to the process. After that all
works as usual.

OK mpi@

show more ...


# 2d5a4214 09-Oct-2024 claudio <claudio@openbsd.org>

Convert prsignal() into a real function

Also do not use ps_mainproc as the thread the signal is send to. Sending
a signal to ps_mainproc may not work reliably if it already exited. Use
TAILQ_FIRST(&

Convert prsignal() into a real function

Also do not use ps_mainproc as the thread the signal is send to. Sending
a signal to ps_mainproc may not work reliably if it already exited. Use
TAILQ_FIRST(&pr->ps_threads) instead but first check that the process has
not yet entered exit1().

OK mpi@

show more ...


# 67526adf 01-Oct-2024 claudio <claudio@openbsd.org>

Adjust ptrace interface to properly suport single threaded continue.

Introduce P_TRACESINGLE flag to instruct the trapped thread to not
wakeup the other threads (via single_thread_clear). This must

Adjust ptrace interface to properly suport single threaded continue.

Introduce P_TRACESINGLE flag to instruct the trapped thread to not
wakeup the other threads (via single_thread_clear). This must be done
like this since ptrace must wake just the single thread to ensure it
runs first and gets the ps_xsig value from ptrace.

Modern gdb depends on this for multi-threaded processes, when a breakpoint
is hit gdb fixes up the trapping instruction and then single steps over
it with only that thread. After that single step gdb continues with all
threads. If all threads are run like now it is possible that one of the
other threads hits a breakpoint before the single step is done which results
in an assertion in gdb (because that is not expected).
OK mpi@

show more ...


# 9221c00b 10-Aug-2024 jsg <jsg@openbsd.org>

spelling; ok claudio@


# 0747e3d2 06-Aug-2024 claudio <claudio@openbsd.org>

Stop using KERNEL_LOCK to protect the per process kqueue list

Instead of the KERNEL_LOCK use the ps_mtx for most operations.
If the ps_klist is modified an additional global rwlock (kqueue_ps_list_l

Stop using KERNEL_LOCK to protect the per process kqueue list

Instead of the KERNEL_LOCK use the ps_mtx for most operations.
If the ps_klist is modified an additional global rwlock (kqueue_ps_list_lock)
is required. This includes the knotes with NOTE_FORK and NOTE_EXIT since
in either cases a ps_klist is changed. In the NOTE_FORK | NOTE_TRACK case
the call to kqueue_register() can sleep this is why a global rwlock is used.

Adjust the reaper() to call knote_processexit() without KERNEL_LOCK.
Double lock idea from visa@
OK mvs@

show more ...


# 235013eb 29-Jul-2024 claudio <claudio@openbsd.org>

Move the signal related kqueue filters to kern_event.c.

Since proc and signal filters share the same klist it makes sense
to keep them together.
OK mvs@


# c4fac757 29-Jul-2024 claudio <claudio@openbsd.org>

Replace per thread P_CONTINUED with per process PS_CONTINUED flag

dowait6() can only look at per process state so switch this over.
Right now SIGCONT handling in ptsignal is recursive and not quite

Replace per thread P_CONTINUED with per process PS_CONTINUED flag

dowait6() can only look at per process state so switch this over.
Right now SIGCONT handling in ptsignal is recursive and not quite
right but this is a step in the right direction. It fixes dowait6()
handling for multithreaded processes where the main thread exited.

OK mpi@

show more ...


12345678910>>...15