From nobody@FreeBSD.org  Thu Oct 15 18:39:48 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id B34EB1065695
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 15 Oct 2009 18:39:48 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id A2DBF8FC23
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 15 Oct 2009 18:39:48 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n9FIdmSM092266
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 15 Oct 2009 18:39:48 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id n9FIdm1N092259;
	Thu, 15 Oct 2009 18:39:48 GMT
	(envelope-from nobody)
Message-Id: <200910151839.n9FIdm1N092259@www.freebsd.org>
Date: Thu, 15 Oct 2009 18:39:48 GMT
From: Alexander Haderer <alexander.haderer@loescap.de>
To: freebsd-gnats-submit@FreeBSD.org
Subject: mount: read-only remount of NFS volume does not work
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         139651
>Category:       bin
>Synopsis:       [nfs] mount(8): read-only remount of NFS volume does not work
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-fs
>State:          patched
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Oct 15 18:40:02 UTC 2009
>Closed-Date:    
>Last-Modified:  Wed Jan 05 18:16:01 UTC 2011
>Originator:     Alexander Haderer
>Release:        Freebsd 7.2R
>Organization:
LoeScap Technology GmbH
>Environment:
FreeBSD xxxxxxx 7.2-RELEASE-p4 FreeBSD 7.2-RELEASE-p4 #0: Fri Oct  2 12:21:39 UTC 2009     root@i386-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  i386

>Description:
When trying to read-only remount a NFS volume with 'mount -u -r /mnt'
the volume will be/remain mounted read-write. Neither the mount command
nor the logfiles show any diagnostics, mount's exitcode is 0.

Note: This problem is strongly related to PR 136470

   kern/136470: [nfs] Cannot mount / in read-only, over NFS

PR Summary: A network booted machine has root NFS mounted read-write,
although in rc.conf   root_rw_mount="NO"  is set. 

Because I run diskless setups, I stumbled over the same problem and
found the PR above. My further investigations of such a network boot
environment show, that rc.d/root respects the config var set, but later
rc.d/mountcritremote calls "mount -a -t nfs", which will silently
remount / as read-write.

I marked this PR as serious because with the current behaviour of mount
one can accidently read-write mount a volume.
>How-To-Repeat:
Setup an NFS server (here: FreeBSD 4.9 running a NFS server with
defaults), then goto 7.2 nfs client machine and do:

# mount server:/fs /mnt
# mount
server:/fs on /mnt (nfs)
# mount -u -r /mnt
# mount
server:/fs on /mnt (nfs)
# umount /mnt

# mount -r server:/fs /mnt
# mount
server:/fs on /mnt (nfs, read-only)
# mount -u -r /mnt
# mount
server:/fs on /mnt (nfs)

>Fix:
Only workarounds:

- make the exported filesystem read-only
- export the NFS volume as read-only
- umount and NFS remount read-only



>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-fs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Thu Oct 15 19:30:48 UTC 2009 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=139651 

From: Jaakko Heinonen <jh@FreeBSD.org>
To: Alexander Haderer <alexander.haderer@loescap.de>
Cc: bug-followup@FreeBSD.org
Subject: Re: bin/139651: mount: read-only remount of NFS volume does not work
Date: Tue, 4 Jan 2011 18:57:50 +0200

 On 2009-10-15, Alexander Haderer wrote:
 > Setup an NFS server (here: FreeBSD 4.9 running a NFS server with defaults), then goto 7.2 nfs client machine and do:
 > 
 > # mount server:/fs /mnt
 > # mount
 > server:/fs on /mnt (nfs)
 > # mount -u -r /mnt
 > # mount
 > server:/fs on /mnt (nfs)
 
 I couldn't reproduce this on 8.1:
 
 # mount server:/stor /mnt
 # mount
 .
 .
 .
 server:/stor on /mnt (nfs)
 # mount -u -r /mnt
 # mount
 .
 .
 .
 server:/stor on /mnt (nfs, read-only)
 # touch /mnt/foo
 touch: /mnt/foo: Read-only file system
 
 -- 
 Jaakko

From: Alexander Haderer <alexander.haderer@loescap.de>
To: Jaakko Heinonen <jh@FreeBSD.org>
Cc: bug-followup@FreeBSD.org
Subject: Re: bin/139651: mount: read-only remount of NFS volume does not work
Date: Wed, 05 Jan 2011 18:01:47 +0100

 Am 04.01.2011 17:57, schrieb Jaakko Heinonen:
 > On 2009-10-15, Alexander Haderer wrote:
 >> Setup an NFS server (here: FreeBSD 4.9 running a NFS server with defaults), then goto 7.2 nfs client machine and do:
 >>
 >> ...
 >
 > I couldn't reproduce this on 8.1:
 >
 I couldn't reproduce this too, on 8.0 and 8.1 i386.
 
 seems to be fixed in 8 branch.
 
 Alexander
State-Changed-From-To: open->patched 
State-Changed-By: jh 
State-Changed-When: Wed Jan 5 18:14:58 UTC 2011 
State-Changed-Why:  
Fixed in stable/8 according to submitter. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=139651 
>Unformatted:
