All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ralf Baechle <ralf@linux-mips.org>
To: DM <dm.n9107@gmail.com>
Cc: Ulrich Drepper <drepper@redhat.com>,
	linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	linux-mips@linux-mips.org, sparclinux@vger.kernel.org,
	torvalds@linux-foundation.org
Subject: Re: [PATCH v2] unify sys_pipe implementation
Date: Mon, 5 May 2008 11:18:09 +0100	[thread overview]
Message-ID: <20080505101809.GA14547@linux-mips.org> (raw)
In-Reply-To: <5eeb9ad90805050130i39ae791dwe599c12fc08fb8ec@mail.gmail.com>

On Mon, May 05, 2008 at 10:30:09AM +0200, DM wrote:

> >  + * sys_pipe() is the normal C calling standard for creating
> >  + * a pipe. It's not the way Unix traditionally does this, though.
> >  + */
> >  +asmlinkage long sys_pipe(int __user *fildes)
> >  +{
> >  +       int fd[2];
> >  +       int error;
> >  +
> >  +       error = do_pipe(fd);
> >  +       if (!error) {
> >  +               if (copy_to_user(fildes, fd, sizeof(fd)))
> >  +                       error = -EFAULT;
> >  +       }
> >  +       return error;
> >  +}
> >  +
> [...]
> 
> I realize this code is old, but wouldn't file descriptors leak if
> copy_to_user fails?

The MIPS implementation doesn't have this problem; it returns the
file descriptors in the result registers $v0 and $v1.

But an interesting catch after so many years!

  Ralf

WARNING: multiple messages have this Message-ID (diff)
From: Ralf Baechle <ralf@linux-mips.org>
To: DM <dm.n9107@gmail.com>
Cc: Ulrich Drepper <drepper@redhat.com>,
	linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	linux-mips@linux-mips.org, sparclinux@vger.kernel.org,
	torvalds@linux-foundation.org
Subject: Re: [PATCH v2] unify sys_pipe implementation
Date: Mon, 05 May 2008 10:18:09 +0000	[thread overview]
Message-ID: <20080505101809.GA14547@linux-mips.org> (raw)
In-Reply-To: <5eeb9ad90805050130i39ae791dwe599c12fc08fb8ec@mail.gmail.com>

On Mon, May 05, 2008 at 10:30:09AM +0200, DM wrote:

> >  + * sys_pipe() is the normal C calling standard for creating
> >  + * a pipe. It's not the way Unix traditionally does this, though.
> >  + */
> >  +asmlinkage long sys_pipe(int __user *fildes)
> >  +{
> >  +       int fd[2];
> >  +       int error;
> >  +
> >  +       error = do_pipe(fd);
> >  +       if (!error) {
> >  +               if (copy_to_user(fildes, fd, sizeof(fd)))
> >  +                       error = -EFAULT;
> >  +       }
> >  +       return error;
> >  +}
> >  +
> [...]
> 
> I realize this code is old, but wouldn't file descriptors leak if
> copy_to_user fails?

The MIPS implementation doesn't have this problem; it returns the
file descriptors in the result registers $v0 and $v1.

But an interesting catch after so many years!

  Ralf

  parent reply	other threads:[~2008-05-05 10:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-03 18:01 [PATCH v2] unify sys_pipe implementation Ulrich Drepper
2008-05-03 18:01 ` Ulrich Drepper
2008-05-03 18:40 ` Linus Torvalds
2008-05-03 18:40   ` Linus Torvalds
2008-05-05  8:30 ` DM
2008-05-05  8:30   ` DM
2008-05-05  9:15   ` Michael Kerrisk
2008-05-05  9:15     ` Michael Kerrisk
2008-05-05 10:18   ` Ralf Baechle [this message]
2008-05-05 10:18     ` Ralf Baechle

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=20080505101809.GA14547@linux-mips.org \
    --to=ralf@linux-mips.org \
    --cc=akpm@linux-foundation.org \
    --cc=dm.n9107@gmail.com \
    --cc=drepper@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=sparclinux@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.