From owner-freebsd-fs@FreeBSD.ORG Wed May 27 15:20:02 2009 Return-Path: Delivered-To: freebsd-fs@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E415910657F5 for ; Wed, 27 May 2009 15:20:02 +0000 (UTC) (envelope-from jh@saunalahti.fi) Received: from gw03.mail.saunalahti.fi (gw03.mail.saunalahti.fi [195.197.172.111]) by mx1.freebsd.org (Postfix) with ESMTP id A155E8FC1A for ; Wed, 27 May 2009 15:20:01 +0000 (UTC) (envelope-from jh@saunalahti.fi) Received: from a91-153-125-115.elisa-laajakaista.fi (a91-153-125-115.elisa-laajakaista.fi [91.153.125.115]) by gw03.mail.saunalahti.fi (Postfix) with SMTP id 510A1216BB4 for ; Wed, 27 May 2009 18:02:59 +0300 (EEST) Date: Wed, 27 May 2009 18:02:59 +0300 From: Jaakko Heinonen To: freebsd-fs@FreeBSD.org Message-ID: <20090527150258.GA3666@a91-153-125-115.elisa-laajakaista.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) Cc: Subject: VOP_WRITE & read-only file system X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 May 2009 15:20:07 -0000 Hi, I found a few ways to get VOP_WRITE called for a read-only system. Looks like there is an assumption in (UFS) file system code that VOP_WRITE is not called for read-only file-systems and indeed the assumption is true in typical cases. Calling VOP_WRITE for a read-only file system leads to erratic behavior at least with UFS. Ways I found: 1) mmap(2) - mmap(2) a file - close(2) the file handle - remount file-system as read-only - modify mapped memory 2) ktrace(2) - start ktracing a process - remount file-system as read-only 3) alq(9) - I didn't really test this but it looks obvious At which level this should be fixed? Is it caller's responsibility not to call VOP_WRITE if the file system is read-only or should there be a check in VOP_WRITE? Another concern is races during remount. I don't see that UFS has protection against read-only flag changing during VOPs. -- Jaakko