History log of /openbsd/sys/kern/kern_sig.c (Results 1 – 25 of 348)
Revision Date Author Comments
# 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 ...


# 350ab3c3 24-Jul-2024 claudio <claudio@openbsd.org>

KASSERT that the ps_single proc has P_SUSPSINGLE cleared.
Requested by kettenis@ and guenther@


# ba2390ce 22-Jul-2024 claudio <claudio@openbsd.org>

Rename PS_STOPPED to PS_STOPPING. I want to use PS_STOPPED to indicate
that a process has been stopped so make room for that.
OK kettenis@


# 49d7ba99 10-Jul-2024 claudio <claudio@openbsd.org>

Kill the runfast and run label and inline those bits. No functional change.
OK mpi@


# 2119f62e 09-Jul-2024 claudio <claudio@openbsd.org>

Reshuffle the switch cases in ptsignal and single_thread_set to be
in the order needed for future changes. No functional change.
OK mpi@


# a09e9584 03-Jun-2024 claudio <claudio@openbsd.org>

Remove the now unsued s argument to SCHED_LOCK and SCHED_UNLOCK.

The SPL level is not tacked by the mutex and we no longer need to track
this in the callers.
OK miod@ mlarkin@ tb@ jca@


# 31342e3c 22-May-2024 claudio <claudio@openbsd.org>

In the big p_stat switch in ptsignal do not call return but instead
use one of the gotos. In this case goto out with mask and prop set to 0.

OK jca@


# 223cf45d 20-May-2024 claudio <claudio@openbsd.org>

Rework interaction between sleep API and exit1() and start unlocking ps_threads

This diff adjusts how single_thread_set() accounts the threads by using
ps_threadcnt as initial value and counting all

Rework interaction between sleep API and exit1() and start unlocking ps_threads

This diff adjusts how single_thread_set() accounts the threads by using
ps_threadcnt as initial value and counting all threads out that are already
parked. In single_thread_check call exit1() before decreasing ps_singlecount
this is now done in exit1().

exit1() and thread_fork() ensure that ps_threadcnt is updated with the
pr->ps_mtx held and in exit1() also account for exiting threads since
exit1() can sleep.

OK mpi@

show more ...


# 0e44f21d 08-May-2024 claudio <claudio@openbsd.org>

Rework how action SIG_HOLD is handled in ptsignal.

Since we want to unlock sigsuspend, ptsignal needs to double check in the
SSLEEP case that the signal being delivered is still masked or unmasked.

Rework how action SIG_HOLD is handled in ptsignal.

Since we want to unlock sigsuspend, ptsignal needs to double check in the
SSLEEP case that the signal being delivered is still masked or unmasked.
Remove the early return for action SIG_HOLD so that the SSLEEP case can
properly recheck the sigmask.

On top of this update siglist only in one place at the end of ptsignal
this now includes the clearing of signals for the SA_CONT and SA_STOP
cases.

OK mpi@

show more ...


# 3809f4f1 07-May-2024 claudio <claudio@openbsd.org>

In Rev 1.296 the update of the siglist was moved to the end of ptsignal().
One atomic_clearbits_int() hiding in SSTOP was missed when converting all
the exceptions that cleared the siglist again. Ins

In Rev 1.296 the update of the siglist was moved to the end of ptsignal().
One atomic_clearbits_int() hiding in SSTOP was missed when converting all
the exceptions that cleared the siglist again. Instead of clearing the bits
the mask needs to be set to 0 so that it is properly ignored.
OK mpi@

show more ...


# d7e8b29a 18-Apr-2024 claudio <claudio@openbsd.org>

If a proc has P_WEXIT set do not stop it, let it exit since it is already
mostly dead.

This is more like belts and suspenders since a proc in exit1() will not
receive signals anymore and so proc_sto

If a proc has P_WEXIT set do not stop it, let it exit since it is already
mostly dead.

This is more like belts and suspenders since a proc in exit1() will not
receive signals anymore and so proc_stop() should not be reachable. This
is even the case when sigexit() is called and a coredump() is happening.
OK mpi@

show more ...


# a2f40c7d 10-Apr-2024 claudio <claudio@openbsd.org>

Unlock dosigsuspend() and with that some aspects of ppoll and pselect

Change p_sigmask from atomic back to non-atomic updates. All changes to
p_sigmask are only allowed by curproc (the owner). There

Unlock dosigsuspend() and with that some aspects of ppoll and pselect

Change p_sigmask from atomic back to non-atomic updates. All changes to
p_sigmask are only allowed by curproc (the owner). There is no need for
atomic instructions here.

p_sigmask is mostly accessed by curproc with the exception of ptsignal().
In ptsignal() p_sigmask is now only read once unless a SSLEEP proc gets
the signal. In that case recheck the p_sigmask before wakeup to ensure
that no unnecessary wakeup happens.

Add some KASSERT(p == curproc) to ensure this precondition.
sigabort() is special since it is also called by ddb but apart from that
only works for curproc.

With and OK mvs@ OK mpi@

show more ...


12345678910>>...14