From: Maneesh Soni <maneesh@in.ibm.com>
To: viro@math.psu.edu
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] proc_readfd race
Date: Tue, 6 Nov 2001 10:24:06 +0530 [thread overview]
Message-ID: <20011106102406.F23390@in.ibm.com> (raw)
Hi Al,
proc_readfd calls fcheck_files() without taking read_lock() for the
files_struct which could end up in race with expand_fd_array(). The patch
below puts the read_lock to avoid that. I am not very sure if this is already
protected by some other means and read_lock is not needed.
Please comment.
Thank you,
Maneesh
--
Maneesh Soni
IBM Linux Technology Center,
IBM India Software Lab, Bangalore.
Phone: +91-80-5262355 Extn. 3999 email: maneesh@in.ibm.com
http://lse.sourceforge.net/locking/rcupdate.html
diff -urN linux-2.4.14-pre8-orig/fs/proc/base.c linux-2.4.14pre8/fs/proc/base.c
--- linux-2.4.14-pre8-orig/fs/proc/base.c Tue Nov 6 10:13:27 2001
+++ linux-2.4.14pre8/fs/proc/base.c Tue Nov 6 10:02:19 2001
@@ -553,6 +553,7 @@
task_unlock(p);
if (!files)
goto out;
+ read_lock(&files->file_lock);
for (fd = filp->f_pos-2;
fd < files->max_fds;
fd++, filp->f_pos++) {
@@ -561,6 +562,7 @@
if (!fcheck_files(files, fd))
continue;
+ read_unlock(&files->file_lock);
j = NUMBUF;
i = fd;
do {
@@ -571,8 +573,11 @@
ino = fake_ino(pid, PROC_PID_FD_DIR + fd);
if (filldir(dirent, buf+j, NUMBUF-j, fd+2, ino, DT_LNK) < 0)
- break;
+ goto done;
+ read_lock(&files->file_lock);
}
+ read_unlock(&files->file_lock);
+done:
put_files_struct(files);
}
out:
reply other threads:[~2001-11-06 4:48 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=20011106102406.F23390@in.ibm.com \
--to=maneesh@in.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@math.psu.edu \
/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