summaryrefslogtreecommitdiff
path: root/drivers/tty/vt/selection.c
diff options
context:
space:
mode:
authorJiri Slaby (SUSE) <jirislaby@kernel.org>2024-01-22 14:03:20 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-01-28 05:08:52 +0300
commitd321cd13f6dca3c1b0e9e9735901fb5eee7a501c (patch)
tree23b990ec9ba2afa076b724747dc07c40b27a9442 /drivers/tty/vt/selection.c
parenta0b8a1681254346010edd2f94e799fb6b6568cf1 (diff)
downloadlinux-d321cd13f6dca3c1b0e9e9735901fb5eee7a501c.tar.xz
tty: vt: push console lock from tioclinux() down to 2 functions
Avoid costly user copies under the console lock. So push the lock down from tioclinux() to sel_loadlut() and set_vesa_blanking(). It is now obvious what is actually protected. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Tested-by: Helge Deller <deller@gmx.de> # parisc STI console Link: https://lore.kernel.org/r/20240122110401.7289-7-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/vt/selection.c')
-rw-r--r--drivers/tty/vt/selection.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/tty/vt/selection.c b/drivers/tty/vt/selection.c
index e172ede235a0..91d789c025c6 100644
--- a/drivers/tty/vt/selection.c
+++ b/drivers/tty/vt/selection.c
@@ -113,15 +113,22 @@ static inline int inword(const u32 c)
* sel_loadlut() - load the LUT table
* @lut: user table
*
- * Load the LUT table from user space. The caller must hold the console
- * lock. Make a temporary copy so a partial update doesn't make a mess.
+ * Load the LUT table from user space. Make a temporary copy so a partial
+ * update doesn't make a mess.
+ *
+ * Locking: The console lock is acquired.
*/
int sel_loadlut(u32 __user *lut)
{
u32 tmplut[ARRAY_SIZE(inwordLut)];
+
if (copy_from_user(tmplut, lut, sizeof(inwordLut)))
return -EFAULT;
+
+ console_lock();
memcpy(inwordLut, tmplut, sizeof(inwordLut));
+ console_unlock();
+
return 0;
}