public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ksys_mount: check for permissions before resource allocation
@ 2018-06-05  2:00 Ilya Matveychikov
  2018-06-05  6:59 ` Ilya Matveychikov
  0 siblings, 1 reply; 13+ messages in thread
From: Ilya Matveychikov @ 2018-06-05  2:00 UTC (permalink / raw)
  To: linux-kernel

Early check for mount permissions prevents possible allocation of 3
pages from kmalloc() pool by unpriveledged user which can be used for
spraying the kernel heap.

Signed-off-by: Ilya V. Matveychikov <matvejchikov@gmail.com>
---
 fs/namespace.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/namespace.c b/fs/namespace.c
index 5f75969adff1..1ef8feb2de2a 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -3046,6 +3046,9 @@ int ksys_mount(char __user *dev_name, char __user *dir_name, char __user *type,
 	char *kernel_dev;
 	void *options;

+	if (!may_mount())
+		return -EPERM;
+
 	kernel_type = copy_mount_string(type);
 	ret = PTR_ERR(kernel_type);
 	if (IS_ERR(kernel_type))
--
2.17.0

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

end of thread, other threads:[~2018-06-06 15:26 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-05  2:00 [PATCH] ksys_mount: check for permissions before resource allocation Ilya Matveychikov
2018-06-05  6:59 ` Ilya Matveychikov
2018-06-05 11:26   ` Al Viro
2018-06-05 11:35     ` Ilya Matveychikov
2018-06-05 11:53       ` Al Viro
2018-06-05 12:07         ` Ilya Matveychikov
2018-06-05 12:28           ` David Sterba
2018-06-05 12:42             ` Ilya Matveychikov
2018-06-05 12:34           ` Al Viro
2018-06-05 19:56   ` Eric W. Biederman
2018-06-06  9:32     ` Ilya Matveychikov
2018-06-06 14:22       ` Eric W. Biederman
2018-06-06 15:26         ` Ilya Matveychikov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox