[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20070516.220631.07641650.davem@davemloft.net>
Date: Wed, 16 May 2007 22:06:31 -0700 (PDT)
From: David Miller <davem@...emloft.net>
To: skb300@...mail.com
Cc: linux-kernel@...r.kernel.org
Subject: Re: user pointers and race conditions
From: sk b <skb300@...mail.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.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists