Messages in this thread | | | From | Rusty Russell <> | Subject | Re: AUDIT: copy_from_user is a deathtrap. | Date | Mon, 20 May 2002 12:06:07 +1000 |
| |
In message <Pine.LNX.4.44.0205191125120.3104-100000@home.transmeta.com> you wri te: > > > On Sat, 18 May 2002, Benjamin Herrenschmidt wrote: > > > > Looking at generic_file_write(), it ignore the count returned by > > copy_from_user and always commit a write for the whole requested > > count, regardless of how much could actually be read from userland. > > The result of copy_from_user is only used as an error condition. > > And this is exactly what makes it re-startable.
If read always returns the amount read (ignoring any copy_to_user errors), then you can repeat it by seeking backwards[1] and redoing the read.
So copy_to_user can simply deliver a SIGSEGV and return "success", and everything will work (except sockets, pipes, etc).
Is this satisfactory? I'd really like to get rid of 5,500 code paths in the kernel...
BTW, SuSv3/POSIX.1.2001 says it's OK, Rusty. [1] No, this won't work on pipes & sockets, but the whole idea won't work on many devices anyway... -- Anyone who quotes me in their sig is an idiot. -- Rusty Russell. - 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/
| |