updated: tgkill patch for safe inter-thread signals
PATCH 1/1 updated: tgkill patch for safe inter-thread signals
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
This are updated versions of the patch Ingo sent some time ago to implement a new tgkill() syscall which can in theory replace kill() and tkill().
The first patch is just Ingo's patch, relative to the current BK sources, plus the fix to send the correct si_pid value.
The second patch implementation the additional functionality Linus proposed. They allow using tgkill as a replacement for kill/tkill by recognizing special -1 values. This is the interdiff:
- --- linux-2.5/kernel/signal.c 2003-07-07 12:39:36.000000000 -0700
+++ linux-2.5/kernel/signal.c 2003-07-07 13:03:15.000000000 -0700
@@ -2104,8 +2104,12 @@
int error;
struct task_struct *p;+ /* Handle tgkill(tgid, -1, sig) like kill(tgid, sig). */
+ if (pid == -1)
+ return sys_kill(tgid, sig);
+
/* This is only valid for single tasks */
- - if (pid <= 0 || tgid <= 0)
+ if (pid <= 0 || tgid < -1 || tgid == 0)
return -EINVAL;
info.si_signo = sig;
@@ -2117,7 +2121,8 @@
read_lock(&tasklist_lock);
p = find_task_by_pid(pid);
error = -ESRCH;
- - if (p && (p->tgid == tgid)) {
+ /* Handle tgkill(-1, pid, sig) like tkill(pid, sig). */
+ if (p && (p->tgid == tgid || tgid == -1)) {
error = check_kill_permission(sig, &info, p);
/*
* The null signal is a permissions and process existenceI personally would think that this addition is overkill since we cannot get rid of the kill/tkill syscalls anyway.
I've tested both patches. Having one of them included is really needed since many/most people still run with limited PID ranges (maybe due to legacy apps breaking) and the PID reuse can cause problems.
Let me know if there are any problems. I'll try to address them right away.
- --
- --------------. ,-. 444 Castro Street
Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA
Red Hat --' drepper at redhat.com ---------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE/CdSE2ijCOnn/RHQRAiytAJwJq8BYPRu9Ep6U8krubKafW7nVwwCeKsq7 LKsQB68ROJYi8OrdUPFOZ5M=
=HdOW
-----END PGP SIGNATURE-----
arch/i386/kernel/entry.S renamed from arch/i386/kernel/entry.S-old +1 -0
@@ -876,5 +876,6 @@ ENTRY(sys_call_table) .long sys_clock_nanosleep .long sys_statfs64 .long sys_fstatfs64 + .long sys_tgkill nr_syscalls=(.-sys_call_table)/4
include/asm-i386/unistd.h renamed from include/asm-i386/unistd.h-old +2 -1
@@ -275,8 +275,9 @@#define __NR_clock_nanosleep (__NR_timer_create+8)#define __NR_statfs64 268#define __NR_fstatfs64 269 +#define __NR_tgkill 270 -#define NR_syscalls 270 +#define NR_syscalls 271/* user-visible error numbers are in the range -1 - -124: see <asm-i386/errno.h> */
kernel/signal.c renamed from kernel/signal.c-old +48 -2
62 lines not on this page · raw message
arch/i386/kernel/entry.S renamed from arch/i386/kernel/entry.S-old +1 -0
@@ -876,5 +876,6 @@ ENTRY(sys_call_table) .long sys_clock_nanosleep .long sys_statfs64 .long sys_fstatfs64 + .long sys_tgkill nr_syscalls=(.-sys_call_table)/4
include/asm-i386/unistd.h renamed from include/asm-i386/unistd.h-old +2 -1
@@ -275,8 +275,9 @@#define __NR_clock_nanosleep (__NR_timer_create+8)#define __NR_statfs64 268#define __NR_fstatfs64 269 +#define __NR_tgkill 270 -#define NR_syscalls 270 +#define NR_syscalls 271/* user-visible error numbers are in the range -1 - -124: see <asm-i386/errno.h> */
kernel/signal.c renamed from kernel/signal.c-old +53 -2
67 lines not on this page · raw message