summaryrefslogtreecommitdiffstats
path: root/drivers/tty/vt/consolemap.c
diff options
context:
space:
mode:
authorPhilipp Stanner <pstanner@redhat.com>2023-11-03 12:12:08 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-11-25 07:23:16 +0000
commite651faa2fba4d387aa00b3c02e9c10232852d2ef (patch)
tree30a81de33ad819a75f1beae0061839edb0edbb8b /drivers/tty/vt/consolemap.c
parent727e08b1a56a60ee9b68ae5c7539cbcfe2cfe552 (diff)
downloadlinux-e651faa2fba4d387aa00b3c02e9c10232852d2ef.tar.gz
linux-e651faa2fba4d387aa00b3c02e9c10232852d2ef.tar.bz2
linux-e651faa2fba4d387aa00b3c02e9c10232852d2ef.zip
drivers/tty/vt: use standard array-copy-functions
tty/vt currently uses memdup_user() and vmemdup_array_user() to copy userspace arrays. Whereas there is no danger of overflowing, the call to vmemdup_user() currently utilizes array_size() to calculate the array size nevertheless. This is not useful because array_size() would return SIZE_MAX and pass it to vmemdup_user() in case of (the impossible) overflow. string.h from the core-API now provides the wrappers memdup_array_user() and vmemdup_array_user() to copy userspace arrays in a standardized manner. Additionally, they also perform generic overflow-checks. Use these wrappers to make it more obvious and readable that arrays are being copied. As we are at it, remove two unnecessary empty lines. Suggested-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Philipp Stanner <pstanner@redhat.com> Link: https://lore.kernel.org/r/20231103111207.74621-2-pstanner@redhat.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/vt/consolemap.c')
-rw-r--r--drivers/tty/vt/consolemap.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/tty/vt/consolemap.c b/drivers/tty/vt/consolemap.c
index 5e39a4f430ee..82d70083fead 100644
--- a/drivers/tty/vt/consolemap.c
+++ b/drivers/tty/vt/consolemap.c
@@ -644,7 +644,7 @@ int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list)
if (!ct)
return 0;
- unilist = vmemdup_user(list, array_size(sizeof(*unilist), ct));
+ unilist = vmemdup_array_user(list, ct, sizeof(*unilist));
if (IS_ERR(unilist))
return PTR_ERR(unilist);