NetBSD Problem Report #42513
From bernd@arresum.veego.de Wed Dec 23 21:15:58 2009
Return-Path: <bernd@arresum.veego.de>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by www.NetBSD.org (Postfix) with ESMTP id F0CA163C3A9
for <gnats-bugs@gnats.NetBSD.org>; Wed, 23 Dec 2009 21:15:57 +0000 (UTC)
Message-Id: <200912232115.nBNLFgI3027804@arresum.veego.de>
Date: Wed, 23 Dec 2009 22:15:42 +0100 (CET)
From: Bernd Ernesti <pr200915@veego.de>
Reply-To: Bernd Ernesti <pr200915@veego.de>
To: gnats-bugs@gnats.NetBSD.org
Subject: permission denied to "cd .."
X-Send-Pr-Version: 3.95
>Number: 42513
>Category: kern
>Synopsis: permission denied to "cd .."
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: kern-bug-people
>State: suspended
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Dec 23 21:20:00 +0000 2009
>Closed-Date:
>Last-Modified: Mon Jun 13 02:35:21 +0000 2011
>Originator: Bernd Ernesti
>Release: NetBSD 5.0_STABLE 20092312 1200UTC
>Organization:
>Environment:
System: NetBSD 5.0_STABLE 20092312 1200UTC
Architecture: i386
Machine: i386
>Description:
I had a problem to build a kernel and was flooded with
cd: can't cd to ..
lines until i did a ctrl-c.
The kernel obj directory was outside of the source tree and the obj
dir (below /x/y) was not on the root filesystem:
/dev/wd0a /
/dev/wd0e /x
/dev/wd1e /x/y
Changing to /x/y works but going one directory up cause an error:
$ /x/y> cd ..
..: Permission denied.
A ls -lad from /x showed this:
drwxr-xr-x 28 xx xx 1024 Dec 23 17:03 y
So it should be fine but looking again after unmounting /x/y
showed this for the same directory:
drwx------ 2 xx xx 512 Oct 12 2008 y
Now to the question: Is this a bug or intentional?
IMHO is this a bug and the cd should use the permissions of the
mounted filesystem and not the one from the underlying fs.
>How-To-Repeat:
Alan Barrett suggested this:
replication recipe (run as non-root user with permission to sudo):
( set -x ; sudo mkdir -p /foo/tmp ; sudo chmod 700 /foo/tmp ; ls -ld /foo/tmp ;
sudo mount_tmpfs -s 10m tmpfs /foo/tmp ; sudo chown "$(id -u)" /foo/tmp ;
ls -ld /foo/tmp ; cd /foo/tmp ; ls -la ; cd .. ; cd / ; sudo umount /foo/tmp )
>Fix:
>Release-Note:
>Audit-Trail:
From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: kern/42513: permission denied to "cd .."
Date: Wed, 30 Dec 2009 21:53:38 +0000
On Wed, Dec 23, 2009 at 09:20:00PM +0000, Bernd Ernesti wrote:
> A ls -lad from /x showed this:
> drwxr-xr-x 28 xx xx 1024 Dec 23 17:03 y
> So it should be fine but looking again after unmounting /x/y
> showed this for the same directory:
> drwx------ 2 xx xx 512 Oct 12 2008 y
>
> Now to the question: Is this a bug or intentional?
>
> IMHO is this a bug and the cd should use the permissions of the
> mounted filesystem and not the one from the underlying fs.
This behavior is historic and near-universal, so whether or not it's a
bug it's something you need to be prepared to encounter in the wild.
It arises because the logic for crossing through mount points passes
through both the mounted and mounted-over directories and therefore
requires access to both.
It may be possible to hack things up so it doesn't happen, but I'm not
sure that'd be desirable and in any event I wouldn't recommend trying
it until I finish beating up namei. :-/
Probably the right time to tackle this is when/if we get around to
adding support for rebind mounts...
--
David A. Holland
dholland@netbsd.org
State-Changed-From-To: open->suspended
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Mon, 13 Jun 2011 02:35:21 +0000
State-Changed-Why:
The objectionable behavior is long-established historical behavior
(though I agree it's objectionable) and there's no hope of dealing
with it robustly until a bunch more namei grinding gets done.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.