* [PATCH] Input: Added check for grabbed device
@ 2015-01-04 8:25 Anshul Garg
2015-01-04 22:46 ` Dmitry Torokhov
0 siblings, 1 reply; 2+ messages in thread
From: Anshul Garg @ 2015-01-04 8:25 UTC (permalink / raw)
To: dmitry.torokhov, dtor, linux-input; +Cc: aksgarg1989, anshul.g
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;
+ }
while (retval + input_event_size() <= count) {
if (input_event_from_user(buffer + retval, &event)) {
--
1.7.9.5
---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Input: Added check for grabbed device
2015-01-04 8:25 [PATCH] Input: Added check for grabbed device Anshul Garg
@ 2015-01-04 22:46 ` Dmitry Torokhov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2015-01-04 22:46 UTC (permalink / raw)
To: Anshul Garg; +Cc: linux-input, anshul.g
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-01-04 22:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-04 8:25 [PATCH] Input: Added check for grabbed device Anshul Garg
2015-01-04 22:46 ` Dmitry Torokhov
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).