All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] autofs4: check dev ioctl size before allocating
@ 2014-03-16  1:40 Sasha Levin
  2014-04-05 15:06 ` Sasha Levin
  0 siblings, 1 reply; 7+ messages in thread
From: Sasha Levin @ 2014-03-16  1:40 UTC (permalink / raw)
  To: raven; +Cc: autofs, linux-kernel, Sasha Levin

There wasn't any check of the size passed from userspace before
trying to allocate the memory required.

This meant that userspace might request more space than allowed,
triggering an OOM.

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 fs/autofs4/dev-ioctl.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c
index 3182c0e..86fa7af 100644
--- a/fs/autofs4/dev-ioctl.c
+++ b/fs/autofs4/dev-ioctl.c
@@ -103,6 +103,9 @@ static struct autofs_dev_ioctl *copy_dev_ioctl(struct autofs_dev_ioctl __user *i
 	if (tmp.size < sizeof(tmp))
 		return ERR_PTR(-EINVAL);
 
+	if (tmp.size > (PATH_MAX + sizeof(tmp)))
+		return ERR_PTR(-E2BIG);
+
 	return memdup_user(in, tmp.size);
 }
 
-- 
1.7.2.5


^ permalink raw reply related	[flat|nested] 7+ messages in thread
* [PATCH] autofs4: check dev ioctl size before allocating
@ 2014-04-07  1:42 Ian Kent
  0 siblings, 0 replies; 7+ messages in thread
From: Ian Kent @ 2014-04-07  1:42 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Sasha Levin, autofs mailing list, Kernel Mailing List

From: Sasha Levin <sasha.levin@oracle.com>

There wasn't any check of the size passed from userspace before
trying to allocate the memory required.

This meant that userspace might request more space than allowed,
triggering an OOM.

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Ian Kent <raven@themaw.net>
---
 fs/autofs4/dev-ioctl.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c
index 3182c0e..232e03d 100644
--- a/fs/autofs4/dev-ioctl.c
+++ b/fs/autofs4/dev-ioctl.c
@@ -103,6 +103,9 @@ static struct autofs_dev_ioctl *copy_dev_ioctl(struct autofs_dev_ioctl __user *i
 	if (tmp.size < sizeof(tmp))
 		return ERR_PTR(-EINVAL);
 
+	if (tmp.size > (PATH_MAX + sizeof(tmp)))
+		return ERR_PTR(-ENAMETOOLONG);
+
 	return memdup_user(in, tmp.size);
 }
 


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-04-07  1:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-16  1:40 [PATCH] autofs4: check dev ioctl size before allocating Sasha Levin
2014-04-05 15:06 ` Sasha Levin
2014-04-06  3:03   ` Ian Kent
2014-04-06  3:11     ` Sasha Levin
2014-04-06  3:53       ` Ian Kent
2014-04-07  0:03         ` Sasha Levin
2014-04-07  1:42 Ian Kent

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.