* Re: BUG REPORT: User/Kernel Pointer bug in sys_poll
[not found] <20041028052218.52478.qmail@web50207.mail.yahoo.com>
@ 2004-10-28 5:57 ` Sorav Bansal
2004-10-28 9:48 ` Andrew Morton
0 siblings, 1 reply; 7+ messages in thread
From: Sorav Bansal @ 2004-10-28 5:57 UTC (permalink / raw)
To: Tace; +Cc: linux-kernel
Older x86 architectures (386 and before) allow the kernel to write to any
user location regardless of the write-protect bits.
Hence, with this bug, a user program could write to the write-protected
region of its address space by calling the sys_poll system call and
setting the address and data values appropriately.
An example where this could be exploited is an application running
third-party software. The application may want to write-protect its code
region but with this bug, the third party software will be able to
overwrite write-protected regions by calling sys_poll.
Sorav
On Wed, 27 Oct 2004, Tace wrote:
> sorry but I don't understand, why would it be a
> problem?
>
> --- Sorav Bansal <sbansal@stanford.edu> wrote:
>
> >
> > Package: linux-kernel-src
> > Version: 2.4.27
> >
> > Description: User/Kernel pointer bug/security holl
> > in sys_poll
> >
> > I think, there is a potential bug/security hole in
> > the sys_poll system
> > call.
> >
> > In sys_poll, the user pointer ufds (first arg to
> > sys_poll) goes through
> > copy_from_user. Then __put_user is called on
> > &ufds->revents.
> >
> > Since copy_from_user is a read access and __put_user
> > is a write access,
> > the first call does not verify write-access to ufds.
> > This can be exploited
> > by a malicious user on a 386 machine (where
> > write-protection in
> > kernel mode is not enabled .i.e.
> > CONFIG_X86_WP_WORKS_OK is undef).
> >
> > It seems that this bug can be corrected by replacing
> > the two __put_user
> > calls in sys_poll by put_user. I am using the latest
> > kernel from
> > kernel.org .i.e. linux-2.4.27
> >
> > thanks,
> > Sorav
> >
> > -
> > To unsubscribe from this list: send the line
> > "unsubscribe linux-kernel" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at
> > http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at http://www.tux.org/lkml/
> >
>
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail Address AutoComplete - You start. We finish.
> http://promotions.yahoo.com/new_mail
>
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: BUG REPORT: User/Kernel Pointer bug in sys_poll
2004-10-28 5:57 ` BUG REPORT: User/Kernel Pointer bug in sys_poll Sorav Bansal
@ 2004-10-28 9:48 ` Andrew Morton
2004-10-28 10:04 ` Sorav Bansal
2004-10-28 19:24 ` Alan Cox
0 siblings, 2 replies; 7+ messages in thread
From: Andrew Morton @ 2004-10-28 9:48 UTC (permalink / raw)
To: Sorav Bansal; +Cc: tacetan, linux-kernel
Sorav Bansal <sbansal@stanford.edu> wrote:
>
> Older x86 architectures (386 and before) allow the kernel to write to any
> user location regardless of the write-protect bits.
>
> Hence, with this bug, a user program could write to the write-protected
> region of its address space by calling the sys_poll system call and
> setting the address and data values appropriately.
Nope. The only significant difference between copy_from_user() and
__put_user() here is that copy_from_user() checks that the address is not
in the 0xc0000000-0xffffffff range. __put_user() skips that check.
So
if (copy_from_user(kaddr, addr, n))
fail();
__put_user(42, addr);
is safe. We know that the address is in the 0x00000000-0xbfffffff range by
the time we call __put_user(). And if the page at *addr it not writeable
the kernel will take a fault.
So I see no hole. But I wouldn't have coded it that way...
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: BUG REPORT: User/Kernel Pointer bug in sys_poll
2004-10-28 9:48 ` Andrew Morton
@ 2004-10-28 10:04 ` Sorav Bansal
2004-10-28 19:24 ` Alan Cox
1 sibling, 0 replies; 7+ messages in thread
From: Sorav Bansal @ 2004-10-28 10:04 UTC (permalink / raw)
To: Andrew Morton; +Cc: tacetan, linux-kernel
> Nope. The only significant difference between copy_from_user() and
> __put_user() here is that copy_from_user() checks that the address is not
> in the 0xc0000000-0xffffffff range. __put_user() skips that check.
This is true for modern x86 architectures.
For some older 386's, where Write-Protect does not work okay, there is a
difference between put_user() and copy_from_user(). put_user() performs an
extra check called verify_write() in addition to checking the address
range. Hence, the following code may be unsafe when running on those
machines.
> So
>
> if (copy_from_user(kaddr, addr, n))
> fail();
> __put_user(42, addr);
>
> is safe. We know that the address is in the 0x00000000-0xbfffffff range by
> the time we call __put_user(). And if the page at *addr it not writeable
> the kernel will take a fault.
In older 386's, the kernel will NOT take a fault and write to the
write-protected region.
But then, maybe 386 is too old to worry about :-)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: BUG REPORT: User/Kernel Pointer bug in sys_poll
2004-10-28 9:48 ` Andrew Morton
2004-10-28 10:04 ` Sorav Bansal
@ 2004-10-28 19:24 ` Alan Cox
1 sibling, 0 replies; 7+ messages in thread
From: Alan Cox @ 2004-10-28 19:24 UTC (permalink / raw)
To: Andrew Morton; +Cc: Sorav Bansal, tacetan, Linux Kernel Mailing List
On Iau, 2004-10-28 at 10:48, Andrew Morton wrote:
> is safe. We know that the address is in the 0x00000000-0xbfffffff range by
> the time we call __put_user(). And if the page at *addr it not writeable
> the kernel will take a fault.
>
> So I see no hole. But I wouldn't have coded it that way...
On x86 maybe. I think he's right in the sense that we may have a non x86
platform that this is not safe on.
^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <20041028052218.52478.qmail@web50207.mail.yahoo.com.suse.lists.linux.kernel>]
* BUG REPORT: User/Kernel Pointer bug in sys_poll
@ 2004-10-28 4:25 Sorav Bansal
0 siblings, 0 replies; 7+ messages in thread
From: Sorav Bansal @ 2004-10-28 4:25 UTC (permalink / raw)
To: linux-kernel
Package: linux-kernel-src
Version: 2.4.27
Description: User/Kernel pointer bug/security holl in sys_poll
I think, there is a potential bug/security hole in the sys_poll system
call.
In sys_poll, the user pointer ufds (first arg to sys_poll) goes through
copy_from_user. Then __put_user is called on &ufds->revents.
Since copy_from_user is a read access and __put_user is a write access,
the first call does not verify write-access to ufds. This can be exploited
by a malicious user on a 386 machine (where write-protection in
kernel mode is not enabled .i.e. CONFIG_X86_WP_WORKS_OK is undef).
It seems that this bug can be corrected by replacing the two __put_user
calls in sys_poll by put_user. I am using the latest kernel from
kernel.org .i.e. linux-2.4.27
thanks,
Sorav
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2004-10-28 20:52 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20041028052218.52478.qmail@web50207.mail.yahoo.com>
2004-10-28 5:57 ` BUG REPORT: User/Kernel Pointer bug in sys_poll Sorav Bansal
2004-10-28 9:48 ` Andrew Morton
2004-10-28 10:04 ` Sorav Bansal
2004-10-28 19:24 ` Alan Cox
[not found] <20041028052218.52478.qmail@web50207.mail.yahoo.com.suse.lists.linux.kernel>
[not found] ` <Pine.GSO.4.44.0410272246240.7124-100000@elaine9.Stanford.EDU.suse.lists.linux.kernel>
2004-10-28 6:32 ` Andi Kleen
2004-10-28 8:50 ` Denis Vlasenko
2004-10-28 4:25 Sorav Bansal
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®