From: sk b <skb300@hotmail.com>
To: <linux-kernel@vger.kernel.org>
Subject: user pointers and race conditions
Date: Wed, 16 May 2007 22:56:22 -0600 [thread overview]
Message-ID: <BAY115-W33D3EC723171255D88FBF86330@phx.gbl> (raw)
Hello,
I'm wondering whether there is an exploitable TOCTTOU race condition in the way user pointers are handled in the kernel. Consider the following code:
1: struct st { int *u; };
2: void syscall(struct st * stp) {
3: if (!access_ok(VERIFY_READ,stp,sizeof(struct st)))
4: return;
5: if (!access_ok(VERIFY_WRITE,stp->u,sizeof(int)))
6: return;
7: foo(); //user app writes a kernel address to stp->u
8: *(stp->u) = 0;
9:}
Suppose syscall is some system call and, thus, stp and stp->u are user pointers. The function checks the stp and stp->u pointers using the access_ok macro on lines 3 and 5. Also suppose that the call to foo on line 7 takes a non-trivial amount of time to execute. During the time it takes foo to execute, the user application writes a kernel address to stp->u. Note that this write occurs after the check on line 5. Then, on line 8, the kernel writes to stp->u which contains a kernel address. So, the user application could force the kernel to overwrite itself. Is it possible to exploit this race condition? If so, does Sparse check for this?
-SKB
_________________________________________________________________
Download Messenger. Start an i’m conversation. Support a cause. Join now.
http://im.live.com/messenger/im/home/?source=TAGWL_MAY07
next reply other threads:[~2007-05-17 4:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-17 4:56 sk b [this message]
2007-05-17 5:04 ` Al Viro
2007-05-17 5:06 ` David Miller
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=BAY115-W33D3EC723171255D88FBF86330@phx.gbl \
--to=skb300@hotmail.com \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®