From owner-freebsd-bugs@FreeBSD.ORG Fri Nov 2 04:00:01 2012 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E7C4956C for ; Fri, 2 Nov 2012 04:00:00 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id BD2928FC12 for ; Fri, 2 Nov 2012 04:00:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id qA2400HT062263 for ; Fri, 2 Nov 2012 04:00:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id qA24002R062261; Fri, 2 Nov 2012 04:00:00 GMT (envelope-from gnats) Resent-Date: Fri, 2 Nov 2012 04:00:00 GMT Resent-Message-Id: <201211020400.qA24002R062261@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Garrett Cooper Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 2445755C for ; Fri, 2 Nov 2012 03:59:24 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id E71A58FC08 for ; Fri, 2 Nov 2012 03:59:23 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.5/8.14.5) with ESMTP id qA23xNtl092877 for ; Fri, 2 Nov 2012 03:59:23 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.5/8.14.5/Submit) id qA23xN36092876; Fri, 2 Nov 2012 03:59:23 GMT (envelope-from nobody) Message-Id: <201211020359.qA23xN36092876@red.freebsd.org> Date: Fri, 2 Nov 2012 03:59:23 GMT From: Garrett Cooper To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: kern/173278: kern_getfsstat incorrectly assumes that flags is a bitmask X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Nov 2012 04:00:01 -0000 >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 isilon 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: