linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Benjamin LaHaise <bcrl@kvack.org>
Cc: Andrew Morton <akpm@osdl.org>,
	pavel@suse.cz, linux-kernel@vger.kernel.org
Subject: Re: [PATCH -mm] swsusp: userland interface (rev 2)
Date: Wed, 25 Jan 2006 11:50:00 +0100	[thread overview]
Message-ID: <200601251150.01545.rjw@sisk.pl> (raw)
In-Reply-To: <20060125024607.GA10409@kvack.org>

On Wednesday, 25 January 2006 03:46, Benjamin LaHaise wrote:
> On Wed, Jan 25, 2006 at 12:35:38AM +0100, Rafael J. Wysocki wrote:
> > > > +		if (!access_ok(VERIFY_WRITE, (unsigned long __user *)arg, _IOC_SIZE(cmd))) {
> > > > +			error = -EINVAL;
> > > > +			break;
> > > > +		}
> > > 
> > > Why do we need an access_ok() here?
> > 
> > Because we use __put_user() down the road?
> > 
> > The problem is if the address is wrong we should not try to call
> > alloc_swap_page() at all.  If we did, we wouldn't be able to return the result
> > and we would leak a swap page.
> 
> Then access_ok() is not the droid you are looking for... since it won't 
> catch several cases (out of memory being the most obvious).

Thanks, I haven't thought about it.

> Doing an early put_user() wouldn't hurt and reduces the chance of later failure 
> even further.  __put_user() should never be used outside of a select few 
> performance critical code paths.

Do you mean to use a fake put_user() instead of access_ok()?  And then
put_user() once again or is it reasonable to call __put_user() with the same
arg?

Rafael

  reply	other threads:[~2006-01-25 10:48 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-24  8:29 [PATCH -mm] swsusp: userland interface (rev 2) Rafael J. Wysocki
2006-01-24 11:14 ` Pavel Machek
2006-01-24 21:13 ` Andrew Morton
2006-01-24 21:30   ` Pavel Machek
2006-01-24 21:58     ` Andrew Morton
2006-01-24 22:14       ` Pavel Machek
2006-01-24 22:20         ` Dave Jones
2006-01-24 22:33           ` Pavel Machek
2006-01-24 22:38             ` Dave Jones
2006-01-24 22:44               ` Pavel Machek
2006-01-26  2:09                 ` Jim Crilly
2006-01-26  7:58                   ` Pavel Machek
2006-01-27  1:11                   ` Greg KH
2006-01-27  3:42                   ` Kay Sievers
2006-01-27 11:24                     ` Rafael J. Wysocki
2006-01-24 22:47               ` Lee Revell
2006-01-24 23:53         ` Rafael J. Wysocki
2006-01-25  0:17           ` Andrew Morton
2006-01-25  0:31             ` Rafael J. Wysocki
2006-01-24 23:35   ` Rafael J. Wysocki
2006-01-25  2:46     ` Benjamin LaHaise
2006-01-25 10:50       ` Rafael J. Wysocki [this message]
2006-01-25 12:18     ` Pavel Machek
2006-01-25 12:29       ` Rafael J. Wysocki
2006-01-25 12:20     ` Pavel Machek

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=200601251150.01545.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=akpm@osdl.org \
    --cc=bcrl@kvack.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pavel@suse.cz \
    /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).