public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* SMP races in proc with thread_struct
@ 2001-05-01 14:30 Todd Inglett
  2001-05-01 16:50 ` Alexander Viro
  0 siblings, 1 reply; 12+ messages in thread
From: Todd Inglett @ 2001-05-01 14:30 UTC (permalink / raw)
  To: linux-kernel

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

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

end of thread, other threads:[~2001-05-05 20:37 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-05-01 14:30 SMP races in proc with thread_struct Todd Inglett
2001-05-01 16:50 ` 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

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