From nobody@www.freebsd.org  Wed Jun 19 08:08:41 2002
Return-Path: <nobody@www.freebsd.org>
Received: from nwww.freebsd.org (www.FreeBSD.org [216.136.204.117])
	by hub.freebsd.org (Postfix) with ESMTP id E736B37B487
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 19 Jun 2002 08:07:39 -0700 (PDT)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by nwww.freebsd.org (8.12.2/8.12.2) with ESMTP id g5JF7dhG096491
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 19 Jun 2002 08:07:39 -0700 (PDT)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.2/8.12.2/Submit) id g5JF7dYU096490;
	Wed, 19 Jun 2002 08:07:39 -0700 (PDT)
Message-Id: <200206191507.g5JF7dYU096490@www.freebsd.org>
Date: Wed, 19 Jun 2002 08:07:39 -0700 (PDT)
From: Robert Jan <rj@xs4all.nl>
To: freebsd-gnats-submit@FreeBSD.org
Subject: getcwd() and unreadable parent directory
X-Send-Pr-Version: www-1.0

>Number:         39527
>Category:       kern
>Synopsis:       getcwd() and unreadable parent directory
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    dwmalone
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jun 19 08:10:01 PDT 2002
>Closed-Date:    Thu Sep 08 15:34:42 UTC 2011
>Last-Modified:  Thu Sep 08 15:34:42 UTC 2011
>Originator:     Robert Jan
>Release:        4.5-RELEASE
>Organization:
XS4ALL Internet
>Environment:
FreeBSD xs0.xs4all.nl 4.5-RELEASE-p3 FreeBSD 4.5-RELEASE-p3 #5: Tue Apr 23 10:22:45 CEST 2002     cor@xs0.xs4all.nl:/usr/src/sys/compile/XS0  i386

>Description:
When working in a directory of which a parent directory is not readable to you, deleting a subdirectory in the current working directory seems to invalidate the directory cache, causing calls to getcwd() to fail with a Permission Denied error, which it did not before. stat()ing the full path to the current working directory seems to re-initialize the cache and solve the problem. stat()ing "." or the chdir() system call do not solve the problem.

This bug was reproduced on FreeBSD 4.2, 4.5, 4.6-RC and 5.0-CURRENT.

>How-To-Repeat:
As root do:

root# cd /tmp && mkdir -p foo/bar && chmod 711 foo && chown user foo/bar

As user do:

user$ cd /tmp/foo/bar
user$ mkdir foo && rmdir foo
user$ /bin/pwd
pwd: .: Permission denied


>Fix:
user$ cd .
user$ /bin/pwd
/tmp/foo/bar

It is the stat() call on /tmp/foo/bar that fixes the problem.

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->dwmalone 
Responsible-Changed-By: dwmalone 
Responsible-Changed-When: Mon Jun 24 04:21:49 PDT 2002 
Responsible-Changed-Why:  
I'm intesteted in having a more detailed look in the name cache fulshing stuff. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=39527 

From: David Malone <dwmalone@maths.tcd.ie>
To: Robert Jan <rj@xs4all.nl>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: kern/39527: getcwd() and unreadable parent directory
Date: Mon, 24 Jun 2002 12:21:12 +0100

 On Wed, Jun 19, 2002 at 08:07:39AM -0700, Robert Jan wrote:
 > >Description:
 > When working in a directory of which a parent directory is not readable to you, deleting a subdirectory in the current working directory seems to invalidate the directory cache, causing calls to getcwd() to fail with a Permission Denied error, which it did not before. stat()ing the full path to the current working directory seems to re-initialize the cache and solve the problem. stat()ing "." or the chdir() system call do not solve the problem.
 > 
 > This bug was reproduced on FreeBSD 4.2, 4.5, 4.6-RC and 5.0-CURRENT.
 
 Getcwd is actually documented to return EACCES if part of the path
 is unaccessable. This is mentioned in susv2, so I assume it is
 something which standards allow.
 
 I think it is actually possible to make the apperance of this problem
 less common though, because the kernel code which flushes part of the
 directory cache may be over eager. I'll take the PR as a reminder to
 investigate this further.
 
 	David.

From: Jaakko Heinonen <jh@saunalahti.fi>
To: bug-followup@FreeBSD.org
Cc: rj@xs4all.nl
Subject: Re: kern/39527: getcwd() and unreadable parent directory
Date: Thu, 12 Feb 2009 21:14:04 +0200

 See also kern/120128 (http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/120128)
 which is a duplicate of this PR and has some information.
 
 -- 
 Jaakko
State-Changed-From-To: open->closed 
State-Changed-By: jh 
State-Changed-When: Thu Sep 8 15:34:41 UTC 2011 
State-Changed-Why:  
Duplicate of kern/120128. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=39527 
>Unformatted:
