[PATCH] pids: sys_getpgid: use rcu_read_lock() instead of tasklist_lock

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Andrew Morton <akpm@...>
Cc: Eric W. Biederman <ebiederm@...>, Pavel Emelyanov <xemul@...>, <linux-kernel@...>
Date: Sunday, March 23, 2008 - 1:51 pm

Convert sys_getpgid() to use rcu_read_lock() instead of tasklist_lock, make
sure we also check the result of task_pgrp_vnr().

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>

--- 25/kernel/sys.c~2_GETPGID	2008-03-23 19:25:36.000000000 +0300
+++ 25/kernel/sys.c	2008-03-23 20:39:03.000000000 +0300
@@ -988,19 +988,19 @@ asmlinkage long sys_getpgid(pid_t pid)
 	if (!pid)
 		return task_pgrp_vnr(current);
 	else {
-		int retval;
+		int retval = 0;
 		struct task_struct *p;
 
-		read_lock(&tasklist_lock);
+		rcu_read_lock();
 		p = find_task_by_vpid(pid);
-		retval = -ESRCH;
 		if (p) {
 			retval = security_task_getpgid(p);
 			if (!retval)
 				retval = task_pgrp_vnr(p);
 		}
-		read_unlock(&tasklist_lock);
-		return retval;
+		rcu_read_unlock();
+
+		return retval ?: -ESRCH;
 	}
 }
 

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] pids: sys_getpgid: use rcu_read_lock() instead of ta..., Oleg Nesterov, (Sun Mar 23, 1:51 pm)