linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Peter Hutterer <peter.hutterer@who-t.net>
Cc: David Herrmann <dh.herrmann@gmail.com>,
	linux-input@vger.kernel.org, Jiri Kosina <jkosina@suse.cz>,
	Benjamin Tissoires <benjamin.tissoires@gmail.com>,
	Antonio Ospite <ospite@studenti.unina.it>,
	linux-kernel@vger.kernel.org, input-tools@lists.freedesktop.org
Subject: Re: [PATCH 2/4] Input: introduce ABS_MAX2/CNT2 and friends
Date: Wed, 18 Dec 2013 16:05:37 -0800	[thread overview]
Message-ID: <20131219000537.GA838@core.coreip.homeip.net> (raw)
In-Reply-To: <20131218235504.GA17958@yabbi.redhat.com>

On Thu, Dec 19, 2013 at 09:55:04AM +1000, Peter Hutterer wrote:
> On Wed, Dec 18, 2013 at 03:48:37PM -0800, Dmitry Torokhov wrote:
> > On Thursday, December 19, 2013 09:40:09 AM Peter Hutterer wrote:
> > > > +     memset(&abs, 0, sizeof(abs));
> > > > +     for (i = valid_cnt; i < cnt; ++i)
> > > > +             if (copy_to_user(&pinfo->info[i], &abs, sizeof(abs)))
> > > > +                     return -EFAULT;
> > > > +
> > > > +     return 0;
> > > 
> > > why don't you return the number of valid copied axes to the user?
> > > that seems better even than forcing the remainder to 0.
> > 
> > Well, if your program messed up buffers that it faulted we do not know
> > for sure if data that did not cause fault ended up where it should have
> > or if it smashed something else. This condition I think should be
> > signaled early.
> 
> not 100% sure I understand but I wasn't proposing to remove the -EFAULT, i
> was proposing to replace "return 0" with "return valid_cnt".

I understand what you were saying. Now consider: your program supplied
buffer that is actually smaller than what it said to the kernel.
Depending on the exact placement we may or may not fault when we get
pass the buffer boundary, most likely not. We are likely to fault when
we go way past the buffer boundary and wracked process' memory. If we
return -EFAULT the program will at least notice that something wrong. If
we return count it will try to resubmit the remainder of operation and
not even know that there was something very bad happening.

IOW we should not treat fault condition as other partial read/write
conditions.

Thanks.

-- 
Dmitry

  reply	other threads:[~2013-12-19  0:05 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-17 15:48 [PATCH 0/4] Input: ABS2 and friends David Herrmann
2013-12-17 15:48 ` [PATCH 1/4] Input: uinput: add full absinfo support David Herrmann
2013-12-18 22:27   ` Peter Hutterer
2014-01-12 19:40     ` Dmitry Torokhov
2014-01-12 19:38   ` Dmitry Torokhov
2013-12-17 15:48 ` [PATCH 2/4] Input: introduce ABS_MAX2/CNT2 and friends David Herrmann
2013-12-18 14:27   ` Antonio Ospite
2013-12-18 14:44     ` David Herrmann
2013-12-18 16:36       ` Dmitry Torokhov
2013-12-18 23:21       ` Antonio Ospite
2013-12-18 14:47   ` Dmitry Torokhov
2013-12-18 23:40   ` Peter Hutterer
2013-12-18 23:48     ` Dmitry Torokhov
2013-12-18 23:55       ` Peter Hutterer
2013-12-19  0:05         ` Dmitry Torokhov [this message]
2013-12-19  0:25           ` Peter Hutterer
2013-12-19  0:34             ` Dmitry Torokhov
2013-12-17 15:48 ` [PATCH 3/4] Input: remove ambigious gamepad comment David Herrmann
2013-12-17 15:48 ` [PATCH 4/4] Input: add motion-tracking ABS_* bits and docs David Herrmann
2013-12-18 14:29   ` Antonio Ospite
2013-12-17 16:34 ` [PATCH 0/4] Input: ABS2 and friends David Herrmann
2013-12-17 21:28 ` simon
2013-12-18  8:12   ` David Herrmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131219000537.GA838@core.coreip.homeip.net \
    --to=dmitry.torokhov@gmail.com \
    --cc=benjamin.tissoires@gmail.com \
    --cc=dh.herrmann@gmail.com \
    --cc=input-tools@lists.freedesktop.org \
    --cc=jkosina@suse.cz \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ospite@studenti.unina.it \
    --cc=peter.hutterer@who-t.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).