lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 30 Mar 2012 13:04:27 -0400
From:	Sasha Levin <levinsasha928@...il.com>
To:	arnd@...db.de, gregkh@...uxfoundation.org, viro@...iv.linux.org.uk
Cc:	davej@...hat.com, tglx@...utronix.de, linux-kernel@...r.kernel.org,
	Sasha Levin <levinsasha928@...il.com>
Subject: [PATCH] kmsg: Use vmalloc instead of kmalloc when writing

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@...il.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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