kern/105093: ext2fs on read-only media cannot be mounted

Csaba Henk csaba.henk at creo.hu
Fri Nov 3 01:00:50 UTC 2006


>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 at 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:


More information about the freebsd-bugs mailing list