blocking sigkill (+PATCH)

Alexander V. Lukyanov (lav@video.yars.free.net)
Tue, 14 Apr 1998 02:33:22 +0400


Ok, I verifyed on i386 that using sa_mask member of struct sigaction anyone
can block kill/stop signals. Here is a test program and a patch. This patch
is probably overkill, any of the two changes would fix this particular
problem.

#include <stdio.h>
#include <unistd.h>
#include <signal.h>

void sig(int x)
{
printf("Try to kill me (pid=%ld)\n",(long)getpid());
sleep(100);
printf("Exiting\n");
exit(1);
}

int main()
{
struct sigaction s;
s.sa_handler=sig;
s.sa_flags=0;
sigfillset(&s.sa_mask);
sigaction(1,&s,0);
raise(1);
return 0;
}

--- signal.c.1 Mon Apr 13 22:38:08 1998
+++ signal.c Mon Apr 13 22:51:54 1998
@@ -338,7 +338,8 @@
}

sigaddset(&t->signal, sig);
- if (!sigismember(&t->blocked, sig))
+ /* KILL and STOP signals can't be blocked */
+ if (!sigismember(&t->blocked, sig) || sig==SIGKILL || sig==SIGSTOP)
t->sigpending = 1;

out:
@@ -788,6 +789,8 @@

if (act) {
*k = *act;
+ sigdelsetmask(&k->sa.sa_mask, (sigmask(SIGKILL)|
+ sigmask(SIGSTOP)));

/*
* POSIX 3.3.1.3:

Alexander.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu