Commit 6994d8b8 authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: evdev - limit amount of data for writes

Limit amount of data that can be written into an evdev instance at
a given time to 4096 bytes (170 input events) to avoid holding
evdev->mutex for too long and starving other users.
Reviewed-by: default avatarJeff LaBundy <jeff@labundy.com>
Reviewed-by: default avatarPeter Hutterer <peter.hutterer@who-t.net>
Link: https://lore.kernel.org/r/Zr5L8TUzkJcB9HcF@google.comSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 6c65914a
......@@ -498,6 +498,13 @@ static ssize_t evdev_write(struct file *file, const char __user *buffer,
struct input_event event;
int retval = 0;
/*
* Limit amount of data we inject into the input subsystem so that
* we do not hold evdev->mutex for too long. 4096 bytes corresponds
* to 170 input events.
*/
count = min(count, 4096);
if (count != 0 && count < input_event_size())
return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment