Fixed sigaction() for SIGKILL and SIGSTOP. Reading the old action now

succeeds.  Writing an action now succeeds iff the handler isn't changed.
(POSIX allows attempts to change the handler to be ignored or cause an
error.  Changing other parts of the action is allowed (except attempts
to mask unmaskable signals are silently ignored as usual).)

Found by:	NIST-PCTS
This commit is contained in:
bde 1996-11-29 18:01:55 +00:00
parent 623ea9097a
commit 0d3f6a9373

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_sig.c 8.7 (Berkeley) 4/18/94
* $Id: kern_sig.c,v 1.25 1996/07/09 18:12:37 ache Exp $
* $Id: kern_sig.c,v 1.26 1996/10/19 01:06:20 davidg Exp $
*/
#include "opt_ktrace.h"
@ -108,8 +108,7 @@ sigaction(p, uap, retval)
int bit, error;
signum = uap->signum;
if (signum <= 0 || signum >= NSIG ||
signum == SIGKILL || signum == SIGSTOP)
if (signum <= 0 || signum >= NSIG)
return (EINVAL);
sa = &vec;
if (uap->osa) {
@ -135,6 +134,9 @@ sigaction(p, uap, retval)
if ((error = copyin((caddr_t)uap->nsa, (caddr_t)sa,
sizeof (vec))))
return (error);
if ((signum == SIGKILL || signum == SIGSTOP) &&
sa->sa_handler != SIG_DFL)
return (EINVAL);
setsigvec(p, signum, sa);
}
return (0);
@ -343,8 +345,7 @@ osigvec(p, uap, retval)
int bit, error;
signum = uap->signum;
if (signum <= 0 || signum >= NSIG ||
signum == SIGKILL || signum == SIGSTOP)
if (signum <= 0 || signum >= NSIG)
return (EINVAL);
sv = &vec;
if (uap->osv) {
@ -372,6 +373,9 @@ osigvec(p, uap, retval)
if ((error = copyin((caddr_t)uap->nsv, (caddr_t)sv,
sizeof (vec))))
return (error);
if ((signum == SIGKILL || signum == SIGSTOP) &&
sv->sv_handler != SIG_DFL)
return (EINVAL);
#ifdef COMPAT_SUNOS
sv->sv_flags |= SA_USERTRAMP;
#endif