BUG REPORT: User/Kernel Pointer bug in sys_poll
A message that is not in the archive (sent off-list or not yet received): [email protected]
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
Quoted 56 lines · Tace
sorry but I don't understand, why would it be a
problem?Quoted 34 lines · --- Sorav Bansal
Package: linux-kernel-src
Version: 2.4.27Description: User/Kernel pointer bug/security holl in
sys_pollI think, there is a potential bug/security hole in the
sys_pollsystem
call.In
sys_poll, the user pointer ufds (first arg tosys_poll) goes throughcopy_from_user. Then__put_useris called on&ufds->revents.Since
copy_from_useris a read access and__put_useris 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_OKis undef).It seems that this bug can be corrected by replacing the two
__put_user
calls insys_pollbyput_user. I am using the latest kernel from
kernel.org .i.e. linux-2.4.27thanks,
SoravQuoted 8 lines
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected] 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
Quoted 7 lines · Sorav Bansal
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_pollsystem 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...
Quoted 4 lines
Nope. The only significant difference between
copy_from_user()and__put_user()here is thatcopy_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.
Quoted 9 lines
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 :-)
Quoted 5 lines · Andrew Morton
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.