summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authormartin <martin@NetBSD.org>2014-06-10 16:10:59 +0000
committermartin <martin@NetBSD.org>2014-06-10 16:10:59 +0000
commit95e8f0fabf233ebb84e1e67b58f3003d220abc23 (patch)
tree630537cd19ab55470b7ec27370b4ace426faae60 /sys
parentc7c8d1e038eacbd2011ad7aba019e7d473394df0 (diff)
Check for invalid mount arguments early and gracefully fail the mount.
Spotted by pooka@
Diffstat (limited to 'sys')
-rw-r--r--sys/fs/tmpfs/tmpfs_vfsops.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/sys/fs/tmpfs/tmpfs_vfsops.c b/sys/fs/tmpfs/tmpfs_vfsops.c
index ba412b55787..6cfdff501c1 100644
--- a/sys/fs/tmpfs/tmpfs_vfsops.c
+++ b/sys/fs/tmpfs/tmpfs_vfsops.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tmpfs_vfsops.c,v 1.62 2014/06/07 09:54:34 martin Exp $ */
+/* $NetBSD: tmpfs_vfsops.c,v 1.63 2014/06/10 16:10:59 martin Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.62 2014/06/07 09:54:34 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.63 2014/06/10 16:10:59 martin Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -135,6 +135,14 @@ tmpfs_mount(struct mount *mp, const char *path, void *data, size_t *data_len)
if (tmpfs_mem_info(true) < uvmexp.freetarg)
return EINVAL;
+ /* Check for invalid uid and gid arguments */
+ if (args->ta_root_uid == VNOVAL || args->ta_root_gid == VNOVAL)
+ return EINVAL;
+
+ /* This can never happen? */
+ if ((args->ta_root_mode & ALLPERMS) == VNOVAL)
+ return EINVAL;
+
/* Get the memory usage limit for this file-system. */
if (args->ta_size_max < PAGE_SIZE) {
memlimit = UINT64_MAX;