linux-mips
[Top] [All Lists]

Re: __access_ok

To: Carsten Langgaard <carstenl@mips.com>
Subject: Re: __access_ok
From: Justin Carlson <justin@cs.cmu.edu>
Date: 17 Jun 2002 09:24:58 -0700
Cc: linux-mips@oss.sgi.com
In-reply-to: <3D0DCDCB.252F5565@mips.com>
References: <3D0DCDCB.252F5565@mips.com>
Sender: owner-linux-mips@oss.sgi.com
On Mon, 2002-06-17 at 04:53, Carsten Langgaard wrote:

>   * Address valid if:
> - *  - "addr" doesn't have any high-bits set
> - *  - AND "size" doesn't have any high-bits set
> - *  - AND "addr+size" doesn't have any high-bits set
> - *  - OR we are in kernel mode.
> + *  - In user mode and "addr" and "addr+size" in USEG (or XUSEG).
> + *  - OR we are in kernel mode and "addr" and "addr+size" isn't in the
> + *    area between USEG (XUSEG) and KSEG0.

You also need to test for high bit set in size.  Otherwise, for example,
if a process was ok to access range 0x40000000-0x40003fff, 
access_ok(0x40001000, 0xfffff100) would return 1.  The addition will
wrap around, leading to all sorts of fun havoc.

-Justin


<Prev in Thread] Current Thread [Next in Thread>