Re: AUDIT: copy_from_user is a deathtrap.

Rusty Russell
2002-05-22T06:25:01Z

On Tue, 21 May 2002 14:46:08 -0700
Andrew Morton <akpm@zip.com.au> wrote:
> Is it safe to stick a nose in here with some irrelevancies?

Well, if you can do it, I guess I can too...

Someone who knows x86 asm better than I can change everything in uaccess.h
to always return 0, like so:

#define copy_from_user(to, from, n) \
({ \
/* Returns non-zero only if hit fault handler */ \
if (general_copy_user((to), (from), (n))) \
memset(to, 0, n); \
0; \
})

So the fault handler sends a SIGSEGV, and makes generic_copy_user return 1
immediately (if you were ambitious, it could do the memset too).

If someone wants to write the asm for that, I'll fix the SEGV delivery code
and mount option reading (two places where we must not deliver a signal),
and we can see what it looks like.

Cheers,
Rusty.
--
there are those who do and those who hang on and you don't see too
many doers quoting their contemporaries. -- Larry McVoy