Bug 139651 - [nfs] mount(8): read-only remount of NFS volume does not work
Summary: [nfs] mount(8): read-only remount of NFS volume does not work
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-fs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-15 19:40 UTC by alexander.haderer
Modified: 2018-07-04 22:23 UTC (History)
1 user (show)

See Also:
bugmeister: mfc-stable10?
bugmeister: mfc-stable9?
bugmeister: mfc-stable8?


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description alexander.haderer 2009-10-15 19:40:02 UTC
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.

Fix: 

Only workarounds:

- make the exported filesystem read-only
- export the NFS volume as read-only
- umount and NFS remount read-only
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)
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2009-10-15 20:30:48 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-fs

Over to maintainer(s).
Comment 2 Jaakko Heinonen freebsd_committer freebsd_triage 2011-01-04 16:57:50 UTC
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
Comment 3 alexander.haderer 2011-01-05 17:01:47 UTC
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
Comment 4 Jaakko Heinonen freebsd_committer freebsd_triage 2011-01-05 18:14:58 UTC
State Changed
From-To: open->patched

Fixed in stable/8 according to submitter.
Comment 5 Ian Lepore freebsd_committer freebsd_triage 2018-07-04 22:23:07 UTC
This was fixed long ago.  Re-confirmed that it still works properly on 12-current.