summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_sig.c
Commit message (Collapse)AuthorAgeFilesLines
* Don't restart a timeout wait in kern_sigtimedwait, also allow itdavidxu2005-02-191-11/+27
| | | | to wait longer than a single integer can represent.
* Backout previous change (disabling of security checks for signals deliveredsobomax2005-02-131-22/+11
| | | | | | in emulation layers), since it appears to be too broad. Requested by: rwatson
* Split out kill(2) syscall service routine into user-level and kernel part, thesobomax2005-02-131-11/+22
| | | | | | | | | | | | | | | | | former is callable from user space and the latter from the kernel one. Make kernel version take additional argument which tells if the respective call should check for additional restrictions for sending signals to suid/sugid applications or not. Make all emulation layers using non-checked version, since signal numbers in emulation layers can have different meaning that in native mode and such protection can cause misbehaviour. As a result remove LIBTHR from the signals allowed to be delivered to a suid/sugid application. Requested (sorta) by: rwatson MFC after: 2 weeks
* /* -> /*- for copyright notices, minor format tweaks as necessaryimp2005-01-061-1/+1
|
* - If delivering a signal will result in killing a process that has ajeff2004-12-131-0/+2
| | | | | | nice value above 0, set it to 0 so that it may proceed with haste. This is especially important on ULE, where adjusting the priority does not guarantee that a thread will be granted a greater time slice.
* Fix an off by one error. MAXPATHLEN already has +1.imp2004-11-151-1/+1
|
* Allow kill -9 to kill processes stuck in procfs STOPEVENTs.alfred2004-10-301-0/+10
|
* Backout 1.291.alfred2004-10-291-10/+0
| | | | | re doesn't seem to think this fixes: Desired features for 5.3-RELEASE "More truss problems"
* Use scheduler api to adjust thread priority.davidxu2004-10-051-2/+3
|
* Don't bother to turn off other P_STOPPED bits for SIGKILL, doingdavidxu2004-10-031-1/+1
| | | | | | so would cause kernel to produce an unkillable process in some cases, especially, P_STOPPED_SINGLE has a singling thread, turning off the bit would mess the state.
* Clear a process's procfs trace points upon delivery of SIGKILL.alfred2004-10-011-0/+10
| | | | MT5 candidate. (Desired features for 5.3-RELEASE "More truss problems")
* Remove an unneeded argument..julian2004-08-311-1/+1
| | | | | | | | | The removed argument could trivially be derived from the remaining one. That in turn should be the same as curthread, but it is possible that curthread could be expensive to derive on some syste,s so leave it as an argument. Having both proc and thread as an argumen tjust gives an opportunity for them to get out sync. MFC after: 3 days
* Add locking to the kqueue subsystem. This also makes the kqueue subsystemjmg2004-08-151-7/+3
| | | | | | | | | | | | | a more complete subsystem, and removes the knowlege of how things are implemented from the drivers. Include locking around filter ops, so a module like aio will know when not to be unloaded if there are outstanding knotes using it's filter ops. Currently, it uses the MTX_DUPOK even though it is not always safe to aquire duplicate locks. Witness currently doesn't support the ability to discover if a dup lock is ok (in some cases). Reviewed by: green, rwatson (both earlier versions)
* add option to automaticly mark core dumps with the nodump flagjmg2004-08-091-0/+6
| | | | | PR: 57065 Submitted by: Walter C. Pelissero
* Don't skip permission checks when sending signals to zombie processes.pjd2004-08-031-13/+7
| | | | | Pointed out by: bde Reviewed by: rwatson
* Syscall kill(2) called for a zombie process should return 0.pjd2004-07-291-1/+10
| | | | Obtained from: Darwin
* Improve readability a bit by changing some code at the end of a functionjhb2004-07-161-6/+2
| | | | | | | | | | | | | | | | that did: if (foo) return else blah to just do the simpler if (!foo) blah instead.
* Add code to support debugging threaded process.davidxu2004-07-131-44/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Add tm_lwpid into kse_thr_mailbox to indicate which kernel thread current user thread is running on. Add tm_dflags into kse_thr_mailbox, the flags is written by debugger, it tells UTS and kernel what should be done when the process is being debugged, current, there two flags TMDF_SSTEP and TMDF_DONOTRUNUSER. TMDF_SSTEP is used to tell kernel to turn on single stepping, or turn off if it is not set. TMDF_DONOTRUNUSER is used to tell kernel to schedule upcall whenever possible, to UTS, it means do not run the user thread until debugger clears it, this behaviour is necessary because gdb wants to resume only one thread when the thread's pc is at a breakpoint, and thread needs to go forward, in order to avoid other threads sneak pass the breakpoints, it needs to remove breakpoint, only wants one thread to go. Also, add km_lwp to kse_mailbox, the lwp id is copied to kse_thr_mailbox at context switch time when process is not being debugged, so when process is attached, debugger can map kernel thread to user thread. 2. Add p_xthread to proc strcuture and td_xsig to thread structure. p_xthread is used by a thread when it wants to report event to debugger, every thread can set the pointer, especially, when it is used in ptracestop, it is the last thread reporting event will win the race. Every thread has a td_xsig to exchange signal with debugger, thread uses TDF_XSIG flag to indicate it is reporting signal to debugger, if the flag is not cleared, thread will keep retrying until it is cleared by debugger, p_xthread may be used by debugger to indicate CURRENT thread. The p_xstat is still in proc structure to keep wait() to work, in future, we may just use td_xsig. 3. Add TDF_DBSUSPEND flag, the flag is used by debugger to suspend a thread. When process stops, debugger can set the flag for thread, thread will check the flag in thread_suspend_check, enters a loop, unless it is cleared by debugger, process is detached or process is existing. The flag is also checked in ptracestop, so debugger can temporarily suspend a thread even if the thread wants to exchange signal. 4. Current, in ptrace, we always resume all threads, but if a thread has already a TDF_DBSUSPEND flag set by debugger, it won't run. Encouraged by: marcel, julian, deischen
* Implement the PT_LWPINFO request. This request can be used by themarcel2004-07-121-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | tracing process to obtain information about the LWP that caused the traced process to stop. Debuggers can use this information to select the thread currently running on the LWP as the current thread. The request has been made compatible with NetBSD for as much as possible. This implementation differs from NetBSD in the following ways: 1. The data argument is allowed to be smaller than the size of the ptrace_lwpinfo structure known to the kernel, but not 0. This is opposite to what NetBSD allows. The reason for this is that we can extend the structure without affecting older binaries. 2. On NetBSD the tracing process is to set the pl_lwpid field to the Id of the LWP it wants information of. We don't do that. Our ptrace interface allows passing the LWP Id instead of the PID. The tracing process is to set the PID to the LWP Id it wants information of. 3. When the PID is actually the PID of the tracing process, this request returns the information about the LWP that caused the process to stop. This was the whole purpose of the request in the first place. When the traced process has exited, this request will return the LWP Id 0, indicating that the process state is not the result of an event specific to a LWP.
* - Change mi_switch() and sched_switch() to accept an optional thread tojhb2004-07-021-2/+2
| | | | | | | | | | | | | switch to. If a non-NULL thread pointer is passed in, then the CPU will switch to that thread directly rather than calling choosethread() to pick a thread to choose to. - Make sched_switch() aware of idle threads and know to do TD_SET_CAN_RUN() instead of sticking them on the run queue rather than requiring all callers of mi_switch() to know to do this if they can be called from an idlethread. - Move constants for arguments to mi_switch() and thread_single() out of the middle of the function prototypes and up above into their own section.
* Deorbit COMPAT_SUNOS.phk2004-06-111-19/+7
| | | | | We inherited this from the sparc32 port of BSD4.4-Lite1. We have neither a sparc32 port nor a SunOS4.x compatibility desire these days.
* According to SUSv3, sigwait is different with sigwaitinfo, sigwaitdavidxu2004-06-071-5/+12
| | | | returns error code in return value, not in errno.
* Move TDF_SA from td_flags to td_pflags (and rename it accordingly)tjr2004-06-021-5/+5
| | | | | | | so that it is no longer necessary to hold sched_lock while manipulating it. Reviewed by: davidxu
* Fixed some style bugs in tdsigwakeup().bde2004-05-211-11/+10
|
* In tdsigwakeup(), use TD_ON_SLEEPQ() rather than TD_IS_SLEEPING() to see ifjhb2004-05-201-1/+1
| | | | | | a thread is on a sleep queue and should have it's sleep aborted. Reported by: Thierry Herbelot thierry at herbelot dot com
* stop() no longer needs sched_lock held; in fact, holding sched_lock causescperciva2004-04-121-3/+2
| | | | | | | | a LOR against sleepq. Fix the comment, and fix ptracestop() to pick up sched_lock after stop() rather than before. Reported by: Scott Sipe <cscotts@mindspring.com> Reviewed by: rwatson, jhb
* Remove advertising clause from University of California Regent's license,imp2004-04-051-4/+0
| | | | | | per letter dated July 22, 1999. Approved by: core
* Shorten some XXXKSE commentrypeter2004-03-291-4/+2
|
* - Push down Giant in exit() and wait().jhb2004-03-051-12/+13
| | | | | | | | - Push Giant down a bit in coredump() and call coredump() with the proc lock already held rather than unlocking it only to turn around and relock it. Requested by: peter
* Use different dummy wait channels to avoid panic in msleep().des2004-03-031-3/+3
| | | | Reviewed by: jhb
* Switch the sleep/wakeup and condition variable implementations to use thejhb2004-02-271-16/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | sleep queue interface: - Sleep queues attempt to merge some of the benefits of both sleep queues and condition variables. Having sleep qeueus in a hash table avoids having to allocate a queue head for each wait channel. Thus, struct cv has shrunk down to just a single char * pointer now. However, the hash table does not hold threads directly, but queue heads. This means that once you have located a queue in the hash bucket, you no longer have to walk the rest of the hash chain looking for threads. Instead, you have a list of all the threads sleeping on that wait channel. - Outside of the sleepq code and the sleep/cv code the kernel no longer differentiates between cv's and sleep/wakeup. For example, calls to abortsleep() and cv_abort() are replaced with a call to sleepq_abort(). Thus, the TDF_CVWAITQ flag is removed. Also, calls to unsleep() and cv_waitq_remove() have been replaced with calls to sleepq_remove(). - The sched_sleep() function no longer accepts a priority argument as sleep's no longer inherently bump the priority. Instead, this is soley a propery of msleep() which explicitly calls sched_prio() before blocking. - The TDF_ONSLEEPQ flag has been dropped as it was never used. The associated TDF_SET_ONSLEEPQ and TDF_CLR_ON_SLEEPQ macros have also been dropped and replaced with a single explicit clearing of td_wchan. TD_SET_ONSLEEPQ() would really have only made sense if it had taken the wait channel and message as arguments anyway. Now that that only happens in one place, a macro would be overkill.
* Locking for the per-process resource limits structure.jhb2004-02-041-5/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - struct plimit includes a mutex to protect a reference count. The plimit structure is treated similarly to struct ucred in that is is always copy on write, so having a reference to a structure is sufficient to read from it without needing a further lock. - The proc lock protects the p_limit pointer and must be held while reading limits from a process to keep the limit structure from changing out from under you while reading from it. - Various global limits that are ints are not protected by a lock since int writes are atomic on all the archs we support and thus a lock wouldn't buy us anything. - All accesses to individual resource limits from a process are abstracted behind a simple lim_rlimit(), lim_max(), and lim_cur() API that return either an rlimit, or the current or max individual limit of the specified resource from a process. - dosetrlimit() was renamed to kern_setrlimit() to match existing style of other similar syscall helper functions. - The alpha OSF/1 compat layer no longer calls getrlimit() and setrlimit() (it didn't used the stackgap when it should have) but uses lim_rlimit() and kern_setrlimit() instead. - The svr4 compat no longer uses the stackgap for resource limits calls, but uses lim_rlimit() and kern_setrlimit() instead. - The ibcs2 compat no longer uses the stackgap for resource limits. It also no longer uses the stackgap for accessing sysctl's for the ibcs2_sysconf() syscall but uses kernel_sysctl() instead. As a result, ibcs2_sysconf() no longer needs Giant. - The p_rlimit macro no longer exists. Submitted by: mtm (mostly, I only did a few cleanups and catchups) Tested on: i386 Compiled on: alpha, amd64
* Assert process lock in ptracestop(), since we're going to relyrwatson2004-01-291-0/+1
| | | | on it, and later unlock it.
* Move the part of the comment which applies to osigsuspend wherekan2004-01-281-2/+5
| | | | | | | it belongs. The current sigsuspend syscall does expect a pointer to the mask as argument. Submitted by: Igor Sysoev <is at rambler-co dot ru>
* - Add a flags parameter to mi_switch. The value of flags may be SW_VOL orjeff2004-01-251-4/+2
| | | | | | | | | | SW_INVOL. Assert that one of these is set in mi_switch() and propery adjust the rusage statistics. This is to simplify the large number of users of this interface which were previously all required to adjust the proper counter prior to calling mi_switch(). This also facilitates more switch and locking optimizations. - Change all callers of mi_switch() to pass the appropriate paramter and remove direct references to the process statistics.
* When not creating a core dump due to resource limits specifyingrwatson2004-01-111-1/+1
| | | | | | | | | | | a maximum dump size of 0, return a size-related error, rather than returning success. Otherwise, waitpid() will incorrectly return a status indicating that a core dump was created. Note that the specific error doesn't actually matter, since it's lost. MFC after: 2 weeks PR: 60367 Submitted by: Valentin Nechayev <netch@netch.kiev.ua>
* Drop the sigacts mutex around calls to stopevent() to avoid sleepingrwatson2004-01-081-2/+10
| | | | | | | | | holding the mutex. Because the sigacts pointer can't change while the process is "live" (proc locking (x)), we know our pointer is still valid. In communication with: truckman Reviewed by: jhb
* Make sigaltstack as per-threaded, because per-process sigaltstack statedavidxu2004-01-031-37/+28
| | | | | | | | | | | | | is useless for threaded programs, multiple threads can not share same stack. The alternative signal stack is private for thread, no lock is needed, the orignal P_ALTSTACK is now moved into td_pflags and renamed to TDP_ALTSTACK. For single thread or Linux clone() based threaded program, there is no semantic changed, because those programs only have one kernel thread in every process. Reviewed by: deischen, dfr
* Lock and unlock sched_lock when walking through thread list, current wedavidxu2003-12-071-1/+11
| | | | | insert kse upcall thread into thread list at mi_switch time, process lock is not enough.
* Try to fetch thread mailbox address in page fault trap, so when threaddavidxu2003-10-301-1/+2
| | | | | blocks in page fault hanlder, and upcall thread can be scheduled. It is useful if process is doing lots of mmap based I/O.
* Check (locked) before performing an advisory unlock following a failurerwatson2003-10-251-1/+2
| | | | | | | of vn_start_write(). Otherwise, we may inconsistently attempt to release the advisory lock. Pointed out by: teggej
* When generate a core dump, use advisory locking in an advisory way:rwatson2003-10-251-6/+6
| | | | | | | | | | | if we do acquire an advisory lock, great! We'll release it later. However, if we fail to acquire a lock, we perform the coredump anyway. This problem became particularly visible with NFS after the introduction of rpc.lockd: if the lock manager isn't running, then locking calls will fail, aborting the core dump (resulting in a zero-byte dump file). Reported by: Yogeshwar Shenoy <ynshenoy@alumni.cs.ucsb.edu>
* Don't clear signal mask in execsig(). RELENG_4 does not clear it and POSIXdavidxu2003-10-131-4/+0
| | | | asks to inherit signal mask for execv.
* Move some tracing related code into its own function as it willrobert2003-09-261-15/+24
| | | | | be needed for system call related ptrace functionality I plan to commit soon.
* panic() if we try to handle an out-of-range signal number innectar2003-08-101-2/+5
| | | | | | | | psignal()/tdsignal(). The test was historically in psignal(). It was changed into a KASSERT, and then later moved to tdsignal() when the latter was introduced. Reviewed by: iedowse, jhb
* Use correct signal when calling sigexit.davidxu2003-07-301-1/+3
|
* Add fdidx argument to vn_open() and vn_open_cred() and pass -1 throughout.phk2003-07-271-1/+1
|
* The POSIX spec also requires that kern_sigtimedwait returnmtm2003-07-241-1/+1
| | | | EINVAL if tv_nsec of the timeout is less than zero.
* Always deliver synchronous signal to UTS for SA threads.davidxu2003-07-211-2/+14
|
* Fix sigwait to conform to POSIX.davidxu2003-07-171-67/+109
| | | | | | | | | | | When a signal is being delivered to process, first find a sigwait thread to deliver, POSIX's argument is speed of delivering signal to sigwait thread is faster than other ways. A signal in its wait set will cause sigwait to return the signal number, a signal not in its wait set but in not blocked by the thread also causes sigwait to return, but sigwait returns EINTR, sigwait is oneshot operation, only one signal can be delivered to its wait set, when a signal is delivered to the sigwait thread, the thread's sigwait state is canceled.
OpenPOWER on IntegriCloud