From: Sasha Levin <levinsasha928@gmail.com>
To: arnd@arndb.de, gregkh@linuxfoundation.org, viro@zeniv.linux.org.uk
Cc: davej@redhat.com, tglx@linutronix.de,
linux-kernel@vger.kernel.org,
Sasha Levin <levinsasha928@gmail.com>
Subject: [PATCH] kmsg: Use vmalloc instead of kmalloc when writing
Date: Fri, 30 Mar 2012 13:04:27 -0400 [thread overview]
Message-ID: <1333127067-2043-1-git-send-email-levinsasha928@gmail.com> (raw)
There are no size checks in kmsg_write(), and we try allocating enough
memory to store everything userspace gave us, which may be too much for
kmalloc to allocate.
One option would be to limit it to something, but we can't come up with
a number that would make sense.
Instead, just use vmalloc so that nothing would break with large amounts
of data.
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
drivers/char/mem.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index d6e9d08..e047783 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -815,7 +815,7 @@ static ssize_t kmsg_writev(struct kiocb *iocb, const struct iovec *iv,
ssize_t ret = -EFAULT;
size_t len = iov_length(iv, count);
- line = kmalloc(len + 1, GFP_KERNEL);
+ line = vmalloc(len + 1);
if (line == NULL)
return -ENOMEM;
@@ -836,7 +836,7 @@ static ssize_t kmsg_writev(struct kiocb *iocb, const struct iovec *iv,
if (ret > len)
ret = len;
out:
- kfree(line);
+ vfree(line);
return ret;
}
--
1.7.8.4
next reply other threads:[~2012-03-30 15:04 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-30 17:04 Sasha Levin [this message]
2012-03-30 15:30 ` Greg KH
2012-03-30 16:37 ` Sasha Levin
2012-03-30 16:49 ` Greg KH
2012-03-30 17:15 ` Sasha Levin
2012-03-30 20:35 ` Thomas Gleixner
2012-03-30 20:42 ` Greg KH
2012-03-30 20:49 ` Thomas Gleixner
2012-03-30 21:05 ` Arnd Bergmann
2012-03-30 21:17 ` Greg KH
2012-03-30 22:02 ` Sasha Levin
2012-03-30 23:43 ` Greg KH
2012-03-31 0:02 ` Kay Sievers
2012-03-31 8:57 ` Sasha Levin
2012-04-23 9:54 ` Sasha Levin
2012-03-30 21:18 ` Thomas Gleixner
2012-03-31 1:43 ` Joe Perches
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=1333127067-2043-1-git-send-email-levinsasha928@gmail.com \
--to=levinsasha928@gmail.com \
--cc=arnd@arndb.de \
--cc=davej@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=viro@zeniv.linux.org.uk \
/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
all inboxes | Powered by JetHome®