svn commit: r201773 - head/sys/fs/tmpfs

Jaakko Heinonen jh at FreeBSD.org
Fri Jan 8 07:57:44 UTC 2010


Author: jh
Date: Fri Jan  8 07:57:43 2010
New Revision: 201773
URL: http://svn.freebsd.org/changeset/base/201773

Log:
  - Change the type of size_max to u_quad_t because its value is converted
    with vfs_scanopt(9) using the "%qu" format string.
  - Limit the maximum value of size_max to (SIZE_MAX - PAGE_SIZE) to
    prevent overflow in howmany() macro.
  
  PR:		kern/141194
  Approved by:	trasz (mentor)
  MFC after:	2 weeks

Modified:
  head/sys/fs/tmpfs/tmpfs_vfsops.c

Modified: head/sys/fs/tmpfs/tmpfs_vfsops.c
==============================================================================
--- head/sys/fs/tmpfs/tmpfs_vfsops.c	Fri Jan  8 07:42:01 2010	(r201772)
+++ head/sys/fs/tmpfs/tmpfs_vfsops.c	Fri Jan  8 07:57:43 2010	(r201773)
@@ -185,8 +185,8 @@ tmpfs_mount(struct mount *mp)
 	ino_t nodes;
 	int error;
 	/* Size counters. */
-	ino_t	nodes_max;
-	size_t	size_max;
+	ino_t		nodes_max;
+	u_quad_t	size_max;
 
 	/* Root node attributes. */
 	uid_t	root_uid;
@@ -239,7 +239,7 @@ tmpfs_mount(struct mount *mp)
 	 * allowed to use, based on the maximum size the user passed in
 	 * the mount structure.  A value of zero is treated as if the
 	 * maximum available space was requested. */
-	if (size_max < PAGE_SIZE || size_max >= SIZE_MAX)
+	if (size_max < PAGE_SIZE || size_max > (SIZE_MAX - PAGE_SIZE))
 		pages = SIZE_MAX;
 	else
 		pages = howmany(size_max, PAGE_SIZE);


More information about the svn-src-all mailing list