Skip to contentSkip to conversation

add likely around access_ok for uaccess

PATCH Andi Kleen 1 participant 1 message Sep 14, 2003 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Andi Kleen

author
#1 lore raw
Quoted 2 lines · Manfred Spraul

The attached patch adds likely to the tests - any objections? What about the archs except i386?

I fixed x86-64 get/put_user, although it doesn't matter much there because it compiles with -fno-reorder-blocks by default.

(generates smaller code and makes the assembly output much more readable)

But:

Quoted 15 lines

--
Manfred

include/asm-i386/uaccess.h +1 -1
@@ -300,7 +300,7 @@
 	long __pu_err = -EFAULT;					\
 	__typeof__(*(ptr)) *__pu_addr = (ptr);				\
 	might_sleep();						\
-	if (access_ok(VERIFY_WRITE,__pu_addr,size))			\
+	if (likely(access_ok(VERIFY_WRITE,__pu_addr,size)))			\
 		__put_user_size((x),__pu_addr,(size),__pu_err,-EFAULT);	\
 	__pu_err;							\
 })							

include/asm-i386/uaccess.h line 510

Quoted 1 line
include/asm-i386/uaccess.h +0 -0
@@ -510,7 +510,7 @@
 direct_copy_to_user(void __user *to, const void *from, unsigned long n)

My copy of 2.6.0test5 doesn't have a "direct_copy_to_user", so I'm wondering at what tree you're looking.

And more importantly I think the i386 uaccess.h copy_{from/to}_user should be fixed to not do the access_ok()/memset check inline. It can be as well done out of line. This would likely save some code size. Doing it inline just doesn't make any sense.

[x86-64 does it this way]

-Andi