lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 15 Dec 2008 18:09:37 +0100
From:	Oleg Nesterov <oleg@...hat.com>
To:	"Eric W. Biederman" <ebiederm@...ssion.com>
Cc:	Jiri Slaby <jirislaby@...il.com>, kenchen@...gle.com,
	Linux kernel mailing list <linux-kernel@...r.kernel.org>
Subject: Re: broken do_each_pid_{thread,task}

On 12/15, Oleg Nesterov wrote:
>
> On 12/14, Eric W. Biederman wrote:
> >
> > Although seeing the unexpected corner case it gets us into I think it would
> > be good to reconsider this test.

So. I can't decide whether this patch is cleanup or the further
uglification, but if anyone likes it I will be happy to send it.

Then we can kill do_each_pid_task/while_each_pid_task completely.

Oleg.

--- linux-2.6.27/include/linux/pid.h~PID_FOR_EACH	2008-10-10 00:13:53.000000000 +0200
+++ linux-2.6.27/include/linux/pid.h	2008-12-15 17:51:50.000000000 +0100
@@ -144,21 +144,25 @@ static inline pid_t pid_nr(struct pid *p
 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
 pid_t pid_vnr(struct pid *pid);
 
+/*
+ * Both old and new leaders may be attached to the same pid in the
+ * middle of de_thread(), that is why we do the special check for
+ * PIDTYPE_PID below.
+ */
+#define pid_for_each_task(pid, type, p)	\
+	for (p = (pid) ? (void*)(pid)->tasks[type].first : NULL;	\
+	     rcu_dereference(p) && ({					\
+		prefetch(((struct hlist_node*)p)->next);		\
+		p = hlist_entry((void*)p, typeof(*p), pids[type].node);	\
+		1; });							\
+	     p = ((type) != PIDTYPE_PID) ?				\
+		(void*)(p)->pids[type].node.next : NULL)
+
 #define do_each_pid_task(pid, type, task)				\
 	do {								\
-		struct hlist_node *pos___;				\
-		if (pid != NULL)					\
-			hlist_for_each_entry_rcu((task), pos___,	\
-				&pid->tasks[type], pids[type].node) {
+		pid_for_each_task(pid, type, task)
 
-			/*
-			 * Both old and new leaders may be attached to
-			 * the same pid in the middle of de_thread().
-			 */
 #define while_each_pid_task(pid, type, task)				\
-				if (type == PIDTYPE_PID)		\
-					break;				\
-			}						\
 	} while (0)
 
 #define do_each_pid_thread(pid, type, task)				\

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