Re: AUDIT: copy_from_user is a deathtrap.

Christoph Hellwig (hch@infradead.org)
Tue, 21 May 2002 09:33:57 +0100


On Tue, May 21, 2002 at 03:21:18AM -0300, Arnaldo Carvalho de Melo wrote:
> stay, but something like:
>
> #define copyin(...) (copy_from_user(...) ? -EFAULT : 0)
> #define copyout(...) (copy_to_user(...) ? -EFAULT : 0)
>
> Like several drivers already have (with these names or with other names)
> would be something interesting, that way we could clean up the ones that
> use this construct and all the others that use the longer
> 'copy_{to,from}_user(...) ? -EFAULT : 0' construct. If the powers that be
> accept this, I'd do the work 8)
>
> Is it *BSD that have copyin/copyout with this semantic? If so it'd even
> have an extra bonus to make porting a little bit faster... 8)

FreeBSD has:
/* return 0 on success, EFAULT on failure */
int copyin(const void *udaddr, void *kaddr, size_t len);
int copyout(const void *kaddr, void *udaddr, size_t len);

System V and derivates have:
/* return 0 on success, -1 on failure */
int copyin(const void *userbuf, void *driverbuf, size_t cn);
int copyout(const void *driverbuf, void *userbuf, size_t cn);

OSF/1 has:
/* return 0 on success, some non-specified error on failure) */
int copyin(caddr_t user_src, caddr_t kernel_dest, u_int bcount);
int copyout(caddr_t kernel_src, caddr_t user_dest, u_int bcount);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/