[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: pthread_kill is racy: probably needs kernel change



Here is the proposed kernel patch: only tested compilation.
The NPTL change is even more trivial.

Should I go forward with this?


--- kernel/signal.c~	2002-11-01 13:32:32.000000000 +0100
+++ kernel/signal.c	2002-11-04 02:00:00.000000000 +0100
@@ -1548,15 +1548,12 @@ sys_kill(int pid, int sig)
  *  Send a signal to only one task, even if it's a CLONE_THREAD task.
  */
 asmlinkage long
-sys_tkill(int pid, int sig)
+sys_tkill(int* ppid, int sig)
 {
 	struct siginfo info;
 	int error;
 	struct task_struct *p;
-
-	/* This is only valid for single tasks */
-	if (pid <= 0)
-		return -EINVAL;
+	int pid;
 
 	info.si_signo = sig;
 	info.si_errno = 0;
@@ -1565,13 +1562,24 @@ sys_tkill(int pid, int sig)
 	info.si_uid = current->uid;
 
 	read_lock(&tasklist_lock);
-	p = find_task_by_pid(pid);
+	
+	error = -EFAULT;
+	if(get_user(pid, ppid))
+		goto out_unlock;
+	
+	/* This is only valid for single tasks */	
+	error = -EINVAL;
+	if (pid < 0)
+		goto out_unlock;
+
 	error = -ESRCH;
-	if (p) {
+	if(pid && (p = find_task_by_pid(pid))) {	
 		spin_lock_irq(&p->sig->siglock);
 		error = specific_send_sig_info(sig, &info, p, 0);
 		spin_unlock_irq(&p->sig->siglock);
 	}
+
+  out_unlock:
 	read_unlock(&tasklist_lock);
 	return error;
 }

Attachment: pgp00038.pgp
Description: PGP signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]