mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: skb300@hotmail.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: user pointers and race conditions
Date: Wed, 16 May 2007 22:06:31 -0700 (PDT)	[thread overview]
Message-ID: <20070516.220631.07641650.davem@davemloft.net> (raw)
In-Reply-To: <BAY115-W33D3EC723171255D88FBF86330@phx.gbl>

From: sk b <skb300@hotmail.com>
Date: Wed, 16 May 2007 22:56:22 -0600

> 3:        if (!access_ok(VERIFY_READ,stp,sizeof(struct st)))
> 4:                return;
> 5:        if (!access_ok(VERIFY_WRITE,stp->u,sizeof(int)))
> 6:                return;

This code would not exist in the kernel, the kernel cannot dereference
stp->u.  The stp->u dereference would silently work on x86 and x86_64
but it would generate an exception on sparc64 and other platforms.

User space accesses must go through the proper copy_from_user(),
copy_to_user, get_user(), and put_user() interfaces.

It must first copy stp into a local kernel space copy, then it may
inspect the value of stp->u.

And yes sparse would catch this problem in your code, because the
"__user" annotations would catch the illegal "stp->u" dereference.

  parent reply	other threads:[~2007-05-17  5:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-17  4:56 sk b
2007-05-17  5:04 ` Al Viro
2007-05-17  5:06 ` David Miller [this message]
2007-05-17 12:26 ` Arjan van de Ven

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=20070516.220631.07641650.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=skb300@hotmail.com \
    /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

all inboxes | Powered by JetHome®