summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDavi Arnaut2006-02-01 12:06:40 +0100
committerLinus Torvalds2006-02-01 17:53:25 +0100
commit172411f10c25bbd81b19f67566af6a7f549f46a9 (patch)
tree1a4bf56e53fdc6ea51cc2a72957e0eee710a284f /drivers
parent[PATCH] s390: Add missing memory constraint to stcrw() (diff)
downloadkernel-qcow2-linux-172411f10c25bbd81b19f67566af6a7f549f46a9.tar.gz
kernel-qcow2-linux-172411f10c25bbd81b19f67566af6a7f549f46a9.tar.xz
kernel-qcow2-linux-172411f10c25bbd81b19f67566af6a7f549f46a9.zip
[PATCH] ebcdic do_kdsk_ioctl off-by-one
Add a missing return check from strnlen_user and fixes a off-by-one when terminating the string with zero. Signed-off-by: Davi Arnaut <davi.arnaut@gmail.com> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/s390/char/keyboard.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/s390/char/keyboard.c b/drivers/s390/char/keyboard.c
index 5bda2340a39d..a317a123daba 100644
--- a/drivers/s390/char/keyboard.c
+++ b/drivers/s390/char/keyboard.c
@@ -440,7 +440,11 @@ do_kdgkb_ioctl(struct kbd_data *kbd, struct kbsentry __user *u_kbs,
return -EPERM;
len = strnlen_user(u_kbs->kb_string,
sizeof(u_kbs->kb_string) - 1);
- p = kmalloc(len, GFP_KERNEL);
+ if (!len)
+ return -EFAULT;
+ if (len > sizeof(u_kbs->kb_string) - 1)
+ return -EINVAL;
+ p = kmalloc(len + 1, GFP_KERNEL);
if (!p)
return -ENOMEM;
if (copy_from_user(p, u_kbs->kb_string, len)) {