Bug 15739 - readonly attribute of a bind mount is not preserved across bind mounts.
Summary: readonly attribute of a bind mount is not preserved across bind mounts.
Status: CLOSED PATCH_ALREADY_AVAILABLE
Alias: None
Product: File System
Classification: Unclassified
Component: VFS (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Marshel Abraham
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-09 14:38 UTC by Tefnet developers
Modified: 2013-05-15 06:00 UTC (History)
1 user (show)

See Also:
Kernel Version: 2.6.31
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Tefnet developers 2010-04-09 14:38:21 UTC
root@tefnet:/tmp/bindtest# mkdir -p 1/11 2 3

When I mount -o bind,ro a directory:

root@tefnet:/tmp/bindtest# mount 1 2 -o bind,ro
root@tefnet:/tmp/bindtest# touch 2/foo
touch: cannot touch `2/foo': Read-only file system

and then mount part of it with -o bind:

root@tefnet:/tmp/bindtest# mount 2/11 3 -o bind
root@tefnet:/tmp/bindtest# touch 3/foo
root@tefnet:/tmp/bindtest#

the mounted part is read-write despite no specification of ro/rw option on the mount command line.

I expected the "3" directory to be read-only as well.
Comment 1 Marshel Abraham 2013-05-12 09:06:16 UTC
This issue seems to be solved in the latest kernel. Remember 2.6 onwards kernel doesnt support to bind mount a rw file system to ro, the first step itself doesnt work in my kernel.

root@host:/# mount 1 2 -o bind,ro
mount: warning: 2 seems to be mounted read-write.

http://lwn.net/Articles/281157/

Besides that the filesystem subdirectories tend to retain their properties...

In your case /2 is ro, But /2/11 is rw having inherited from 1/11

So 2/11 which is rw when bind mounted to /3 retains the rw...


Can this issue be closed...?
Comment 2 Tefnet developers 2013-05-12 18:56:21 UTC
Thanks for the update, it seems more reasonable now:

root@klocek:/tmp/bindtest# mkdir -p 1/11 2 3
root@klocek:/tmp/bindtest# mount 1 2 -o bind,ro
mount: warning: 2 seems to be mounted read-write.
root@klocek:/tmp/bindtest# mount 2 -o remount,ro
root@klocek:/tmp/bindtest# touch 2/foo
touch: cannot touch `2/foo': Read-only file system
root@klocek:/tmp/bindtest# mount 2/11 3 -o bind,rw
mount: warning: 3 seems to be mounted read-only.
root@klocek:/tmp/bindtest# touch 3/foo
touch: cannot touch `3/foo': Read-only file system
root@klocek:/tmp/bindtest# 

The original problem I had with that (unexpected write possibilities) does not seem to occur anymore, so I think that the issue can be closed :).
Comment 3 Marshel Abraham 2013-05-14 05:19:51 UTC
Can somebody close this..?

Note You need to log in before you can comment on or make changes to this bug.