aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/char/keyboard.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-06-24 08:45:27 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2015-06-24 08:45:27 -0700
commit4b1f2af6752a4cc9acc1c22ddf3842478965f113 (patch)
tree632e499f2a15b7d6128be11d148fcdc653813ef3 /drivers/s390/char/keyboard.c
parentMerge tag 'microblaze-4.2-rc1' of git://git.monstr.eu/linux-2.6-microblaze (diff)
parents390/pci: improve handling of hotplug event 0x301 (diff)
downloadlinux-dev-4b1f2af6752a4cc9acc1c22ddf3842478965f113.tar.xz
linux-dev-4b1f2af6752a4cc9acc1c22ddf3842478965f113.zip
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
Pull s390 updates from Martin Schwidefsky: "Pretty boring for a merge window pull. One change in behaviour is the patch for dasd driver, the module which provides the diagnose discipline is now loaded automatically. The SCLP code got a nice cleanup, a new global structure replaces a bunch of accessor functions. And a couple of random, small improvements" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: s390/pci: improve handling of hotplug event 0x301 s390/setup: fix DMA_API_DEBUG warnings s390/zcrypt: remove obsolete __constant s390/keyboard: avoid off-by-one when using strnlen_user() s390/sclp: pass timeout as HZ independent value s390/mm: s/specifiation/specification/, s/an specification/a specification/ s390/sclp: Use DECLARE_BITMAP s390/dasd: Enable automatic loading of dasd_diag_mod s390/sclp: move sclp_facilities into "struct sclp" s390/sclp: get rid of sclp_get_mtid() and sclp_get_mtid_max() s390/sclp: unify basic sclp access by exposing "struct sclp" s390/sclp: prepare smp_fill_possible_mask for global "struct sclp"
Diffstat (limited to 'drivers/s390/char/keyboard.c')
-rw-r--r--drivers/s390/char/keyboard.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/s390/char/keyboard.c b/drivers/s390/char/keyboard.c
index 01463b052ae7..ef04a9f7a704 100644
--- a/drivers/s390/char/keyboard.c
+++ b/drivers/s390/char/keyboard.c
@@ -433,20 +433,23 @@ do_kdgkb_ioctl(struct kbd_data *kbd, struct kbsentry __user *u_kbs,
case KDSKBSENT:
if (!perm)
return -EPERM;
- len = strnlen_user(u_kbs->kb_string,
- sizeof(u_kbs->kb_string) - 1);
+ len = strnlen_user(u_kbs->kb_string, sizeof(u_kbs->kb_string));
if (!len)
return -EFAULT;
- if (len > sizeof(u_kbs->kb_string) - 1)
+ if (len > sizeof(u_kbs->kb_string))
return -EINVAL;
- p = kmalloc(len + 1, GFP_KERNEL);
+ p = kmalloc(len, GFP_KERNEL);
if (!p)
return -ENOMEM;
if (copy_from_user(p, u_kbs->kb_string, len)) {
kfree(p);
return -EFAULT;
}
- p[len] = 0;
+ /*
+ * Make sure the string is terminated by 0. User could have
+ * modified it between us running strnlen_user() and copying it.
+ */
+ p[len - 1] = 0;
kfree(kbd->func_table[kb_func]);
kbd->func_table[kb_func] = p;
break;