All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] check the return value of __copy_to_user in drivers/pcmcia/ds.c::ds_ioctl and return -EFAULT if it fails
@ 2004-10-05 22:21 Jesper Juhl
  2004-10-06 10:43 ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Jesper Juhl @ 2004-10-05 22:21 UTC (permalink / raw)
  To: linux-kernel; +Cc: David A. Hinds, linux-pcmcia


  CC      drivers/pcmcia/ds.o
include/asm/uaccess.h: In function `ds_ioctl':
drivers/pcmcia/ds.c:1049: warning: ignoring return value of `__copy_to_user', declared with attribute warn_unused_result

Patch adds a check of the return value and returns -EFAULT if 
__copy_to_user fails.

Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>

diff -up linux-2.6.9-rc3-bk5-orig/drivers/pcmcia/ds.c linux-2.6.9-rc3-bk5/drivers/pcmcia/ds.c
--- linux-2.6.9-rc3-bk5-orig/drivers/pcmcia/ds.c	2004-10-05 22:07:27.000000000 +0200
+++ linux-2.6.9-rc3-bk5/drivers/pcmcia/ds.c	2004-10-06 00:12:20.000000000 +0200
@@ -1046,7 +1046,11 @@ static int ds_ioctl(struct inode * inode
 	}
     }
 
-    if (cmd & IOC_OUT) __copy_to_user(uarg, (char *)&buf, size);
+    if (cmd & IOC_OUT) {
+        if (__copy_to_user(uarg, (char *)&buf, size))
+            err = -EFAULT;
+    }
+
 
     return err;
 } /* ds_ioctl */



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

* Re: [PATCH] check the return value of __copy_to_user in drivers/pcmcia/ds.c::ds_ioctl and return -EFAULT if it fails
  2004-10-05 22:21 [PATCH] check the return value of __copy_to_user in drivers/pcmcia/ds.c::ds_ioctl and return -EFAULT if it fails Jesper Juhl
@ 2004-10-06 10:43 ` Christoph Hellwig
  2004-10-06 20:25   ` Jesper Juhl
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2004-10-06 10:43 UTC (permalink / raw)
  To: Jesper Juhl; +Cc: linux-kernel, David A. Hinds, linux-pcmcia

On Wed, Oct 06, 2004 at 12:21:58AM +0200, Jesper Juhl wrote:
> 
>   CC      drivers/pcmcia/ds.o
> include/asm/uaccess.h: In function `ds_ioctl':
> drivers/pcmcia/ds.c:1049: warning: ignoring return value of `__copy_to_user', declared with attribute warn_unused_result
> 
> Patch adds a check of the return value and returns -EFAULT if 
> __copy_to_user fails.

I think this function should use the non-__ prefix version and remove access_ok
again


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

* Re: [PATCH] check the return value of __copy_to_user in drivers/pcmcia/ds.c::ds_ioctl and return -EFAULT if it fails
  2004-10-06 10:43 ` Christoph Hellwig
@ 2004-10-06 20:25   ` Jesper Juhl
  0 siblings, 0 replies; 3+ messages in thread
From: Jesper Juhl @ 2004-10-06 20:25 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-kernel, David A. Hinds, linux-pcmcia

On Wed, 6 Oct 2004, Christoph Hellwig wrote:

> On Wed, Oct 06, 2004 at 12:21:58AM +0200, Jesper Juhl wrote:
> > 
> >   CC      drivers/pcmcia/ds.o
> > include/asm/uaccess.h: In function `ds_ioctl':
> > drivers/pcmcia/ds.c:1049: warning: ignoring return value of `__copy_to_user', declared with attribute warn_unused_result
> > 
> > Patch adds a check of the return value and returns -EFAULT if 
> > __copy_to_user fails.
> 
> I think this function should use the non-__ prefix version 

Sounds resonable to me.


>and remove access_ok
> again
> 
Actually I see no access_ok there, there's not one single call to that 
function in this file (2.6.9-rc3-bk5).

How about the following patch instead? 

Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>

diff -up linux-2.6.9-rc3-bk5-orig/drivers/pcmcia/ds.c linux-2.6.9-rc3-bk5/drivers/pcmcia/ds.c
--- linux-2.6.9-rc3-bk5-orig/drivers/pcmcia/ds.c	2004-10-05 22:07:27.000000000 +0200
+++ linux-2.6.9-rc3-bk5/drivers/pcmcia/ds.c	2004-10-06 22:20:27.000000000 +0200
@@ -1046,7 +1046,11 @@ static int ds_ioctl(struct inode * inode
 	}
     }
 
-    if (cmd & IOC_OUT) __copy_to_user(uarg, (char *)&buf, size);
+    if (cmd & IOC_OUT) {
+        if (copy_to_user(uarg, (char *)&buf, size))
+            err = -EFAULT;
+    }
+
 
     return err;
 } /* ds_ioctl */



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

end of thread, other threads:[~2004-10-06 21:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-05 22:21 [PATCH] check the return value of __copy_to_user in drivers/pcmcia/ds.c::ds_ioctl and return -EFAULT if it fails Jesper Juhl
2004-10-06 10:43 ` Christoph Hellwig
2004-10-06 20:25   ` Jesper Juhl

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.