Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Jan 2010 07:57:43 +0000 (UTC)
From:      Jaakko Heinonen <jh@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r201773 - head/sys/fs/tmpfs
Message-ID:  <201001080757.o087vhrr009799@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201001080757.o087vhrr009799>