From owner-freebsd-bugs@FreeBSD.ORG Fri Nov 3 01:00:50 2006 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B82BB16A403 for ; Fri, 3 Nov 2006 01:00:50 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3728143D62 for ; Fri, 3 Nov 2006 01:00:49 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id kA310nJJ008894 for ; Fri, 3 Nov 2006 01:00:49 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id kA310mYp008893; Fri, 3 Nov 2006 01:00:48 GMT (envelope-from gnats) Resent-Date: Fri, 3 Nov 2006 01:00:48 GMT Resent-Message-Id: <200611030100.kA310mYp008893@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, Csaba Henk Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A86BC16A40F for ; Fri, 3 Nov 2006 00:57:41 +0000 (UTC) (envelope-from csaba@beastie.creo.hu) Received: from beastie.creo.hu (www.creo.hu [217.113.62.14]) by mx1.FreeBSD.org (Postfix) with ESMTP id E580243D58 for ; Fri, 3 Nov 2006 00:57:38 +0000 (GMT) (envelope-from csaba@beastie.creo.hu) Received: from beastie.creo.hu (localhost [127.0.0.1]) by beastie.creo.hu (8.13.4/8.13.4) with ESMTP id kA30undo025867 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 3 Nov 2006 01:56:49 +0100 (CET) (envelope-from csaba@beastie.creo.hu) Received: (from csaba@localhost) by beastie.creo.hu (8.13.4/8.13.4/Submit) id kA30unfs025866; Fri, 3 Nov 2006 01:56:49 +0100 (CET) (envelope-from csaba) Message-Id: <200611030056.kA30unfs025866@beastie.creo.hu> Date: Fri, 3 Nov 2006 01:56:49 +0100 (CET) From: Csaba Henk To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Csaba Henk Subject: kern/105093: ext2fs on read-only media cannot be mounted X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Csaba Henk List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Nov 2006 01:00:50 -0000 >Number: 105093 >Category: kern >Synopsis: ext2fs on read-only media cannot be mounted >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 03 01:00:46 GMT 2006 >Closed-Date: >Last-Modified: >Originator: Csaba Henk >Release: FreeBSD 6.1-PRERELEASE i386 >Organization: creo.hu >Environment: System: FreeBSD beastie.creo.hu 6.1-PRERELEASE FreeBSD 6.1-PRERELEASE #1: Tue Feb 21 14:50:42 CET 2006 toor@beastie.creo.hu:/usr/obj/usr/src/sys/HCS i386 >Description: In ext_mountfs of sys/gnu/fs/ext2fs/ext2_vfsops.c it's checked errorneously whether mounter wants a read-only mount. Therefore this function will always act as in case of a writable mount which yields an EROFS if the media is actually read-only. This might also lead to unintended fs modification despite the "-o ro" option; I haven't made experiments of such type though, it's just a hypothetical problem at this point. This bug is present at least in RELENG6 and HEAD branches. >How-To-Repeat: - Create a sparse file in some of your filesystems. - Format the sparse file as an ext2 filesystem by mke2fs(8). - Remount the host filesystem read-only. - Create an md node backed by the ext2 file using mdconfig(8). - Try to mount the resulting md node with ext2 type. You will get EROFS either you use "-o ro" or not. >Fix: Apply the follwing patch: --- ext2_vfsops.c.orig Fri Nov 3 01:31:42 2006 +++ ext2_vfsops.c Fri Nov 3 01:34:10 2006 @@ -601,7 +601,7 @@ ext2_mountfs(devvp, mp, td) int error; int ronly; - ronly = vfs_flagopt(mp->mnt_optnew, "ro", NULL, 0); + ronly = (mp->mnt_flag & MNT_RDONLY) ? : 1 : 0; /* XXX: use VOP_ACESS to check FS perms */ DROP_GIANT(); g_topology_lock(); Csaba >Release-Note: >Audit-Trail: >Unformatted: