From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754742AbcETF0m (ORCPT ); Fri, 20 May 2016 01:26:42 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:54020 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750851AbcETF0l (ORCPT ); Fri, 20 May 2016 01:26:41 -0400 Date: Fri, 20 May 2016 06:26:39 +0100 From: Al Viro To: Badhri Jagan Sridharan Cc: LKML , linux-fsdevel@vger.kernel.org Subject: Re: path-lookup inconsistency ? Message-ID: <20160520052639.GT14480@ZenIV.linux.org.uk> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.0 (2016-04-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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...