Commit 484923ad authored by Jiri Slaby's avatar Jiri Slaby Committed by Greg Kroah-Hartman

tty/vt: consolemap: walk the buffer only once in con_set_trans_old()

Fetch the user data one by one (by get_user()) and fill in the local
buffer simultaneously. I.e. we no longer require to walk two buffers and
save thus 256 B from stack (whole ubuf).
Reviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20220607104946.18710-36-jslaby@suse.czSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent fc440658
...@@ -343,15 +343,15 @@ static void update_user_maps(void) ...@@ -343,15 +343,15 @@ static void update_user_maps(void)
*/ */
int con_set_trans_old(unsigned char __user * arg) int con_set_trans_old(unsigned char __user * arg)
{ {
int i;
unsigned short inbuf[E_TABSZ]; unsigned short inbuf[E_TABSZ];
unsigned char ubuf[E_TABSZ]; unsigned int i;
unsigned char ch;
if (copy_from_user(ubuf, arg, E_TABSZ)) for (i = 0; i < ARRAY_SIZE(inbuf); i++) {
if (get_user(ch, &arg[i]))
return -EFAULT; return -EFAULT;
inbuf[i] = UNI_DIRECT_BASE | ch;
for (i = 0; i < E_TABSZ ; i++) }
inbuf[i] = UNI_DIRECT_BASE | ubuf[i];
console_lock(); console_lock();
memcpy(translations[USER_MAP], inbuf, sizeof(inbuf)); memcpy(translations[USER_MAP], inbuf, sizeof(inbuf));
......
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