[patch] fix NPTL thread iterator construct in cap_set_pg()

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Linux Kernel Mailing List <linux-kernel@...>, Andrew G. Morgan <morgan@...>
Date: Friday, August 15, 2008 - 12:24 pm

The usage of while_each_pid_task() construct in cap_set_pg() looks incorrect.
The macro is meant to form 'do ... while' loop instead of a simple while loop.
I think currently it will skip thread leader of a NPTL process.

Fix by convert to 'do ... while' style.

Signed-off-by: Ken Chen <kenchen@google.com>

diff --git a/kernel/capability.c b/kernel/capability.c
index 0101e84..26d8eda 100644
--- a/kernel/capability.c
+++ b/kernel/capability.c
@@ -167,7 +167,7 @@ static inline int cap_set_pg
 	pgrp = find_vpid(pgrp_nr);
 	do_each_pid_task(pgrp, PIDTYPE_PGID, g) {
 		target = g;
-		while_each_thread(g, target) {
+		do {
 			if (!security_capset_check(target, effective,
 						   inheritable, permitted)) {
 				security_capset_set(target, effective,
@@ -175,7 +175,7 @@ static inline int cap_set_pg
 				ret = 0;
 			}
 			found = 1;
-		}
+		} while_each_thread(g, target);
 	} while_each_pid_task(pgrp, PIDTYPE_PGID, g);

 	read_unlock(&tasklist_lock);
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[patch] fix NPTL thread iterator construct in cap_set_pg(), Ken Chen, (Fri Aug 15, 12:24 pm)