Re: sys_chroot+sys_fchdir Fix

2007-09-27 Thread David Newall
Bill Davidsen wrote: It seems there are (at least) two parts to this, one regarding changing working directory which is clearly stated in the standards and must work as it does, and the various issues regarding getting out of the chroot after the cwd has entered that changed root. That second

Re: sys_chroot+sys_fchdir Fix

2007-09-27 Thread Bill Davidsen
Theodore Tso wrote: On Thu, Sep 27, 2007 at 09:28:08AM +0200, Christer Weinigel wrote: 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.

Re: sys_chroot+sys_fchdir Fix

2007-09-27 Thread Theodore Tso
On Thu, Sep 27, 2007 at 09:28:08AM +0200, Christer Weinigel wrote: > 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 ar

Re: sys_chroot+sys_fchdir Fix

2007-09-27 Thread Christer Weinigel
On Thu, 27 Sep 2007 06:49:28 +0930 David Newall <[EMAIL PROTECTED]> 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, simpl

Re: sys_chroot+sys_fchdir Fix

2007-09-26 Thread Adrian Bunk
On Thu, Sep 27, 2007 at 04:12:53PM +0930, David Newall wrote: > Adrian Bunk wrote: >> You claimed: >> >> <-- snip --> >> >> 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;

Re: sys_chroot+sys_fchdir Fix

2007-09-26 Thread David Newall
Adrian Bunk wrote: You claimed: <-- snip --> 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. <-- snip --> You were clearly saying that whom you call "th

Re: sys_chroot+sys_fchdir Fix

2007-09-26 Thread Al Viro
On Thu, Sep 27, 2007 at 02:01:37AM +0200, Adrian Bunk wrote: > <-- snip --> > > 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. > > <-- snip --> > > You

Re: sys_chroot+sys_fchdir Fix

2007-09-26 Thread Adrian Bunk
On Thu, Sep 27, 2007 at 09:05:33AM +0930, David Newall wrote: > Adrian Bunk wrote: >> You are claiming "They went so far as to say that dot-dot wouldn't let you >> out"? >> > > I phrased it in a somewhat conversational way. The promise, which I've now > quoted from multiple sources, is expres

Re: sys_chroot+sys_fchdir Fix

2007-09-26 Thread David Newall
Adrian Bunk wrote: You are claiming "They went so far as to say that dot-dot wouldn't let you out"? I phrased it in a somewhat conversational way. The promise, which I've now quoted from multiple sources, is expressed variously, including: The dot-dot entry in the root directory is interp

Re: sys_chroot+sys_fchdir Fix

2007-09-26 Thread Adrian Bunk
On Thu, Sep 27, 2007 at 06:49:28AM +0930, David Newall wrote: >... > 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. >... You are claiming "They went so far a

Re: sys_chroot+sys_fchdir Fix

2007-09-26 Thread David Newall
Christer Weinigel wrote: *spends five minutes with Google* From the OpenBSD FAQ (an operating system most know for being really, really focused on security): http://www.openbsd.org/faq/faq10.html Any application which has to assume root privileges to operate is pointless to attempt

Re: sys_chroot+sys_fchdir Fix

2007-09-26 Thread Christer Weinigel
On Wed, 26 Sep 2007 20:04:14 +0930 David Newall <[EMAIL PROTECTED]> wrote: > Al Viro wrote: > > Oh, for fsck sake... Folks, it's standard-required behaviour. > > Ability to chroot() implies the ability to break out of it. Could > > we please add that (along with reference to SuS) to l-k FAQ and

Re: Chroot bug (was: sys_chroot+sys_fchdir Fix)

2007-09-26 Thread Bodo Eggert
On Wed, 26 Sep 2007, David Newall wrote: > Miloslav Semler pointed out that a root process can chdir("..") out of > its chroot. Although this is documented in the man page, it conflicts > with the essential function, which is to change the root directory of > the process. The root directory,

