From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: linux-input@vger.kernel.org
Cc: Jeff LaBundy <jeff@labundy.com>,
Benjamin Tissoires <bentiss@kernel.org>,
linux-kernel@vger.kernel.org, Hans de Goede <hdegoede@redhat.com>,
Peter Hutterer <peter.hutterer@who-t.net>
Subject: [PATCH] Input: evdev - limit amount of data for writes
Date: Thu, 15 Aug 2024 11:41:53 -0700 [thread overview]
Message-ID: <Zr5L8TUzkJcB9HcF@google.com> (raw)
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.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/evdev.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index a8ce3d140722..eb4906552ac8 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -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;
--
2.46.0.184.g6999bdac58-goog
--
Dmitry
next reply other threads:[~2024-08-15 18:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-15 18:41 Dmitry Torokhov [this message]
2024-08-16 0:18 ` [PATCH] Input: evdev - limit amount of data for writes Peter Hutterer
2024-08-16 6:17 ` Dmitry Torokhov
2024-08-18 5:47 ` Jeff LaBundy
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=Zr5L8TUzkJcB9HcF@google.com \
--to=dmitry.torokhov@gmail.com \
--cc=bentiss@kernel.org \
--cc=hdegoede@redhat.com \
--cc=jeff@labundy.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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).