Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1404073 > unrolled thread

path-lookup inconsistency ?

Started byBadhri Jagan Sridharan <badhri@google.com>
First post2016-05-20 04:30 +0200
Last post2016-05-20 07:30 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  path-lookup inconsistency ? Badhri Jagan Sridharan <badhri@google.com> - 2016-05-20 04:30 +0200
    Re: path-lookup inconsistency ? Al Viro <viro@ZenIV.linux.org.uk> - 2016-05-20 07:30 +0200

#1404073 — path-lookup inconsistency ?

FromBadhri Jagan Sridharan <badhri@google.com>
Date2016-05-20 04:30 +0200
Subjectpath-lookup inconsistency ?
Message-ID<rAIml-86S-9@gated-at.bofh.it>
Hi,

I mounted overlayfs at /

My cat /proc/mounts looks like the following.
# cat /proc/mounts
/dev/root / squashfs ro,seclabel,relatime 0 0
..
overlayfs / overlay
rw,relatime,lowerdir=/,upperdir=/cache/upper,workdir=/cache/working 0

0

The original blockdevice at fs root is squashfs formatted so doesnt
support write operations. I mounted overlayfs on fs root to cache the
writes made.

While in /, the filesystem does not allow me to create files/directories,
if I dont prefix it with ".." directive.

hikey:/ # mkdir test
mkdir: 'testt12': Read-only file system
hikey:/ # mkdir ../test

"mkdir ../test" command succeeds.

I traced through the fs/namei.c code to notice that __follow_mount_rcu
does not get called when I execute "mkdir test" whereas, it gets called from
the follow_dotdot_rcu when I execute "mkdir ../test"

What is the expected behavior ? Should "mkdir test" and "mkdir ../test"
both succeed ?

Similar inconsistency is found with "ls" and "ls .." as well while in fs root.

Thanks,
Badhri

[toc] | [next] | [standalone]


#1404137

FromAl Viro <viro@ZenIV.linux.org.uk>
Date2016-05-20 07:30 +0200
Message-ID<rALax-1qG-9@gated-at.bofh.it>
In reply to#1404073
On Thu, May 19, 2016 at 07:20:26PM -0700, Badhri Jagan Sridharan wrote:
> Hi,
> 
> I mounted overlayfs at /
> 
> My cat /proc/mounts looks like the following.
> # cat /proc/mounts
> /dev/root / squashfs ro,seclabel,relatime 0 0
> ..
> overlayfs / overlay
> rw,relatime,lowerdir=/,upperdir=/cache/upper,workdir=/cache/working 0
> 0
> 
> The original blockdevice at fs root is squashfs formatted so doesnt
> support write operations. I mounted overlayfs on fs root to cache the
> writes made.
> 
> While in /, the filesystem does not allow me to create files/directories,
> if I dont prefix it with ".." directive.

Chroot to the thing that overmounts root.  All that .. is doing here is
triggering the traversal to whatever covers the parent (== whatever
covers the root itself, since the parent of root is the root itself).
And we do *not* cross a mountpoint if the starting point of lookup
happens to be covered.  Might've been better if we did a different semantics,
but this one is userland-exposed and, worse yet, a bunch of early boot
userland code relies upon it.

What you want is to be chrooted to whatever overmounts the global root.
The easiest way is probably chroot("/..");chdir("/"); when you are
setting the things up.  Before you exec the final /sbin/init...

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web