public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jamie Lokier <jamie@shareable.org>
To: Linus Torvalds <torvalds@osdl.org>
Cc: chris@scary.beasts.org, akpm@osdl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Add 64-bit get_user and __get_user for i386
Date: Mon, 19 Apr 2004 11:14:46 +0100	[thread overview]
Message-ID: <20040419101446.GC13007@mail.shareable.org> (raw)
In-Reply-To: <20040419094408.GA13007@mail.shareable.org>

Ignore the previous patch.  It didn't include the access_ok() check in
64-bit get_user().  Use this instead.

Enjoy,
-- Jamie

Subject: [PATCH] Add 64-bit get_user and __get_user for i386
Patch: uaccess64-2.6.5-jl2

Add 64-bit get_user and __get_user for i386.
This time, include the access_ok() check.
Don't ask me how, but this shrinks the kernel too.

--- orig-2.6.5/include/asm-i386/uaccess.h	2003-12-18 02:58:16.000000000 +0000
+++ uaccess64-2.6.5/include/asm-i386/uaccess.h	2004-04-19 11:06:52.000000000 +0100
@@ -168,17 +168,19 @@
  * Returns zero on success, or -EFAULT on error.
  * On error, the variable @x is set to zero.
  */
-#define get_user(x,ptr)							\
-({	int __ret_gu,__val_gu;						\
-	switch(sizeof (*(ptr))) {					\
-	case 1:  __get_user_x(1,__ret_gu,__val_gu,ptr); break;		\
-	case 2:  __get_user_x(2,__ret_gu,__val_gu,ptr); break;		\
-	case 4:  __get_user_x(4,__ret_gu,__val_gu,ptr); break;		\
-	default: __get_user_x(X,__ret_gu,__val_gu,ptr); break;		\
-	}								\
-	(x) = (__typeof__(*(ptr)))__val_gu;				\
-	__ret_gu;							\
-})
+#define get_user(x,ptr)							      \
+(sizeof (*(ptr)) == 8 ? (copy_from_user((void *)&(x),(ptr),8) ? -EFAULT : 0): \
+({									      \
+  	int __ret_gu,__val_gu;						      \
+	switch(sizeof (*(ptr))) {					      \
+	case 1:  __get_user_x(1,__ret_gu,__val_gu,ptr); break;		      \
+	case 2:  __get_user_x(2,__ret_gu,__val_gu,ptr); break;		      \
+	case 4:  __get_user_x(4,__ret_gu,__val_gu,ptr); break;		      \
+	default: __get_user_bad(); break;				      \
+	}								      \
+	(x) = (__typeof__(*(ptr)))__val_gu;				      \
+	__ret_gu;							      \
+}))
 
 extern void __put_user_bad(void);
 
@@ -333,13 +335,14 @@
 		: ltype (x), "m"(__m(addr)), "i"(errret), "0"(err))
 
 
-#define __get_user_nocheck(x,ptr,size)				\
-({								\
-	long __gu_err, __gu_val;				\
-	__get_user_size(__gu_val,(ptr),(size),__gu_err,-EFAULT);\
-	(x) = (__typeof__(*(ptr)))__gu_val;			\
-	__gu_err;						\
-})
+#define __get_user_nocheck(x,ptr,size)					     \
+((size) == 8 ? (__copy_from_user_ll((void *)&(x), (ptr), 8) ? -EFAULT : 0) : \
+({									     \
+	long __gu_err, __gu_val;					     \
+	__get_user_size(__gu_val,(ptr),(size),__gu_err,-EFAULT);	     \
+	(x) = (__typeof__(*(ptr)))__gu_val;				     \
+	__gu_err;							     \
+}))
 
 extern long __get_user_bad(void);
 


