From: Corey Minyard <cminyard@mvista.com>
To: linux-kernel@vger.kernel.org
Subject: Race condition in fs/proc/array.c with task->comm
Date: Sun, 29 Jun 2003 09:27:31 -0500 [thread overview]
Message-ID: <3EFEF753.50100@mvista.com> (raw)
I searched for something about this, and I couldn't find anything.
I was having a problem with "top" crashing occasionally, so I looked,
and top was getting nil characters in the process name in
/proc/<pid>/stat. It turns out that there is a race condition when
generating the output for task->comm. If the task "execs" during this
time, it copies a new name into task->comm. When generating
/proc/<pid>/stat, it uses sprintf to copy the string. However, if the
data is changing in task->comm during this time, the results can be
corrupted, including putting nil characters into the string.
This seems to be a problem in all version of the kernel I looked at
(various 2.4 and 2.5 releases). I have only tested the problem in 2.4.20.
I can think it two main ways to fix this. You can:
* Make a local copy of task->comm. The results might still be wrong,
but it will not contain nil characters.
* Use locks so the data is consistent.
I can fix this and supply a patch, but I'd like suggestions on which
path to take. If suggesting a lock, should I create a new lock, or is
there an existing lock I can use?
Thanks,
-Corey
reply other threads:[~2003-06-29 14:11 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=3EFEF753.50100@mvista.com \
--to=cminyard@mvista.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