Re: sys_chroot+sys_fchdir Fix

2007-09-26 Thread Al Viro
On Wed, Sep 26, 2007 at 08:04:14PM +0930, David Newall wrote: > Al Viro wrote: > >Oh, for fsck sake... Folks, it's standard-required behaviour. Ability > >to chroot() implies the ability to break out of it. Could we please > >add that (along with reference to SuS) to l-k FAQ and be done with tha

Re: sys_chroot+sys_fchdir Fix

2007-09-26 Thread David Newall
Alan Cox wrote: ** Plonk ** Welcome to my killfile. Well that's a relief. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://ww

Re: sys_chroot+sys_fchdir Fix

2007-09-26 Thread Alan Cox
** Plonk ** Welcome to my killfile. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/

Re: sys_chroot+sys_fchdir Fix

2007-09-26 Thread David Newall
Alan Cox wrote: You quoted the standard, I merely pointed out you forgot to read it properly. Thats your problem not mine. How bizarre. Last email you claimed to quote the standards (but you never did.) Your becoming an embarrassment. You were rude, and multiple times. Please just drop

Re: sys_chroot+sys_fchdir Fix

2007-09-26 Thread Alan Cox
You quoted the standard, I merely pointed out you forgot to read it properly. Thats your problem not mine. Alan - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: sys_chroot+sys_fchdir Fix

2007-09-26 Thread David Newall
Alan, Alan Cox wrote: therefore it must be right. You present no reasoning to explain why the behavior is correct; instead you use insults. I've exhausted my tolerance for rudeness. Well if citing standards documents at people is rudeness so be it. Did you just tell a porky? Did you

Re: sys_chroot+sys_fchdir Fix

2007-09-26 Thread Chris Adams
Once upon a time, Alan Cox <[EMAIL PROTECTED]> said: >Well if citing standards documents at people is rudeness so be it. I hate to get involved in this, but actually chroot() is no longer part of SuS as of version 3. For other Unix versions, both Tru64 (5.1B) and Solaris (9) chroot(2) man pages

Re: sys_chroot+sys_fchdir Fix

2007-09-26 Thread Alan Cox
> therefore it must be right. You present no reasoning to explain why the > behavior is correct; instead you use insults. I've exhausted my > tolerance for rudeness. Well if citing standards documents at people is rudeness so be it. Alan - To unsubscribe from this list: send the line "unsubsc

Re: sys_chroot+sys_fchdir Fix

