Module Name: src Committed By: martin Date: Tue Jun 10 16:10:59 UTC 2014
Modified Files: src/sys/fs/tmpfs: tmpfs_vfsops.c Log Message: Check for invalid mount arguments early and gracefully fail the mount. Spotted by pooka@ To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 src/sys/fs/tmpfs/tmpfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/fs/tmpfs/tmpfs_vfsops.c diff -u src/sys/fs/tmpfs/tmpfs_vfsops.c:1.62 src/sys/fs/tmpfs/tmpfs_vfsops.c:1.63 --- src/sys/fs/tmpfs/tmpfs_vfsops.c:1.62 Sat Jun 7 09:54:34 2014 +++ src/sys/fs/tmpfs/tmpfs_vfsops.c Tue Jun 10 16:10:59 2014 @@ -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 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;