mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Andrew Morton <akpm@osdl.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] simplify/fix first_tid()
Date: Mon, 20 Mar 2006 11:00:59 -0700	[thread overview]
Message-ID: <m1fyldvvvo.fsf@ebiederm.dsl.xmission.com> (raw)
In-Reply-To: <441DB045.87C4134C@tv-sign.ru> (Oleg Nesterov's message of "Sun, 19 Mar 2006 22:25:57 +0300")

Oleg Nesterov <oleg@tv-sign.ru> writes:

> first_tid:
>
> 	/* If nr exceeds the number of threads there is nothing todo */
> 	if (nr) {
> 		if (nr >= get_nr_threads(leader))
> 			goto done;
> 	}
>
> This is not reliable: sub-threads can exit after this check, so the
> 'for' loop below can overlap and proc_task_readdir() can return an
> already filldir'ed dirents.
>
> 	for (; pos && pid_alive(pos); pos = next_thread(pos)) {
> 		if (--nr > 0)
> 			continue;
>
> Off-by-one error, will return 'leader' when nr == 1.
>
> This patch tries to fix these problems and simplify the code.

This is better however if I read this code correctly.  It modifies
the code so the last time user space goes trough this loop
with nr > nr_threads.  Then we will walk the entire threads
list to achieve nothing.

So we really still need the nr_threads test in there so we don't
traverse the list twice everytime through readdir.

Eric

  reply	other threads:[~2006-03-20 18:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-19 19:25 Oleg Nesterov
2006-03-20 18:00 ` Eric W. Biederman [this message]
2006-03-20 18:30   ` Oleg Nesterov
2006-03-20 18:56     ` Eric W. Biederman
2006-03-20 19:32       ` Oleg Nesterov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m1fyldvvvo.fsf@ebiederm.dsl.xmission.com \
    --to=ebiederm@xmission.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@tv-sign.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome