Re: sys_chroot+sys_fchdir Fix

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: David Newall <david@...>
Cc: Al Viro <viro@...>, Phillip Susi <psusi@...>, Bill Davidsen <davidsen@...>, majkls <majkls@...>, <bunk@...>, <linux-kernel@...>
Date: Thursday, September 27, 2007 - 3:28 am

On Thu, 27 Sep 2007 06:49:28 +0930
David Newall <david@davidnewall.com> wrote:

 

So keep reading the links I gave you:

    http://www.unixwiz.net/techtips/chroot-practices.html

    The chroot call itself does not change the working directory, so
    if the new root is below the current directory, the application
    can still have access outside resources.

    http://www.bpfh.net/simes/computing/chroot-break.html

    chdir("/foo/bar");
    chroot("/foo/bar");

    Note the use of the chdir() call before the chroot() call. This is
    to ensure that the working directory of the process is within the
    chroot()ed area before the chroot() call takes place. This is due
    to most implementations of chroot() not changing the working
    directory of the process to within the directory the process is
    now chroot()ed in.

    http://www.faqs.org/faqs/unix-faq/programmer/secure-programming/

    The chroot() call itself will only change the root file system in
    the process' context. A chroot() call must be followed by a
    chdir("/") call in order to reset the current working directory.

So the OpenBSD man page seems to be in the minority here.  Any portable
code can not assume that CWD changes.  And changing the Linux behaviour
now would be a rather big change which might break userspace.  And yes,
there are applications that rely on this, I've used it when building
software for cross compiling.  

  /Christer

On Thu, 27 Sep 2007 06:49:28 +0930
David Newall <david@davidnewall.com> wrote:

-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
sys_chroot+sys_fchdir Fix, majkls, (Wed Sep 19, 3:19 am)
Re: sys_chroot+sys_fchdir Fix, Alan Cox, (Wed Sep 19, 5:40 am)
Re: sys_chroot+sys_fchdir Fix, Bill Davidsen, (Wed Sep 19, 2:27 pm)
Re: sys_chroot+sys_fchdir Fix, Alan Cox, (Wed Sep 19, 2:45 pm)
Re: sys_chroot+sys_fchdir Fix, David Newall, (Wed Sep 19, 6:24 pm)
Re: sys_chroot+sys_fchdir Fix, Phillip Susi, (Fri Sep 21, 1:39 pm)
Re: sys_chroot+sys_fchdir Fix, Alan Cox, (Fri Sep 21, 2:10 pm)
Re: sys_chroot+sys_fchdir Fix, Phillip Susi, (Tue Sep 25, 4:53 pm)
Re: sys_chroot+sys_fchdir Fix, Al Viro, (Tue Sep 25, 8:23 pm)
Re: sys_chroot+sys_fchdir Fix, David Newall, (Wed Sep 26, 6:34 am)
Re: sys_chroot+sys_fchdir Fix, Christer Weinigel, (Wed Sep 26, 3:24 pm)
Re: sys_chroot+sys_fchdir Fix, David Newall, (Wed Sep 26, 5:19 pm)
Re: sys_chroot+sys_fchdir Fix, Christer Weinigel, (Thu Sep 27, 3:28 am)
Re: sys_chroot+sys_fchdir Fix, Theodore Tso, (Thu Sep 27, 7:23 am)
Re: sys_chroot+sys_fchdir Fix, Bill Davidsen, (Thu Sep 27, 10:36 am)
Re: sys_chroot+sys_fchdir Fix, David Newall, (Thu Sep 27, 9:06 pm)
Re: sys_chroot+sys_fchdir Fix, Adrian Bunk, (Wed Sep 26, 5:55 pm)
Re: sys_chroot+sys_fchdir Fix, David Newall, (Wed Sep 26, 7:35 pm)
Re: sys_chroot+sys_fchdir Fix, Adrian Bunk, (Wed Sep 26, 8:01 pm)
Re: sys_chroot+sys_fchdir Fix, David Newall, (Thu Sep 27, 2:42 am)
Re: sys_chroot+sys_fchdir Fix, Adrian Bunk, (Thu Sep 27, 2:53 am)
Re: sys_chroot+sys_fchdir Fix, Al Viro, (Wed Sep 26, 11:59 pm)
Re: sys_chroot+sys_fchdir Fix, Al Viro, (Wed Sep 26, 2:40 pm)
Re: sys_chroot+sys_fchdir Fix, Alan Cox, (Wed Sep 26, 7:21 am)
Re: sys_chroot+sys_fchdir Fix, David Newall, (Wed Sep 26, 7:22 am)
Re: sys_chroot+sys_fchdir Fix, Alan Cox, (Wed Sep 26, 7:38 am)
Re: sys_chroot+sys_fchdir Fix, David Newall, (Wed Sep 26, 7:56 am)
Re: sys_chroot+sys_fchdir Fix, Alan Cox, (Wed Sep 26, 10:10 am)
Re: sys_chroot+sys_fchdir Fix, David Newall, (Wed Sep 26, 12:54 pm)
Re: sys_chroot+sys_fchdir Fix, Alan Cox, (Wed Sep 26, 1:04 pm)
Re: sys_chroot+sys_fchdir Fix, David Newall, (Wed Sep 26, 1:18 pm)
Re: sys_chroot+sys_fchdir Fix, Alan Cox, (Wed Sep 26, 1:29 pm)
Re: sys_chroot+sys_fchdir Fix, David Newall, (Wed Sep 26, 1:28 pm)
Re: sys_chroot+sys_fchdir Fix, Chris Adams, (Wed Sep 26, 11:03 am)