Re: Chroot bug

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Kyle Moffett
Date: Wednesday, September 26, 2007 - 5:54 am

On Sep 26, 2007, at 06:27:38, David Newall wrote:

Let me put it this way:  You *CANNOT* enforce chroot() the way you  
want to without a completely unacceptable performance penalty.  Let's  
start with the simplest example of:

fd = open("/", O_DIRECTORY);
chroot("/foo");
fchdir(fd);
chroot(".");

If you had ever actually looked at the Linux VFS, it is completely  
*impossible* to tell whether "fd" at the time of the chroot is inside  
or outside of "/foo" without tracking an enormous amount of extra  
state.  Even then, any such determination may not be valid since an  
FD may be opened to an inode which is hardlinked at multiple  
locations in the directory tree.  It could also be bind-mounted at  
multiple locations, or it may not even be mounted at all in this  
namespace (CDROM that was lazy-unmounted).  That FD may be later  
passed over an open UNIX-domain socket from another process.   
Moreover, arbitrarily closing FDs would break a huge number of  
programs.  Furthermore, since you can't fix the "trivial" case of  
'fchdir()', then there's no point in even *attempting* to fix the  
"cwd is outside of chroot" problem, although that is basically  
equivalent in difficulty to fixing the "dir-fd is outside of chroot"  
problem.

As for the nested-chroot() bit, the root user inside of a chroot is  
always allowed to chroot().  This is necessary for test-suites for  
various distro installers, chroot once to enter the installer  
playpen, installer chroots again to configure the test-installed- 
system.  Once you allow a second chroot, you're back at the "can't  
reliably and efficiently track directory sub-tree members" problem.

So if you think it can and should be fixed, then PROVIDE THE CODE.

Cheers,
Kyle Moffett

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

