linux-mips
[Top] [All Lists]

mips64 _access_ok fix

To: linux-mips@linux-mips.org
Subject: mips64 _access_ok fix
From: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Date: Thu, 11 Sep 2003 12:43:50 +0900 (JST)
Organization: TOSHIBA Personal Computer System Corporation
Original-recipient: rfc822;linux-mips@linux-mips.org
Sender: linux-mips-bounce@linux-mips.org
The mips64 _access_ok macro in 2.4 tree returns 0 if 'addr' + 'size'
== TASK_SIZE.

Also, __ua_size macro returus 0 if 'size' is negative constant.  I
think we must not skip checking negative constant.

Here is a fix.  For 2.6 tree, only _access_ok fix will be needed
(__ua_size is already fixed).

diff -u linux-mips-cvs/include/asm-mips64/uaccess.h 
linux.new/include/asm-mips64/uaccess.h
--- linux-mips-cvs/include/asm-mips64/uaccess.h Tue Jul 15 20:21:59 2003
+++ linux.new/include/asm-mips64/uaccess.h      Thu Sep 11 12:29:08 2003
@@ -46,10 +46,10 @@
  *  - OR we are in kernel mode.
  */
 #define __ua_size(size)                                                        
\
-       ((__builtin_constant_p(size) && (size)) > 0 ? 0 : (size))
+       (__builtin_constant_p(size) && (signed long) (size) > 0 ? 0 : (size))
 
 #define __access_ok(addr, size, mask)                                  \
-       (((mask) & ((addr) | ((addr) + (size)) | __ua_size(size))) == 0)
+       (((mask) & ((addr) | ((addr) + (size) - 1) | __ua_size(size))) == 0)
 
 #define __access_mask get_fs().seg
 
---
Atsushi Nemoto

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