aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDavid Teigland2013-02-04 15:31:22 -0600
committerDavid Teigland2013-02-04 15:31:22 -0600
commitd4b0bcf32b946590afd29e202d6a399b84fe6c67 (patch)
treeab44da9a693c1e7fd22e5f45d26e1e7742281516 /fs
parent6edacf05c8362f4c368991b55d85e8122cfc9a24 (diff)
downloadkernel-common-d4b0bcf32b946590afd29e202d6a399b84fe6c67.tar.gz
kernel-common-d4b0bcf32b946590afd29e202d6a399b84fe6c67.tar.xz
kernel-common-d4b0bcf32b946590afd29e202d6a399b84fe6c67.zip
dlm: check the write size from user
Return EINVAL from write if the size is larger than allowed. Do this before allocating kernel memory for the bogus size, which could lead to OOM. Reported-by: Sasha Levin <levinsasha928@gmail.com> Tested-by: Jana Saout <jana@saout.de> Signed-off-by: David Teigland <teigland@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/dlm/user.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/dlm/user.c b/fs/dlm/user.c
index 7ff49852b0c..911649a47dd 100644
--- a/fs/dlm/user.c
+++ b/fs/dlm/user.c
@@ -503,11 +503,11 @@ static ssize_t device_write(struct file *file, const char __user *buf,
503#endif 503#endif
504 return -EINVAL; 504 return -EINVAL;
505 505
506#ifdef CONFIG_COMPAT 506 /*
507 if (count > sizeof(struct dlm_write_request32) + DLM_RESNAME_MAXLEN) 507 * can't compare against COMPAT/dlm_write_request32 because
508#else 508 * we don't yet know if is64bit is zero
509 */
509 if (count > sizeof(struct dlm_write_request) + DLM_RESNAME_MAXLEN) 510 if (count > sizeof(struct dlm_write_request) + DLM_RESNAME_MAXLEN)
510#endif
511 return -EINVAL; 511 return -EINVAL;
512 512
513 kbuf = kzalloc(count + 1, GFP_NOFS); 513 kbuf = kzalloc(count + 1, GFP_NOFS);