Messages in current thread:
Re: sys_chroot+sys_fchdir Fix, Bodo Eggert, (Thu Sep 20, 4:13 am)
Re: sys_chroot+sys_fchdir Fix, Philipp Marek, (Thu Sep 20, 4:59 am)
Re: sys_chroot+sys_fchdir Fix, majkls, (Thu Sep 20, 5:52 am)
Re: sys_chroot+sys_fchdir Fix, David Newall, (Thu Sep 20, 9:06 am)
Re: sys_chroot+sys_fchdir Fix, Philipp Marek, (Thu Sep 20, 9:17 am)
Re: sys_chroot+sys_fchdir Fix, David Newall, (Thu Sep 20, 11:02 am)
Re: sys_chroot+sys_fchdir Fix, Bill Davidsen, (Thu Sep 20, 1:53 pm)
Re: sys_chroot+sys_fchdir Fix, David Newall, (Fri Sep 21, 1:29 am)
Re: sys_chroot+sys_fchdir Fix, Serge E. Hallyn, (Mon Sep 24, 2:32 pm)
Re: sys_chroot+sys_fchdir Fix, David Newall, (Mon Sep 24, 3:04 pm)
Re: sys_chroot+sys_fchdir Fix, Serge E. Hallyn, (Mon Sep 24, 4:00 pm)
Re: sys_chroot+sys_fchdir Fix, Serge E. Hallyn, (Mon Sep 24, 4:02 pm)
Re: sys_chroot+sys_fchdir Fix, David Newall, (Tue Sep 25, 12:45 am)
Re: sys_chroot+sys_fchdir Fix, Serge E. Hallyn, (Tue Sep 25, 4:49 am)
Re: sys_chroot+sys_fchdir Fix, David Newall, (Tue Sep 25, 6:58 am)
Chroot bug (was: sys_chroot+sys_fchdir Fix), David Newall, (Tue Sep 25, 8:10 am)
Re: Chroot bug (was: sys_chroot+sys_fchdir Fix), Jan Engelhardt, (Tue Sep 25, 8:20 am)
Re: Chroot bug (was: sys_chroot+sys_fchdir Fix), Alan Cox, (Tue Sep 25, 8:30 am)
Re: Chroot bug (was: sys_chroot+sys_fchdir Fix), Adrian Bunk, (Tue Sep 25, 8:32 am)
Re: Chroot bug, David Newall, (Tue Sep 25, 8:35 am)
Re: Chroot bug, Miloslav Semler, (Tue Sep 25, 8:39 am)
Re: Chroot bug, David Newall, (Tue Sep 25, 8:41 am)
Re: Chroot bug, Miloslav Semler, (Tue Sep 25, 8:43 am)
Re: Chroot bug, Jan Engelhardt, (Tue Sep 25, 8:47 am)
Re: Chroot bug, Alan Cox, (Tue Sep 25, 8:48 am)
Re: Chroot bug, Jan Engelhardt, (Tue Sep 25, 8:48 am)
Re: Chroot bug, Adrian Bunk, (Tue Sep 25, 9:02 am)
Re: Chroot bug, Miloslav Semler, (Tue Sep 25, 9:19 am)
Re: Chroot bug, Arjan van de Ven, (Tue Sep 25, 9:33 am)
Re: Chroot bug, Jan Engelhardt, (Tue Sep 25, 9:52 am)
Re: Chroot bug, Serge E. Hallyn, (Tue Sep 25, 9:53 am)
Re: Chroot bug, Miloslav Semler, (Tue Sep 25, 10:00 am)
Re: Chroot bug, Jan Engelhardt, (Tue Sep 25, 10:05 am)
Re: Chroot bug, Miloslav Semler, (Tue Sep 25, 10:09 am)
Re: Chroot bug, Al Viro, (Tue Sep 25, 10:09 am)
Re: Chroot bug, Miloslav Semler, (Tue Sep 25, 10:19 am)
Re: Chroot bug, David Newall, (Tue Sep 25, 1:51 pm)
Re: Chroot bug, David Newall, (Tue Sep 25, 4:50 pm)
Re: Chroot bug, Alan Cox, (Tue Sep 25, 5:18 pm)
Re: Chroot bug, Adrian Bunk, (Tue Sep 25, 5:55 pm)
Re: Chroot bug, Kyle Moffett, (Tue Sep 25, 10:21 pm)
Re: Chroot bug, Willy Tarreau, (Tue Sep 25, 10:25 pm)
Re: Chroot bug, David Newall, (Wed Sep 26, 3:24 am)
Re: Chroot bug, David Newall, (Wed Sep 26, 3:27 am)
Re: Chroot bug, Olivier Galibert, (Wed Sep 26, 3:45 am)
Re: Chroot bug, Alan Cox, (Wed Sep 26, 3:47 am)
Re: Chroot bug, David Newall, (Wed Sep 26, 4:06 am)
Re: Chroot bug, David Newall, (Wed Sep 26, 4:13 am)
Re: Chroot bug, Alan Cox, (Wed Sep 26, 4:20 am)
Re: Chroot bug, Kyle Moffett, (Wed Sep 26, 5:54 am)
Re: Chroot bug, Miloslav Semler, (Wed Sep 26, 6:11 am)
Re: Chroot bug, Bongani Hlope, (Wed Sep 26, 6:13 am)
Re: Chroot bug, linux-os (Dick Johnson), (Wed Sep 26, 6:18 am)
Re: Chroot bug, Al Viro, (Wed Sep 26, 6:42 am)
Re: Chroot bug, Kyle Moffett, (Wed Sep 26, 7:02 am)
Re: Chroot bug, Miloslav Semler, (Wed Sep 26, 7:51 am)
Re: Chroot bug, Miloslav Semler, (Wed Sep 26, 8:01 am)
Re: Chroot bug, Olivier Galibert, (Wed Sep 26, 8:02 am)
Re: Chroot bug (was: sys_chroot+sys_fchdir Fix), Bodo Eggert, (Wed Sep 26, 12:23 pm)
Re: Chroot bug, Jiri Kosina, (Thu Sep 27, 6:49 am)