From: Sasha Levin <levinsasha928@gmail.com>
To: ccaulfie@redhat.com, teigland@redhat.com
Cc: cluster-devel@redhat.com, linux-kernel@vger.kernel.org,
davej@redhat.com, Sasha Levin <levinsasha928@gmail.com>
Subject: [PATCH] dlm: check the maximum size of a request from user
Date: Sun, 9 Sep 2012 16:16:58 +0200 [thread overview]
Message-ID: <1347200218-3697-1-git-send-email-levinsasha928@gmail.com> (raw)
device_write only checks whether the request size is big enough, but it doesn't
check if the size is too big.
At that point, it also tries to allocate as much memory as the user has requested
even if it's too much. This can lead to OOM killer kicking in, or memory corruption
if (count + 1) overflows.
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
fs/dlm/user.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/fs/dlm/user.c b/fs/dlm/user.c
index eb4ed9b..7ff4985 100644
--- a/fs/dlm/user.c
+++ b/fs/dlm/user.c
@@ -503,6 +503,13 @@ static ssize_t device_write(struct file *file, const char __user *buf,
#endif
return -EINVAL;
+#ifdef CONFIG_COMPAT
+ if (count > sizeof(struct dlm_write_request32) + DLM_RESNAME_MAXLEN)
+#else
+ if (count > sizeof(struct dlm_write_request) + DLM_RESNAME_MAXLEN)
+#endif
+ return -EINVAL;
+
kbuf = kzalloc(count + 1, GFP_NOFS);
if (!kbuf)
return -ENOMEM;
--
1.7.12
next reply other threads:[~2012-09-09 14:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-09 14:16 Sasha Levin [this message]
2012-09-10 15:43 ` [PATCH] dlm: check the maximum size of a request from user David Teigland
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1347200218-3697-1-git-send-email-levinsasha928@gmail.com \
--to=levinsasha928@gmail.com \
--cc=ccaulfie@redhat.com \
--cc=cluster-devel@redhat.com \
--cc=davej@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=teigland@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox