Re: AUDIT: copy_from_user is a deathtrap.

Pavel Machek (pavel@suse.cz)
Thu, 16 May 2002 23:53:36 +0000


Hi!

> > Um, what about delivering a SIGSEGV? So, copy_to/from_user always
> > returns 0, but a signal is delivered.
>
> That doesn't help. It's against some stupid SUS rule, I'm afraid.
>
> (And THAT is a stupid rule, I 100% agree with. It means that some things
> return -EFAULT, and other things do SIGSEGV, and the only difference is
> whether something is a system call or is implemented as a library thing.
> UNIX should always just have segfaulted, but there you are..)

I thought POSIX made it explicit that you may SIGSEGV or EFAULT at your
option. If that SUS rule is stupid, we should just drop it.

Performance advantage from MMX-copy-to-user is probably well worth it.

Ouch, and your read example. Imagine you do read (fd, buf, 12000), and first
page of buf is there, second is not and third is [could happen in your GC
case]. What if copy-to-user decides to first write byte 11045 of buffer,
then byte 17, then byte 4875 (and fault)? I think kernel *has* right to
do that. What will it use as return value?

I think such GC library is seriously broken.
Pavel

-- 
Philips Velo 1: 1"x4"x8", 300gram, 60, 12MB, 40bogomips, linux, mutt,
details at http://atrey.karlin.mff.cuni.cz/~pavel/velo/index.html.

- 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/