From: Changli Gao <xiaosuo@gmail.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: xiaosuo <xiaosuo@gmail.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: PATCH: fd leak if pipe() is called with an invalid address.
Date: Thu, 02 Jul 2009 15:21:55 +0800 [thread overview]
Message-ID: <4A4C6013.9090509@gmail.com> (raw)
fd leak if pipe() is called with an invalid address.
Though -EFAULT is returned, the file descriptors opened by pipe() call
are left open.
Signed-off-by: Changli Gao <xiaosuo@gmail.com>
----
x86/ia32/sys_ia32.c | 5 ++++-
xtensa/kernel/syscall.c | 5 ++++-
2 files changed, 8 insertions(+), 2 deletions(-)
--- arch/x86/ia32/sys_ia32.c.orig 2009-07-02 15:08:39.000000000 +0800
+++ arch/x86/ia32/sys_ia32.c 2009-07-02 15:09:49.000000000 +0800
@@ -197,8 +197,11 @@
retval = do_pipe_flags(fds, 0);
if (retval)
goto out;
- if (copy_to_user(fd, fds, sizeof(fds)))
+ if (copy_to_user(fd, fds, sizeof(fds))) {
+ sys_close(fd[0]);
+ sys_close(fd[1]);
retval = -EFAULT;
+ }
out:
return retval;
}
--- arch/xtensa/kernel/syscall.c.orig 2009-07-02 15:09:01.000000000 +0800
+++ arch/xtensa/kernel/syscall.c 2009-07-02 15:10:15.000000000 +0800
@@ -51,8 +51,11 @@
error = do_pipe_flags(fd, 0);
if (!error) {
- if (copy_to_user(userfds, fd, 2 * sizeof(int)))
+ if (copy_to_user(userfds, fd, 2 * sizeof(int))) {
+ sys_close(fd[0]);
+ sys_close(fd[1]);
error = -EFAULT;
+ }
}
return error;
}
next reply other threads:[~2009-07-02 7:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-02 7:21 Changli Gao [this message]
2009-07-02 9:12 ` PATCH: fd leak if pipe() is called with an invalid address Amerigo Wang
2009-07-10 3:18 ` Amerigo Wang
2009-07-10 3:31 ` Linus Torvalds
2009-07-10 5:29 ` Amerigo Wang
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=4A4C6013.9090509@gmail.com \
--to=xiaosuo@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.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.