Re: sys_chroot+sys_fchdir Fix

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Christer Weinigel <christer@...>
Cc: Al Viro <viro@...>, Phillip Susi <psusi@...>, Bill Davidsen <davidsen@...>, majkls <majkls@...>, <bunk@...>, <linux-kernel@...>
Date: Wednesday, September 26, 2007 - 5:19 pm

Christer Weinigel wrote:

For sure, "a root user can get out of a chroot a million different 
ways."  Young Alan said as much at the beginning of this conversation, 
and I have always agreed.  I don't hope to secure Linux within chroot, 
simply to fix chroot so that it does what it says it does.

Look, when chroot was being designed, I think they intended that even 
root should be unable to get out.  They went so far as to say that 
dot-dot wouldn't let you out; and it doesn't.  It's not dot-dot that's 
the problem.  Even fchdir is no problem, because you choose which file 
descriptors to leave open.  Fchdir is actually one of the answers.  
("What if we need a way to escape?")

The problem is leaving cwd unchanged.  Once you've set cwd within the 
new root, dot-dot is promised to keep you within that root; and so it 
does.  But by leaving cwd unchanged, if you do a subsequent chroot, that 
promise is suddenly broken.  I think this is a bug.  I think that 
behavior was not intended.  Not all agree with me, but obviously a lot 
do, otherwise OpenBSD and others wouldn't have addressed this exact 
issue.  Here's what they do:

    "If the program is already running with an altered root directory,
    the process's current directory is changed to the same new root
    directory.  This prevents the current directory from being further
    up the directory tree than the altered root directory."
    -- OpenBSD man 2 chroot


This was no more than an attempt to fix a long-standing bug.

As stated, opinion is divided as to whether this is a bug.  I think it 
is, and many people agree, for example some of the BSDs and probably 
others; some people don't.  Young Alan, for example, ummm, strongly (is 
a good word) disagrees.  I don't see that it calls for nastiness or 
emotion, and although opinion on this august list is divided, apparently 
the nays are in the majority.  We should leave it at that.
-
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)