Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 2 Nov 2012 03:59:23 GMT
From:      Garrett Cooper <yanegomi@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   kern/173278: kern_getfsstat incorrectly assumes that flags is a bitmask
Message-ID:  <201211020359.qA23xN36092876@red.freebsd.org>
Resent-Message-ID: <201211020400.qA24002R062261@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         173278
>Category:       kern
>Synopsis:       kern_getfsstat incorrectly assumes that flags is a bitmask
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Nov 02 04:00:00 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Garrett Cooper
>Release:        9.1-PRERELEASE
>Organization:
EMC Isilon
>Environment:
FreeBSD forza.west.isilon.com 9.1-PRERELEASE FreeBSD 9.1-PRERELEASE #0 r240770: Thu Sep 20 19:28:45 PDT 2012     gcooper@forza.west.isilon.com:/usr/obj/usr/src/sys/FORZA  amd64
>Description:
kern_getfsstat incorrectly assumes that flags is a bitmask, when in fact the values that can be passed as flags should be mutually exclusive (from sys/sys/mount.h):

413 /*
414  * Flags for various system call interfaces.
415  *
416  * waitfor flags to vfs_sync() and getfsstat()
417  */
418 #define MNT_WAIT        1       /* synchronously wait for I/O to complete */
419 #define MNT_NOWAIT      2       /* start all I/O, but do not wait for it */
420 #define MNT_LAZY        3       /* push data not written by filesystem synce    r */
421 #define MNT_SUSPEND     4       /* Suspend file system after sync */

..

The following patch should fix kern_getfsstat, but it's untested:

Index: sys/kern/vfs_syscalls.c
===================================================================
--- sys/kern/vfs_syscalls.c     (revision 242321)
+++ sys/kern/vfs_syscalls.c     (working copy)
@@ -504,8 +504,7 @@ kern_getfsstat(struct thread *td, struct statfs **
                         * refresh the fsstat cache. MNT_NOWAIT or MNT_LAZY
                         * overrides MNT_WAIT.
                         */
-                       if (((flags & (MNT_LAZY|MNT_NOWAIT)) == 0 ||
-                           (flags & MNT_WAIT)) &&
+                       if (flags == MNT_WAIT &&
                            (error = VFS_STATFS(mp, sp))) {
                                mtx_lock(&mountlist_mtx);
                                nmp = TAILQ_NEXT(mp, mnt_list);

Noticed by rhestilow <AT> isilon <DON'T-SPAM-ME DOT> com.
>How-To-Repeat:
Call getfsstat with flags == MNT_LAZY.
>Fix:


Patch attached with submission follows:

Index: sys/kern/vfs_syscalls.c
===================================================================
--- sys/kern/vfs_syscalls.c	(revision 242321)
+++ sys/kern/vfs_syscalls.c	(working copy)
@@ -504,8 +504,7 @@
 			 * refresh the fsstat cache. MNT_NOWAIT or MNT_LAZY
 			 * overrides MNT_WAIT.
 			 */
-			if (((flags & (MNT_LAZY|MNT_NOWAIT)) == 0 ||
-			    (flags & MNT_WAIT)) &&
+			if (flags == MNT_WAIT &&
 			    (error = VFS_STATFS(mp, sp))) {
 				mtx_lock(&mountlist_mtx);
 				nmp = TAILQ_NEXT(mp, mnt_list);


>Release-Note:
>Audit-Trail:
>Unformatted:



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