summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_sig.c
Commit message (Collapse)AuthorAgeFilesLines
* - trapsignal() no longer needs to acquire Giant for ktrpsig().jhb2002-06-071-7/+5
| | | | - Catch up to new ktrace API.
* s/!SIGNOTEMPY/SIGISEMPTY/davidc2002-06-061-1/+1
| | | | Reviewed by: marcel, jhb, alfred
* Add POSIX.1-2001 WCONTINUED option for waitpid(2). A proc flagmike2002-06-011-0/+2
| | | | | | | | | | (P_CONTINUED) is set when a stopped process receives a SIGCONT and cleared after it has notified a parent process that has requested notification via waitpid(2) with WCONTINUED specified in its options operand. The status value can be checked with the new WIFCONTINUED() macro. Reviewed by: jake
* CURSIG() is not a macro so rename it cursig().julian2002-05-291-3/+3
| | | | Obtained from: KSE tree
* Change p_can{debug,see,sched,signal}()'s first argument to be a threadjhb2002-05-191-4/+3
| | | | | | | pointer instead of a proc pointer and require the process pointed to by the second argument to be locked. We now use the thread ucred reference for the credential checks in p_can*() as a result. p_canfoo() should now no longer need Giant.
* p_cansignal() returns an errno value; at some point, the check forrwatson2002-05-141-2/+2
| | | | | | | | | | inter-process signalling ceased to preserve and return that value, instead always returning EPERM. This meant that it was possible to "probe" the pid space for processes that were not otherwise visible. This change reverts that reversion. Obtained from: TrustedBSD Project Sponsored by: DARPA, NAI Labs
* Remove trace_req().mini2002-05-091-14/+10
| | | | Reviewed by: alfred, jhb, peter
* expand_name fixes:alfred2002-05-081-38/+32
| | | | | | | | | | | | | | | .) don't use MAXPATHLEN + 1, fix logic to compensate. .) style(9) function parameters. .) fix line wrapping. .) remove duplicated error and string handling code. .) don't NUL terminate already NUL terminated string. .) all string length variables changed from int to size_t. .) constify variables. .) catch when corename would be truncated. .) cast pid_t and uid_t args for format string. .) add parens around return arguments. Help and suggestions from: bde
* M_ZERO the temp buffer in expand_name() otherwise if an error occursalfred2002-05-071-1/+1
| | | | | while logging we may pass a non NUL terminated string to log(9) for a %s format arg.
* Return the correct error code (ENOSYS, not EINVAL) from nosys(). Gettingbde2002-05-051-1/+1
| | | | | | | | | killed by SIGSYS for unimlemented syscalls is bad enough. Obtained from: Lite2 branch The Lite2 branch has some other interesting unmerged (?) bits in this file. They are well hidden among cosmetic regressions.
* - Reorder execve() so that it performs blocking operations before itjhb2002-05-021-2/+1
| | | | | | | | locks the process. - Defer other blocking operations such as vrele()'s until after we release locks. - execsigs() now requires the proc lock to be held when it is called rather than locking the process internally.
* Redo the sigio locking.alfred2002-05-011-4/+10
| | | | | | | | | | | Turn the sigio sx into a mutex. Sigio lock is really only needed to protect interrupts from dereferencing the sigio pointer in an object when the sigio itself is being destroyed. In order to do this in the most unintrusive manner change pgsigio's sigio * argument into a **, that way we can lock internally to the function.
* Avoid the user-visible effect of setting SA_NOCLDWAIT when theiedowse2002-04-271-3/+6
| | | | | | | SIGCHLD handler is SIG_IGN. This is a reimplementation of the problematic revision 1.131 of kern_exit.c. To avoid accessing process UPAGES, we set a new procsig flag when the SIGCHLD handler is SIG_IGN and use that instead.
* Lock proctree_lock instead of pgrpsess_lock.jhb2002-04-161-5/+5
|
* - Change killpg1()'s first argument to be a thread instead of a process sojhb2002-04-131-36/+22
| | | | | | | | | | | | | | | | we can use td_ucred. - In killpg1(), the proc lock is sufficient to check if p_stat is SZOMB or not. We don't need sched_lock. - Close some races in psignal(). In psignal() there is a big switch statement based on p_stat. All the different cases are assuming that the process (or thread) isn't going to change state out from under it. To ensure this is true, just lock sched_lock for the entire switch. We practically held it the entire time already anyways. This also simplifies the locking somewhat and actually results in fewer lock operations. - Allow signotify() to be called with the sched_lock held since psignal() now does that. - Use td_ucred in a couple of places.
* Moved signal handling and rescheduling from userret() to ast() so thatbde2002-04-041-3/+25
| | | | | | | | | | | they aren't in the usual path of execution for syscalls and traps. The main complication for this is that we have to set flags to control ast() everywhere that changes the signal mask. Avoid locking in userret() in most of the remaining cases. Submitted by: luoqi (first part only, long ago, reorganized by me) Reminded by: dillon
* Optimized the check for unmasked pending signals in CURSIG() using a newbde2002-04-041-8/+2
| | | | | | | | | | | inline function sigsetmasked() and a new macro SIGPENDING(). CURSIG() will soon be moved out of the normal path of execution for syscalls and traps. Then its efficiency will be less important but the new interfaces will be useful for checking for unmasked pending signals in more places. Submitted by: luoqi (long ago, in a slightly different form) Assert that sched_lock is not held in CURSIG().
* Fixed some style bugs in the removal of __P(()). The main ones werebde2002-03-241-7/+7
| | | | | | not removing tabs before "__P((", and not outdenting continuation lines to preserve non-KNF lining up of code with parentheses. Switch to KNF formatting and/or rewrap the whole prototype in some cases.
* Remove __P.alfred2002-03-191-10/+10
|
* Fix warning in !SMP case.phk2002-02-261-0/+2
| | | | Submitted by: Maxime Henrion <mux@mu.org>
* Lock struct pgrp, session and sigio.tanimura2002-02-231-15/+29
| | | | | | | | | | | | | | | | | | | | | | | | | New locks are: - pgrpsess_lock which locks the whole pgrps and sessions, - pg_mtx which protects the pgrp members, and - s_mtx which protects the session members. Please refer to sys/proc.h for the coverage of these locks. Changes on the pgrp/session interface: - pgfind() needs the pgrpsess_lock held. - The caller of enterpgrp() is responsible to allocate a new pgrp and session. - Call enterthispgrp() in order to enter an existing pgrp. - pgsignal() requires a pgrp lock held. Reviewed by: jhb, alfred Tested on: cvsup.jp.FreeBSD.org (which is a quad-CPU machine running -current)
* Fixed a typo in rev.1.65 that gave a reference to a nonexistent variable.bde2002-02-151-1/+1
| | | | This was not detected by LINT because LINT is missing COMPAT_SUNOS.
* In a threaded world, differnt priorirites become properties ofjulian2002-02-111-4/+3
| | | | | | different entities. Make it so. Reviewed by: jhb@freebsd.org (john baldwin)
* Add a comment indicating that VOP_GETATTR() is called without appropriaterwatson2002-02-101-0/+2
| | | | locking in the core dump code. This should be fixed.
* Pre-KSE/M3 commit.julian2002-02-071-2/+2
| | | | | | | | | | this is a low-functionality change that changes the kernel to access the main thread of a process via the linked list of threads rather than assuming that it is embedded in the process. It IS still embeded there but remove all teh code that assumes that in preparation for the next commit which will actually move it out. Reviewed by: peter@freebsd.org, gallatin@cs.duke.edu, benno rice,
* o Revert kern_sig.c#1.143, as cr_cansignal() doesn't currently permitrwatson2002-01-101-3/+14
| | | | | | | a number of desirable cases in which SIGIO/SIGURG are delivered. We'll keep tweaking. Reported by: Alexander Kabaev <ak03@gte.com>
* - Teach SIGIO code to use cr_cansignal() instead of a custom CANSIGIO()rwatson2002-01-061-13/+3
| | | | | | | | | | | | | | | | | | | macro. As a result, mandatory signal delivery policies will be applied consistently across the kernel. - Note that this subtly changes the protection semantics, and we should watch out for any resulting breakage. Previously, delivery of SIGIO in this circumstance was limited to situations where the subject was privileged, or where one of the subject's (ruid, euid) matched one of the object's (ruid, euid). In the new scenario, subject (ruid, euid) are matched against the object's (ruid, svuid), and the object uid's must be a subset of the subject uid's. Likewise, jail now affects delivery, and special handling for P_SUGID of the object is present. This change can always be reversed or tweaked if it proves to disrupt application behavior substantially. Obtained from: TrustedBSD Project Sponsored by: DARPA, NAI Labs
* Change the preemption code for software interrupt thread schedules andjhb2002-01-051-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mutex releases to not require flags for the cases when preemption is not allowed: The purpose of the MTX_NOSWITCH and SWI_NOSWITCH flags is to prevent switching to a higher priority thread on mutex releease and swi schedule, respectively when that switch is not safe. Now that the critical section API maintains a per-thread nesting count, the kernel can easily check whether or not it should switch without relying on flags from the programmer. This fixes a few bugs in that all current callers of swi_sched() used SWI_NOSWITCH, when in fact, only the ones called from fast interrupt handlers and the swi_sched of softclock needed this flag. Note that to ensure that swi_sched()'s in clock and fast interrupt handlers do not switch, these handlers have to be explicitly wrapped in critical_enter/exit pairs. Presently, just wrapping the handlers is sufficient, but in the future with the fully preemptive kernel, the interrupt must be EOI'd before critical_exit() is called. (critical_exit() can switch due to a deferred preemption in a fully preemptive kernel.) I've tested the changes to the interrupt code on i386 and alpha. I have not tested ia64, but the interrupt code is almost identical to the alpha code, so I expect it will work fine. PowerPC and ARM do not yet have interrupt code in the tree so they shouldn't be broken. Sparc64 is broken, but that's been ok'd by jake and tmm who will be fixing the interrupt code for sparc64 shortly. Reviewed by: peter Tested on: i386, alpha
* o Wording fix in comment.rwatson2001-12-141-1/+1
| | | | Submitted by: tanimura via p4
* _SIG_MAXSIG (128) is the highest legal signal. The arrays are offsetpeter2001-11-031-2/+2
| | | | | | by one - see _SIG_IDX(). Revert part of my mis-correction in kern_sig.c (but signal 0 still has to be allowed) and fix _SIG_VALID() (it was rejecting ignal 128).
* Partial reversion of rev 1.138. kill and killpg allow a signalpeter2001-11-031-2/+2
| | | | | | | | | | argument of 0. You cannot return EINVAL for signal 0. This broke (in 5 minutes of testing) at least ssh-agent and screen. However, there was a bug in the original code. Signal 128 is not valid. Pointy-hat to: des, jhb
* We have a _SIG_VALID() macro, so use it instead of duplicating the test alldes2001-11-021-7/+5
| | | | | | over the place. Also replace a printf() + panic() with a KASSERT(). Reviewed by: jhb
* Fix a typo in do_sigaction() where sa_sigaction and sa_handler wereiedowse2001-10-071-3/+3
| | | | | | | confused. Since sa_sigaction and sa_handler alias each other in a union, the bug was completely harmless. This had been fixed as part of the SIGCHLD changes in revision 1.125, but it was reverted when they were backed out in revision 1.126.
* Lock the vnode while truncating the corefile. This fixes a panicps2001-09-261-0/+2
| | | | | | | with softupdates dangling deps. Submitted by: peter MFC: ASAP :)
* Replace line accidentally deleted during KSE additions.julian2001-09-171-1/+1
| | | | | Symptom.. Stopped program unable to be restarted if it was stopped while already sleeping.
* o Correct authorization check in CANSIGIO(), which suffered from incorrectrwatson2001-09-151-4/+5
| | | | | | | | transcription during the (pcred,ucred) merge; this was not used for the kill() system call, so does not affect direct explicit process signalling. Pointed out by: fenner
* KSE Milestone 2julian2001-09-121-78/+166
| | | | | | | | | | | | | | Note ALL MODULES MUST BE RECOMPILED make the kernel aware that there are smaller units of scheduling than the process. (but only allow one thread per process at this time). This is functionally equivalent to teh previousl -current except that there is a thread associated with each process. Sorry john! (your next MFC will be a doosie!) Reviewed by: peter@freebsd.org, dillon@freebsd.org X-MFC after: ha ha ha ha
* This brings in a Yahoo coredump patch from Paul, with additional mods bydillon2001-09-081-4/+19
| | | | | | | | | | | | | | | | | | | me (addition of vn_rdwr_inchunks). The problem Yahoo is solving is that if you have large process images core dumping, or you have a large number of forked processes all core dumping at the same time, the original coredump code would leave the vnode locked throughout. This can cause the directory vnode to get locked up, which can cause the parent directory vnode to get locked up, and so on all the way to the root node, locking the entire machine up for extremely long periods of time. This patch solves the problem in two ways. First it uses an advisory non-blocking lock to abort multiple processes trying to core to the same file. Second (my contribution) it chunks up the writes and uses bwillwrite() to avoid holding the vnode locked while blocking in the buffer cache. Submitted by: ps Reviewed by: dillon MFC after: 2 weeks
* Call sendsig() with the proc lock held and return with it held.jhb2001-09-061-4/+0
|
* Giant Pushdowndillon2001-09-011-37/+133
| | | | | | | | clock_gettime() clock_settime() nanosleep() settimeofday() adjtime() getitimer() setitimer() __sysctl() ogetkerninfo() sigaction() osigaction() sigpending() osigpending() osigvec() osigblock() osigsetmask() sigsuspend() osigsuspend() osigstack() sigaltstack() kill() okillpg() trapsignal() nosys()
* Remove the MPSAFE keyword from the parser for syscalls.master.dillon2001-08-301-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead introduce the [M] prefix to existing keywords. e.g. MSTD is the MP SAFE version of STD. This is prepatory for a massive Giant lock pushdown. The old MPSAFE keyword made syscalls.master too messy. Begin comments MP-Safe procedures with the comment: /* * MPSAFE */ This comments means that the procedure may be called without Giant held (The procedure itself may still need to obtain Giant temporarily to do its thing). sv_prepsyscall() is now MP SAFE and assumed to be MP SAFE sv_transtrap() is now MP SAFE and assumed to be MP SAFE ktrsyscall() and ktrsysret() are now MP SAFE (Giant Pushdown) trapsignal() is now MP SAFE (Giant Pushdown) Places which used to do the if (mtx_owned(&Giant)) mtx_unlock(&Giant) test in syscall[2]() in */*/trap.c now do not. Instead they explicitly unlock Giant if they previously obtained it, and then assert that it is no longer held to catch broken system calls. Rebuild syscall tables.
* Prevent passing a null pointer as a filename to vn_open(),roam2001-08-241-0/+2
| | | | | | | | | if for some reason expand_name() failed to build a core file name. PR: 29931 Submitted by: Foldi Tamas <crow@kapu.hu> Reviewed by: dd, -arch MFC after: 1 month
* Make COMPAT_43 optional again. XXX we need COMPAT_FBSD3 etc for thispeter2001-08-211-0/+2
| | | | stuff.
* Temporarily back out kern_sig.c rev 1.125 and kern_exit.c rev 1.131.peter2001-08-011-4/+5
| | | | | | | | | This paniced my one of my machines one time too many :-( and there is no sign of a solution in the pipeline. The deltas are still easily available in cvs. The problem is that if the parent has been swapped out, the child process cannot grope around in the parent's UPAGES to see the sigact[] array or it will fault. This probably is a showstopper for this implementation anyway.
* As per further discussions on hackers redo the SIGCHLD patch to not generatedillon2001-07-221-5/+4
| | | | | | | | | an unexpected user-visible side effect with the sigaction flags. Also cleanup a minor union issue. Submitted by: Rudolf Cejka <cejkar@dcse.fee.vutbr.cz> MFC addendum: MFC will be combined w/ original commit MFC after: 3 days
* Grab Giant around postsig() since sendsig() can call into the vm tojhb2001-07-031-6/+0
| | | | grow the stack and we already needed Giant for KTRACE.
* - Change CURSIG() and postsig() to require that the proc lock is heldjhb2001-06-221-9/+10
| | | | | | | | | | rather than grabbing it and releasing it themselves. This allows callers of these functions to get the lock to close race conditions. - Grab Giant around ktrace in postsig. - Count the switches performed on SIGSTOP's as involuntary context switches in the resource usage stats. Reported by: tegge (signal race), bde (missing csw stats)
* Lock Giant in postsig() for the KTRACE case as ktrpsig() needs Giant whenjhb2001-06-181-0/+4
| | | | | | it writes out to the trace file. Reported by: peter, gallatin, and others
* Try to make the setting of the SIGCHLD handler the same as setting ofdwmalone2001-06-111-1/+4
| | | | | | | the NOCLDWAI flag. Susv2 seems to require this. Submitted by: Cejka Rudolf <cejkar@dcse.fee.vutbr.cz> Reviewed by: dillon
* o Merge contents of struct pcred into struct ucred. Specifically, add therwatson2001-05-251-12/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | real uid, saved uid, real gid, and saved gid to ucred, as well as the pcred->pc_uidinfo, which was associated with the real uid, only rename it to cr_ruidinfo so as not to conflict with cr_uidinfo, which corresponds to the effective uid. o Remove p_cred from struct proc; add p_ucred to struct proc, replacing original macro that pointed. p->p_ucred to p->p_cred->pc_ucred. o Universally update code so that it makes use of ucred instead of pcred, p->p_ucred instead of p->p_pcred, cr_ruidinfo instead of p_uidinfo, cr_{r,sv}{u,g}id instead of p_*, etc. o Remove pcred0 and its initialization from init_main.c; initialize cr_ruidinfo there. o Restruction many credential modification chunks to always crdup while we figure out locking and optimizations; generally speaking, this means moving to a structure like this: newcred = crdup(oldcred); ... p->p_ucred = newcred; crfree(oldcred); It's not race-free, but better than nothing. There are also races in sys_process.c, all inter-process authorization, fork, exec, and exit. o Remove sigio->sio_ruid since sigio->sio_ucred now contains the ruid; remove comments indicating that the old arrangement was a problem. o Restructure exec1() a little to use newcred/oldcred arrangement, and use improved uid management primitives. o Clean up exit1() so as to do less work in credential cleanup due to pcred removal. o Clean up fork1() so as to do less work in credential cleanup and allocation. o Clean up ktrcanset() to take into account changes, and move to using suser_xxx() instead of performing a direct uid==0 comparision. o Improve commenting in various kern_prot.c credential modification calls to better document current behavior. In a couple of places, current behavior is a little questionable and we need to check POSIX.1 to make sure it's "right". More commenting work still remains to be done. o Update credential management calls, such as crfree(), to take into account new ruidinfo reference. o Modify or add the following uid and gid helper routines: change_euid() change_egid() change_ruid() change_rgid() change_svuid() change_svgid() In each case, the call now acts on a credential not a process, and as such no longer requires more complicated process locking/etc. They now assume the caller will do any necessary allocation of an exclusive credential reference. Each is commented to document its reference requirements. o CANSIGIO() is simplified to require only credentials, not processes and pcreds. o Remove lots of (p_pcred==NULL) checks. o Add an XXX to authorization code in nfs_lock.c, since it's questionable, and needs to be considered carefully. o Simplify posix4 authorization code to require only credentials, not processes and pcreds. Note that this authorization, as well as CANSIGIO(), needs to be updated to use the p_cansignal() and p_cansched() centralized authorization routines, as they currently do not take into account some desirable restrictions that are handled by the centralized routines, as well as being inconsistent with other similar authorization instances. o Update libkvm to take these changes into account. Obtained from: TrustedBSD Project Reviewed by: green, bde, jhb, freebsd-arch, freebsd-audit
OpenPOWER on IntegriCloud