public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Todd Inglett <tinglett@vnet.ibm.com>
To: linux-kernel@vger.kernel.org
Subject: SMP races in proc with thread_struct
Date: Tue, 01 May 2001 09:30:24 -0500	[thread overview]
Message-ID: <3AEEC880.304F4B75@vnet.ibm.com> (raw)

Perhaps this is old news...but...

I can easily create a race when reading /proc/<pid>/stat
(fs/proc/{base.c,array.c}) where a rapidly reading application, such as
"top", starts reading stats for a thread which goes away during the
read.  This is easily reproduced with a program that rapidly forks and
exits while top is running.

On inspection, I don't see how the code can expect the thread_struct to
stay around since it is not holding any lock for the duration of its
use.  The code could hold the thread_struct's lock (after verifying it
still exists while holding tasklist_lock I would imagine), but for
performance I would think a better solution would be to copy the struct
since stale data is probably ok in this case.

Dereferencing a non-existent thread_struct is clearly not ok.

Would anyone familiar with this code care to comment?
-- 
-todd

             reply	other threads:[~2001-05-01 14:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-01 14:30 Todd Inglett [this message]
2001-05-01 16:50 ` SMP races in proc with thread_struct Alexander Viro
2001-05-03 11:47   ` Todd Inglett
2001-05-04 12:34     ` Todd Inglett
2001-05-04 12:46       ` Keith Owens
2001-05-04 13:11         ` Andreas Schwab
2001-05-04 13:38           ` Brian Gerst
2001-05-04 23:27           ` Keith Owens
2001-05-04 14:21         ` Andreas Ferber
2001-05-04 15:18           ` Todd Inglett
2001-05-04 16:04       ` Alexander Viro
2001-05-04 17:52       ` [PATCH][RFC] " Alexander Viro

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=3AEEC880.304F4B75@vnet.ibm.com \
    --to=tinglett@vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    /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