Re: AUDIT: copy_from_user is a deathtrap.

Linus Torvalds
2002-05-21T20:48:14Z

On Thu, 16 May 2002, Pavel Machek wrote:
> 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.

Stop this STUPID "it speeds things up" argument.

It's not TRUE.

We still have to do exactly the same things we do right now, because even
if we SIGSEGV we still have to return the right number of bytes
read/written.

SIGSEGV doesn't mean that the system call wouldn't complete. It removes
_none_ of the kernel fixup handling, because the SIGSEGV won't be
delivered until we return to user mode anyway. So please stop mixing these
two issues up.

There are two completely orthogonal issues:

- Use SIGSEGV on system calls or not.

Using SIGSEGV makes the system call vs library routine issue more
regular, but it does not change the fact that the system call has to
return _something_.

- system call return value for partially successful read/write.

We already have the exact same issue wrt something like SIGINT, and
nobody sane would ever suggest that we always return the "whole" thing
if we're interrupted by an external signal.

Similarly, it's naive and stupid to suggest we return success if we get
interrupted by a SIGSEGV/EFAULT.

On the first issue (SIGSEGV) I'm certainly open to trying that out,
although I'm fairly certain there was _some_ reason we didn't do this a
few years ago.

On the second issue, absolutely _nobody_ has shown any reason why we
should break the existing code that does this correctly, and I've shown
reasons why breaking it is STUPID.

Linus