2007-09-26 Thread David Newall
Alan Cox wrote: Now see I've been working on Unix systems since 1988 or so and in that time I've learned to read the documentation properly (you haven't) My, my, you can be unpleasant when you try. There's no need for it. As it happens I have years of UNIX experience on you. (Newbie!) You

Re: sys_chroot+sys_fchdir Fix

2007-09-26 Thread Alan Cox
> I've made no error. The documentation says what it says, and what it > doesn't say, other than for Linux, is that there is an unspecified way > of breaking out. Now see I've been working on Unix systems since 1988 or so and in that time I've learned to read the documentation properly (you hav

Re: sys_chroot+sys_fchdir Fix

2007-09-26 Thread David Newall
Alan Cox wrote: On Wed, 26 Sep 2007 20:04:14 +0930 David Newall <[EMAIL PROTECTED]> wrote: Al Viro wrote: Oh, for fsck sake... Folks, it's standard-required behaviour. Ability to chroot() implies the ability to break out of it. Could we please add that (along with reference to SuS) t

Re: sys_chroot+sys_fchdir Fix

2007-09-26 Thread Alan Cox
On Wed, 26 Sep 2007 20:04:14 +0930 David Newall <[EMAIL PROTECTED]> wrote: > Al Viro wrote: > > Oh, for fsck sake... Folks, it's standard-required behaviour. Ability > > to chroot() implies the ability to break out of it. Could we please > > add that (along with reference to SuS) to l-k FAQ and

Re: sys_chroot+sys_fchdir Fix

2007-09-26 Thread David Newall
Al Viro wrote: Oh, for fsck sake... Folks, it's standard-required behaviour. Ability to chroot() implies the ability to break out of it. Could we please add that (along with reference to SuS) to l-k FAQ and be done with that nonsense? I'm pretty confident that it's only standard behavior for

Re: sys_chroot+sys_fchdir Fix

2007-09-26 Thread Nick Craig-Wood
Al Viro <[EMAIL PROTECTED]> wrote: > If you are within chroot jail and capable of chroot(), you can chdir to > its root, then chroot() to subdirectory and you've got cwd outside of > your new root. After that you can chdir all way out to original > root. Here is some code I wrote a while back

Re: sys_chroot+sys_fchdir Fix

2007-09-25 Thread Al Viro
On Tue, Sep 25, 2007 at 04:53:00PM -0400, Phillip Susi wrote: > Alan Cox wrote: > >On Fri, 21 Sep 2007 13:39:34 -0400 > >Phillip Susi <[EMAIL PROTECTED]> wrote: > > > >>David Newall wrote: > >>>* In particular, the superuser can escape from a =91chroot jail=92 by d= > >>>oing=20 > >>>=91mkdir foo;

Re: sys_chroot+sys_fchdir Fix

2007-09-25 Thread Phillip Susi
Alan Cox wrote: On Fri, 21 Sep 2007 13:39:34 -0400 Phillip Susi <[EMAIL PROTECTED]> wrote: David Newall wrote: * In particular, the superuser can escape from a =91chroot jail=92 by d= oing=20 =91mkdir foo; chroot foo; cd ..=92. No, he can not. The superuser can escape that way - its expecte

Re: Chroot bug (was: sys_chroot+sys_fchdir Fix)

2007-09-25 Thread Adrian Bunk
On Wed, Sep 26, 2007 at 12:40:27AM +0930, David Newall wrote: > Miloslav Semler pointed out that a root process can chdir("..") out of its > chroot. Although this is documented in the man page, it conflicts with the > essential function, which is to change the root directory of the process. >

Re: Chroot bug (was: sys_chroot+sys_fchdir Fix)

2007-09-25 Thread Alan Cox
> Marek's loading dynamic libraries, it seems clear that the prime purpose > of chroot is to aid security. Being able to cd your way out is handy Does it - I can't find any evidence for that. I think you are confusing containers and chroot. They are quite different things. A root user can get o

Re: Chroot bug (was: sys_chroot+sys_fchdir Fix)

2007-09-25 Thread Jan Engelhardt
On Sep 26 2007 00:40, David Newall wrote: > > Miloslav Semler pointed out that a root process can chdir("..") out of its > chroot. Although this is documented in the man page, it conflicts with the > essential function, which is to change the root directory of the process. In > addition to any c

Chroot bug (was: sys_chroot+sys_fchdir Fix)

2007-09-25 Thread David Newall
Miloslav Semler pointed out that a root process can chdir("..") out of its chroot. Although this is documented in the man page, it conflicts with the essential function, which is to change the root directory of the process. In addition to any creative uses, for example Philipp Marek's loading

Re: sys_chroot+sys_fchdir Fix

2007-09-25 Thread David Newall
Serge E. Hallyn wrote: Quoting David Newall ([EMAIL PROTECTED]): Serge E. Hallyn wrote: Quoting David Newall ([EMAIL PROTECTED]): It might be tidy if pivot_root could be used (instead of a hack based on a chroot bug), but it'd still be unportable. It can. Plea

Re: sys_chroot+sys_fchdir Fix

2007-09-25 Thread Serge E. Hallyn
Quoting David Newall ([EMAIL PROTECTED]): > Serge E. Hallyn wrote: >> Quoting David Newall ([EMAIL PROTECTED]): >> >>> It might be tidy if pivot_root could be used (instead of a hack based on >>> a chroot bug), but it'd still be unportable. >>> >> >> It can. >> >> Please re-read my previou

Re: sys_chroot+sys_fchdir Fix

2007-09-25 Thread David Newall
Serge E. Hallyn wrote: Quoting David Newall ([EMAIL PROTECTED]): It might be tidy if pivot_root could be used (instead of a hack based on a chroot bug), but it'd still be unportable. It can. Please re-read my previous msg. I read it. Currently pivot_root can't be used to affect a s

Re: sys_chroot+sys_fchdir Fix

2007-09-24 Thread Serge E. Hallyn
Quoting David Newall ([EMAIL PROTECTED]): > Serge E. Hallyn wrote: >> No reason for any new parameters to pivot_root. Just clone your mounts >> namespace first. >> >> unshare(CLONE_NEWNS); >> chdir(new_dir); >> pivot_root(new_dir, oldroot); >> >> Since pivot_root actually fiddles wi

Re: sys_chroot+sys_fchdir Fix

2007-09-24 Thread Serge E. Hallyn
Quoting David Newall ([EMAIL PROTECTED]): > Serge E. Hallyn wrote: >> No reason for any new parameters to pivot_root. Just clone your mounts >> namespace first. >> >> unshare(CLONE_NEWNS); >> chdir(new_dir); >> pivot_root(new_dir, oldroot); >> >> Since pivot_root actually fiddles wi

Re: sys_chroot+sys_fchdir Fix

2007-09-24 Thread David Newall
Serge E. Hallyn wrote: No reason for any new parameters to pivot_root. Just clone your mounts namespace first. unshare(CLONE_NEWNS); chdir(new_dir); pivot_root(new_dir, oldroot); Since pivot_root actually fiddles with the vfsmnts, this is really the only way to go about

Re: sys_chroot+sys_fchdir Fix

2007-09-24 Thread Serge E. Hallyn
Quoting David Newall ([EMAIL PROTECTED]): > Bill Davidsen wrote: >> there is no question that pivot_root is intended to have breadth for more >> than one process. > > I think it's clear from the man page that the original idea was to be able > to pivot_root for individual processes. The reason

Re: sys_chroot+sys_fchdir Fix

2007-09-21 Thread Alan Cox
On Fri, 21 Sep 2007 13:39:34 -0400 Phillip Susi <[EMAIL PROTECTED]> wrote: > David Newall wrote: > > * In particular, the superuser can escape from a =91chroot jail=92 by d= > > oing=20 > > =91mkdir foo; chroot foo; cd ..=92. > > No, he can not. The superuser can escape that way - its expected a

Re: sys_chroot+sys_fchdir Fix

2007-09-21 Thread Phillip Susi
David Newall wrote: * In particular, the superuser can escape from a =91chroot jail=92 by d= oing=20 =91mkdir foo; chroot foo; cd ..=92. No, he can not. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info a

Re: sys_chroot+sys_fchdir Fix

2007-09-21 Thread David Newall
Bill Davidsen wrote: there is no question that pivot_root is intended to have breadth for more than one process. I think it's clear from the man page that the original idea was to be able to pivot_root for individual processes. The reason it doesn't do that, the reason it affects all proces

Re: sys_chroot+sys_fchdir Fix

2007-09-20 Thread Bill Davidsen
David Newall wrote: Philipp Marek wrote: AFAIK pivot_root() changes the / mapping for *all* processes, no? The manual page is confusing. It even admits to being "intentionally vague". However the goal seems clear: "pivot_root() moves the root file system of the current process to

Re: sys_chroot+sys_fchdir Fix

2007-09-20 Thread David Newall
Philipp Marek wrote: AFAIK pivot_root() changes the / mapping for *all* processes, no? The manual page is confusing. It even admits to being "intentionally vague". However the goal seems clear: "pivot_root() moves the root file system of the current process to the directory put_ol

Re: sys_chroot+sys_fchdir Fix

2007-09-20 Thread Philipp Marek
On Thursday 20 September 2007 David Newall wrote: > Philipp Marek wrote: > > - User starts a small wrapper, > > - that opens "/", > > - chroot()s into a directory and starts fsvs. > > - fsvs gets its libraries loaded > > - and chroot()s back to the original system. > > Isn't that what pivot_root wa

Re: sys_chroot+sys_fchdir Fix

2007-09-20 Thread David Newall
Philipp Marek wrote: - User starts a small wrapper, - that opens "/", - chroot()s into a directory and starts fsvs. - fsvs gets its libraries loaded - and chroot()s back to the original system. Isn't that what pivot_root was meant for? - To unsubscribe from this list: send the line "unsubscribe

Re: sys_chroot+sys_fchdir Fix

2007-09-20 Thread majkls
Philipp Marek napsal(a): Please, everybody, don't change that. I'm currently using that *feature* (yes, I see it as that) in my fsvs-chrooter-utility (see http://fsvs.tigris.org/source/browse/*checkout*/fsvs/trunk/www/doxygen/html/group__howto__chroot.html) for easier usage of fsvs on older sys

Re: sys_chroot+sys_fchdir Fix

2007-09-20 Thread Philipp Marek
Please, everybody, don't change that. I'm currently using that *feature* (yes, I see it as that) in my fsvs-chrooter-utility (see http://fsvs.tigris.org/source/browse/*checkout*/fsvs/trunk/www/doxygen/html/group__howto__chroot.html) for easier usage of fsvs on older systems. - User starts a smal

Re: sys_chroot+sys_fchdir Fix

2007-09-20 Thread Bodo Eggert
David Newall <[EMAIL PROTECTED]> wrote: >> Normal users cannot use chroot() themselves so they can't use chroot to >> get back out > > I think Bill is right, that this is to fix a method that non-root > processes can use to escape their chroot. The exploit, which is > documented in chroot(2)*, is

Re: sys_chroot+sys_fchdir Fix

2007-09-19 Thread David Newall
Normal users cannot use chroot() themselves so they can't use chroot to get back out I think Bill is right, that this is to fix a method that non-root processes can use to escape their chroot. The exploit, which is documented in chroot(2)*, is to chdir("..") your way out. Who'd have thought

Re: sys_chroot+sys_fchdir Fix

2007-09-19 Thread Alan Cox
> I thought this was to prevent breaking out of chroot as a normal user. > ie. chroot /var/myjail /bin/su - guest > or similar. Normal users cannot use chroot() themselves so they can't use chroot to get back out - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in th

Re: sys_chroot+sys_fchdir Fix

2007-09-19 Thread Bill Davidsen
Alan Cox wrote: On Wed, 19 Sep 2007 09:19:50 +0200 majkls <[EMAIL PROTECTED]> wrote: Hello, here is an fix to an exploit (obtained somewhere in internet). This exploit can workaround chroot with CAP_SYS_CHROOT. It is also possible (with sufficient filedescriptor (if there is na directory fd o

Re: sys_chroot+sys_fchdir Fix

2007-09-19 Thread Alan Cox
On Wed, 19 Sep 2007 09:19:50 +0200 majkls <[EMAIL PROTECTED]> wrote: > Hello, > here is an fix to an exploit (obtained somewhere in internet). This > exploit can workaround chroot with CAP_SYS_CHROOT. It is also possible > (with sufficient filedescriptor (if there is na directory fd opened in >

sys_chroot+sys_fchdir Fix

2007-09-19 Thread majkls
Hello, here is an fix to an exploit (obtained somewhere in internet). This exploit can workaround chroot with CAP_SYS_CHROOT. It is also possible (with sufficient filedescriptor (if there is na directory fd opened in root) workaround chroot with sys_fchdir. This patch fixes it. Miloslav Semle