public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] fix NPTL thread iterator construct in cap_set_pg()
@ 2008-08-15 16:24 Ken Chen
  2008-08-17 23:29 ` Andrew G. Morgan
  2008-08-21 19:18 ` Andrew Morton
  0 siblings, 2 replies; 4+ messages in thread
From: Ken Chen @ 2008-08-15 16:24 UTC (permalink / raw)
  To: Linux Kernel Mailing List, Andrew G. Morgan

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);

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-08-21 19:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-15 16:24 [patch] fix NPTL thread iterator construct in cap_set_pg() Ken Chen
2008-08-17 23:29 ` Andrew G. Morgan
2008-08-21 19:18 ` Andrew Morton
2008-08-21 19:35   ` Ken Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox