From: Dipankar Sarma <dipankar@in.ibm.com>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/4] files: fix expand_files return code
Date: Fri, 24 Jun 2005 16:23:18 +0530 [thread overview]
Message-ID: <20050624105318.GD4804@in.ibm.com> (raw)
In-Reply-To: <20050624105209.GC4804@in.ibm.com>
If expand_fdtable() sees that someone else expanded the fdtable
while it dropped the lock, it can return 0 which in turn
can be returned by expand_files() even though there has
been an expansion of the fdtable since expand_files()
was originally called. This could lead to locate_fd()
not repeating the fd search and returning a bogus fd.
This patch fixes this problem.
Signed-off-by: Dipankar Sarma <dipankar@in.ibm.com>
---
fs/file.c | 15 +++++++--------
1 files changed, 7 insertions(+), 8 deletions(-)
diff -puN fs/file.c~fix-expand-files fs/file.c
--- linux-2.6.12-mm1-fix/fs/file.c~fix-expand-files 2005-06-25 16:42:18.000000000 +0530
+++ linux-2.6.12-mm1-fix-dipankar/fs/file.c 2005-06-25 16:42:18.000000000 +0530
@@ -304,13 +304,14 @@ out:
/*
* Expands the file descriptor table - it will allocate a new fdtable and
* both fd array and fdset. It is expected to be called with the
- * files_lock held.
+ * files_lock held. It returns 1 if fdtable expanded or -errno if
+ * expansion failed.
*/
static int expand_fdtable(struct files_struct *files, int nr)
__releases(files->file_lock)
__acquires(files->file_lock)
{
- int error = 0;
+ int error = 1;
struct fdtable *fdt;
struct fdtable *nfdt = NULL;
@@ -350,7 +351,7 @@ out:
*/
int expand_files(struct files_struct *files, int nr)
{
- int err, expand = 0;
+ int err;
struct fdtable *fdt;
fdt = files_fdtable(files);
@@ -360,11 +361,9 @@ int expand_files(struct files_struct *fi
err = -EMFILE;
goto out;
}
- expand = 1;
- if ((err = expand_fdtable(files, nr)))
- goto out;
- }
- err = expand;
+ err = expand_fdtable(files, nr);
+ } else
+ err = 0;
out:
return err;
}
_
next prev parent reply other threads:[~2005-06-24 10:58 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-24 10:50 [PATCH 0/4] files: various updates Dipankar Sarma
2005-06-24 10:52 ` [PATCH 1/4] files: fix dupfd by fdt reload Dipankar Sarma
2005-06-24 10:53 ` Dipankar Sarma [this message]
2005-06-24 10:54 ` [PATCH 3/4] files: change fd_install assertion Dipankar Sarma
2005-06-24 10:55 ` [PATCH 4/4] files: doc update Dipankar Sarma
2005-06-24 12:04 ` [PATCH 3/4] files: change fd_install assertion Artem B. Bityuckiy
2005-06-24 13:00 ` Dipankar Sarma
2005-06-24 13:55 ` Artem B. Bityuckiy
2005-06-24 14:09 ` Dipankar Sarma
2005-06-24 14:20 ` Artem B. Bityuckiy
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=20050624105318.GD4804@in.ibm.com \
--to=dipankar@in.ibm.com \
--cc=akpm@osdl.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.