Re: [PATCH] Input: serio_raw - signal EFAULT even if read/write partially succeeds

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 29 Apr 2012 23:44:51 -0700
Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx> wrote:

> When copy_to/from_user fails in the middle of transfer we should not
> report to the user that read/write partially succeeded but rather
> report -EFAULT right away, so that application will know that it got
> its buffers all wrong.

Actually POSIX/SuS is quite explicit that if a write or read partially
succeeds you return the partial result. The error will be returned only
if nothing was written or read, or in some cases can be buffered by the
code for the next read/write attempt (eg for sockets).

In the wait_event_interruptible() case it's even more important as a
signal handler and syscall restart needs to do the right thing. Looking
at the patch it looks like a signal interrupting loses you data with this
change appplied. The -EFAULT one is a corner case, the signal handlers
causing data loss one is not.

EFAULT matters for certain crazy software like persistent storage managers
which use -EFAULT and segfault/bus error catching to implement full
persistent storage. Those people may well be somewhat out of their tree.

> -		if (!(file->f_flags & O_NONBLOCK))
> +		if (!(file->f_flags & O_NONBLOCK)) {
>  			error = wait_event_interruptible(serio_raw->wait,
>  					serio_raw->head != serio_raw->tail ||
>  					serio_raw->dead);
> -	} while (!error);
> +			if (error)
> +				return error;

And we lose data as far as I can see, so a timer event will cause the app
to malfunction.

Alan
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux