linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Anshul Garg <aksgarg1989@gmail.com>
Cc: linux-input@vger.kernel.org, anshul.g@samsung.com
Subject: Re: [PATCH] Input: Added check for grabbed device
Date: Sun, 4 Jan 2015 14:46:57 -0800	[thread overview]
Message-ID: <20150104224657.GD31987@dtor-ws> (raw)
In-Reply-To: <1420359955-21553-1-git-send-email-aksgarg1989@gmail.com>

Hi Anshul,

On Sun, Jan 04, 2015 at 12:25:55AM -0800, Anshul Garg wrote:
> From: Anshul Garg <aksgarg1989@gmail.com>
> 
> If input device is grabbed then client which has grabbed the device can
> flush or write to the device so for other clients -EINVAL should be returned.
> 
> Signed-off-by: Anshul Garg <anshul.g@samsung.com>
> ---
>  drivers/input/evdev.c |    7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
> index b1a52ab..105e489 100644
> --- a/drivers/input/evdev.c
> +++ b/drivers/input/evdev.c
> @@ -277,6 +277,8 @@ static int evdev_flush(struct file *file, fl_owner_t id)
>  
>  	if (!evdev->exist || client->revoked)
>  		retval = -ENODEV;
> +	else if (evdev->grab && evdev->grab != client)
> +		retval = -EINVAL;
>  	else
>  		retval = input_flush_device(&evdev->handle, file);
>  
> @@ -475,6 +477,11 @@ static ssize_t evdev_write(struct file *file, const char __user *buffer,
>  		goto out;
>  	}
>  
> +
> +	if (evdev->grab && evdev->grab != client) {
> +		retval = -EINVAL;
> +		goto out;
> +	}

Grab is supposed to be transparent to the other users, so returning
error here is not desirable. Also, input_inject_event() will already
ignore events if device is grabbed, so everything is good as far as
evdev_write() concerned.

Flush is a bit trickier: the driver should only "flush" data that
belongs to the user that issued flush request (and the owner is
identified by file handle passed to flush() method). I think it is OK to
allow owner to flush its own data even while device is grabbed.

Thanks.

-- 
Dmitry

      reply	other threads:[~2015-01-04 22:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-04  8:25 [PATCH] Input: Added check for grabbed device Anshul Garg
2015-01-04 22:46 ` Dmitry Torokhov [this message]

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=20150104224657.GD31987@dtor-ws \
    --to=dmitry.torokhov@gmail.com \
    --cc=aksgarg1989@gmail.com \
    --cc=anshul.g@samsung.com \
    --cc=linux-input@vger.kernel.org \
    /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).