linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christopher Yeoh <cyeoh@au1.ibm.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH RESEND] Fix race in process_vm_rw_core
Date: Wed, 1 Feb 2012 18:38:36 +1030	[thread overview]
Message-ID: <20120201183836.1cf5fc52@Gantu.yeoh.info> (raw)
In-Reply-To: <CA+55aFxstU98L64xgoUiacsV0zwX5ioNv3cT5CH2rvBrUGaovw@mail.gmail.com>

On Tue, 31 Jan 2012 22:10:13 -0800
Linus Torvalds <torvalds@linux-foundation.org> wrote:

> On Tue, Jan 31, 2012 at 9:53 PM, Christopher Yeoh <cyeoh@au1.ibm.com>
> wrote:
> > +       mm = mm_access(task, PTRACE_MODE_ATTACH);
> > +       if (!mm || IS_ERR(mm)) {
> > +               if (!mm)
> > +                       rc = -EINVAL;
> > +               else
> > +                       rc = -EPERM;
> >                goto put_task_struct;
> 
> Btw, do you really want to throw away the error code?
> 
> IOW, maybe it should be
> 
>    rc = IS_ERR(mm) ? PTR_ERR(mm) : -EINVAL;
> 
> or something? Instead of forcing the EPERM? And the -EINVAL might be
> better off as an ESRCH? I dunno.

Yea, that probably makes more sense.

> Right now you turn all errors into EPERM, whether they were really
> about permission problems or not. And that just makes be a bit
> nervous. I wonder if we wouldn't be better off just returning EACCES
> (and any possible future problem) than try so hard to always return
> EPERM?
> 
> I dunno. I don't have any really *strong* opinion and I see why you do
> it, but my gut feel is still that the error number change really does
> seem a bit arbitrary.

I'm not super attached to returning EPERM instead of EACCES though I do
think it would look at bit odd from a user of the syscall view. Is it
too ugly to do:

    rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
    if (rc == -EACCES)
            rc = -EPERM;

That way we avoid the problem of overwriting EINTR and if there are
changes in the future which return different error codes we won't
override those.

If you think it is too ugly then I'll give in and just return EACESS.
Just should to get it settled before too many people start using the
syscalls.

Chris
-- 
cyeoh@au.ibm.com


  reply	other threads:[~2012-02-01  8:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-30  2:14 [PATCH RESEND] Fix race in process_vm_rw_core Christopher Yeoh
2012-01-30 15:09 ` Oleg Nesterov
2012-02-01  5:53   ` Christopher Yeoh
2012-02-01  6:09     ` Cong Wang
2012-02-01  6:10     ` Linus Torvalds
2012-02-01  8:08       ` Christopher Yeoh [this message]
2012-02-02  1:04         ` Christopher Yeoh

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=20120201183836.1cf5fc52@Gantu.yeoh.info \
    --to=cyeoh@au1.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@redhat.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).