mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH][3/4] let's kill verify_area - convert kernel/compat.c to access_ok()
@ 2005-01-07  1:18 Jesper Juhl
  2005-01-07  1:58 ` Andries Brouwer
  0 siblings, 1 reply; 3+ messages in thread
From: Jesper Juhl @ 2005-01-07  1:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Andrew Morton


Here's a patch to convert verify_area to access_ok in kernel/compat.c

diff -up linux-2.6.10-bk9-orig/kernel/compat.c linux-2.6.10-bk9/kernel/compat.c
--- linux-2.6.10-bk9-orig/kernel/compat.c	2005-01-06 22:19:13.000000000 +0100
+++ linux-2.6.10-bk9/kernel/compat.c	2005-01-07 02:06:00.000000000 +0100
@@ -26,16 +26,16 @@
 
 int get_compat_timespec(struct timespec *ts, const struct compat_timespec __user *cts)
 {
-	return (verify_area(VERIFY_READ, cts, sizeof(*cts)) ||
+	return (access_ok(VERIFY_READ, cts, sizeof(*cts)) ||
 			__get_user(ts->tv_sec, &cts->tv_sec) ||
-			__get_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0;
+			__get_user(ts->tv_nsec, &cts->tv_nsec)) ? 0 : -EFAULT;
 }
 
 int put_compat_timespec(const struct timespec *ts, struct compat_timespec __user *cts)
 {
-	return (verify_area(VERIFY_WRITE, cts, sizeof(*cts)) ||
+	return (access_ok(VERIFY_WRITE, cts, sizeof(*cts)) ||
 			__put_user(ts->tv_sec, &cts->tv_sec) ||
-			__put_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0;
+			__put_user(ts->tv_nsec, &cts->tv_nsec)) ? 0 : EFAULT;
 }
 
 static long compat_nanosleep_restart(struct restart_block *restart)
@@ -612,7 +612,7 @@ long compat_get_bitmap(unsigned long *ma
 	/* align bitmap up to nearest compat_long_t boundary */
 	bitmap_size = ALIGN(bitmap_size, BITS_PER_COMPAT_LONG);
 
-	if (verify_area(VERIFY_READ, umask, bitmap_size / 8))
+	if (!access_ok(VERIFY_READ, umask, bitmap_size / 8) != 0)
 		return -EFAULT;
 
 	nr_compat_longs = BITS_TO_COMPAT_LONGS(bitmap_size);
@@ -653,7 +653,7 @@ long compat_put_bitmap(compat_ulong_t __
 	/* align bitmap up to nearest compat_long_t boundary */
 	bitmap_size = ALIGN(bitmap_size, BITS_PER_COMPAT_LONG);
 
-	if (verify_area(VERIFY_WRITE, umask, bitmap_size / 8))
+	if (!access_ok(VERIFY_WRITE, umask, bitmap_size / 8) != 0)
 		return -EFAULT;
 
 	nr_compat_longs = BITS_TO_COMPAT_LONGS(bitmap_size);




^ permalink raw reply	[flat|nested] 3+ messages in thread
* RE: [PATCH][3/4] let's kill verify_area - convert kernel/compat.c to access_ok()
@ 2005-01-07 10:02 Peter Kjellerstedt
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Kjellerstedt @ 2005-01-07 10:02 UTC (permalink / raw)
  To: Jesper Juhl, linux-kernel; +Cc: Andrew Morton

> -----Original Message-----
> From: linux-kernel-owner@vger.kernel.org
[mailto:linux-kernel-owner@vger.kernel.org] On Behalf Of Jesper Juhl
> Sent: Friday, January 07, 2005 02:19
> To: linux-kernel
> Cc: Andrew Morton
> Subject: [PATCH][3/4] let's kill verify_area - convert kernel/compat.c
to access_ok()
> 
> Here's a patch to convert verify_area to access_ok in kernel/compat.c
> 
> diff -up linux-2.6.10-bk9-orig/kernel/compat.c 
> linux-2.6.10-bk9/kernel/compat.c
> --- linux-2.6.10-bk9-orig/kernel/compat.c	2005-01-06
22:19:13.000000000 +0100
> +++ linux-2.6.10-bk9/kernel/compat.c	2005-01-07 02:06:00.000000000
+0100

[snip]

> @@ -612,7 +612,7 @@ long compat_get_bitmap(unsigned long *ma
>  	/* align bitmap up to nearest compat_long_t boundary */
>  	bitmap_size = ALIGN(bitmap_size, BITS_PER_COMPAT_LONG);
>  
> -	if (verify_area(VERIFY_READ, umask, bitmap_size / 8))
> +	if (!access_ok(VERIFY_READ, umask, bitmap_size / 8) != 0)

Please do not use double negations (i.e., drop the '!= 0' test 
again).

>  		return -EFAULT;
>  
>  	nr_compat_longs = BITS_TO_COMPAT_LONGS(bitmap_size);
> @@ -653,7 +653,7 @@ long compat_put_bitmap(compat_ulong_t __
>  	/* align bitmap up to nearest compat_long_t boundary */
>  	bitmap_size = ALIGN(bitmap_size, BITS_PER_COMPAT_LONG);
>  
> -	if (verify_area(VERIFY_WRITE, umask, bitmap_size / 8))
> +	if (!access_ok(VERIFY_WRITE, umask, bitmap_size / 8) != 0)
>  		return -EFAULT;
>  
>  	nr_compat_longs = BITS_TO_COMPAT_LONGS(bitmap_size);

//Peter

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-01-07 10:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-07  1:18 [PATCH][3/4] let's kill verify_area - convert kernel/compat.c to access_ok() Jesper Juhl
2005-01-07  1:58 ` Andries Brouwer
2005-01-07 10:02 Peter Kjellerstedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®