> 
> Enjoy,
> -- Jamie
> 
> Subject: [PATCH] Add 64-bit get_user and __get_user for i386
> Patch: uaccess64-2.6.5
> 
> Add 64-bit get_user and __get_user for i386.
> Don't ask me how, but this shrinks the kernel too.
> 
> --- orig-2.6.5/include/asm-i386/uaccess.h	2003-12-18 02:58:16.000000000 +0000
> +++ uaccess64-2.6.5/include/asm-i386/uaccess.h	2004-04-19 10:33:20.000000000 +0100
> @@ -169,16 +169,19 @@
>   * On error, the variable @x is set to zero.
>   */
>  #define get_user(x,ptr)							\
> -({	int __ret_gu,__val_gu;						\
> +(sizeof (*(ptr)) == 8							\
> + ? (__copy_from_user_ll((void *)&(x), (ptr), 8) ? -EFAULT : 0) :	\
> +({									\
> +  	int __ret_gu,__val_gu;						\
>  	switch(sizeof (*(ptr))) {					\
>  	case 1:  __get_user_x(1,__ret_gu,__val_gu,ptr); break;		\
>  	case 2:  __get_user_x(2,__ret_gu,__val_gu,ptr); break;		\
>  	case 4:  __get_user_x(4,__ret_gu,__val_gu,ptr); break;		\
> -	default: __get_user_x(X,__ret_gu,__val_gu,ptr); break;		\
> +	default: __get_user_bad(); break;				\
>  	}								\
>  	(x) = (__typeof__(*(ptr)))__val_gu;				\
>  	__ret_gu;							\
> -})
> +}))
>  
>  extern void __put_user_bad(void);
>  
> @@ -333,13 +336,14 @@
>  		: ltype (x), "m"(__m(addr)), "i"(errret), "0"(err))
>  
>  
> -#define __get_user_nocheck(x,ptr,size)				\
> -({								\
> -	long __gu_err, __gu_val;				\
> -	__get_user_size(__gu_val,(ptr),(size),__gu_err,-EFAULT);\
> -	(x) = (__typeof__(*(ptr)))__gu_val;			\
> -	__gu_err;						\
> -})
> +#define __get_user_nocheck(x,ptr,size)					     \
> +((size) == 8 ? (__copy_from_user_ll((void *)&(x), (ptr), 8) ? -EFAULT : 0) : \
> +({									     \
> +	long __gu_err, __gu_val;					     \
> +	__get_user_size(__gu_val,(ptr),(size),__gu_err,-EFAULT);	     \
> +	(x) = (__typeof__(*(ptr)))__gu_val;				     \
> +	__gu_err;							     \
> +}))
>  
>  extern long __get_user_bad(void);
>  

  reply	other threads:[~2004-04-19 10:15 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-18  0:28 Nasty 2.6 sendfile() bug / regression; affects vsftpd chris
2004-04-18  3:12 ` Linus Torvalds
2004-04-18 13:49   ` chris
2004-04-19  0:46   ` Jamie Lokier
2004-04-19  5:28     ` Linus Torvalds
2004-04-19  9:44       ` [PATCH] Add 64-bit get_user and __get_user for i386 Jamie Lokier
2004-04-19 10:14         ` Jamie Lokier [this message]
2004-04-19 10:17           ` [PATCH] Use get_user for 64-bit read in sendfile64 Jamie Lokier
2004-04-19 10:36             ` Jamie Lokier
2004-04-19 14:56         ` [PATCH] Add 64-bit get_user and __get_user for i386 Linus Torvalds
     [not found]           ` <20040420020922.GA18348@mail.shareable.org>
     [not found]             ` <Pine.LNX.4.58.0404191945490.29941@ppc970.osdl.org>
2004-04-20 17:41               ` Jamie Lokier
2004-04-21  1:15                 ` Linus Torvalds
2004-04-20 23:21             ` Jim Wilson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040419101446.GC13007@mail.shareable.org \
    --to=jamie@shareable.org \
    --cc=akpm@osdl.org \
    --cc=chris@scary.beasts.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox