linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] chroot= as a new kernel parameter
  2008-03-01 19:09 [PATCH] chroot= as a new kernel parameter Pawel Plociennik
@ 2008-03-01 18:47 ` Alexandre Oliva
  2008-03-01 19:44 ` Stefan Hellermann
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 22+ messages in thread
From: Alexandre Oliva @ 2008-03-01 18:47 UTC (permalink / raw)
  To: Pawel Plociennik; +Cc: linux-kernel

On Mar  1, 2008, Pawel Plociennik <paplociennik@gmail.com> wrote:

> In the short this patch has added a new chroot= kernel parameter
> which can be used to changing a chroot of an init process before it
> will has been runed.

Hey, this is cool, I've wanted something like this for a long time.
However, I was thinking of implementing it in mkinitrd, not in the
kernel proper.

OT1H, having it in the kernel proper makes it easier to support even
on distros whose mkinitrd doesn't support this stuff, or that don't
even use an initrd.  OTOH, having it in mkinitrd means you can use
this even on distros whose kernels don't support chroot=.

And then, given that booting up a kernel from one distro on another
requires setting up /lib/modules for proper functioning (unless your
mkinitrd does that for you, which is something else I've been thinking
of doing for similar reasons), I figured changing mkinitrd might be a
better way to go.

-- 
Alexandre Oliva         http://www.lsd.ic.unicamp.br/~oliva/
FSF Latin America Board Member         http://www.fsfla.org/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH] chroot= as a new kernel parameter
@ 2008-03-01 19:09 Pawel Plociennik
  2008-03-01 18:47 ` Alexandre Oliva
                   ` (4 more replies)
  0 siblings, 5 replies; 22+ messages in thread
From: Pawel Plociennik @ 2008-03-01 19:09 UTC (permalink / raw)
  To: linux-kernel

hi *real* hackers,

it is a my first post to lkml and I hope that you will have not been
ignored me if I have done some incorrect thing.

In the short this patch has added a new chroot= kernel parameter which can be used
to changing a chroot of an init process before it will has been runed.
I use that for testing variouses distroes without making a separate partition but
by copied a new root-fs to a new subdirectory on the my *base* filesystem.

PS: be sure that you have added my e-mail in a CC because I am not subscribed
to the lkml and ...
I sorry but my English can be little incorrect because it is not my *native* language :-(      
please do not ignore me if I have been done some inccorect thing.

diff -urp linux-2.6.24-orig/Documentation/kernel-parameters.txt linux-2.6.24/Documentation/kernel-parameters.txt
--- linux-2.6.24-orig/Documentation/kernel-parameters.txt	2008-02-25 20:53:26.000000000 -0500
+++ linux-2.6.24/Documentation/kernel-parameters.txt	2008-02-25 20:51:21.000000000 -0500
@@ -381,6 +381,8 @@ and is between 256 and 4096 characters. 
 			Value can be changed at runtime via
 				/selinux/checkreqprot.
 	
+	chroot=		[KNL] call chroot() for init proccess.
+
 	clock=		[BUGS=X86-32, HW] gettimeofday clocksource override.
 			[Deprecated]
 			Forces specified clocksource (if available) to be used
diff -urp linux-2.6.24-orig/init/main.c linux-2.6.24/init/main.c
--- linux-2.6.24-orig/init/main.c	2008-03-01 12:58:37.000000000 -0500
+++ linux-2.6.24/init/main.c	2008-02-25 20:36:06.000000000 -0500
@@ -755,8 +755,22 @@ static void __init do_pre_smp_initcalls(
 		spawn_softlockup_task();
 }
 
+static void *chroot_str;
+static int __init chroot_setup(char *str)
+{
+	chroot_str = str;
+	return 1;
+}
+__setup("chroot=", chroot_setup);
+
 static void run_init_process(char *init_filename)
 {
+	if(chroot_str) {
+		if(sys_chroot(chroot_str) < 0)
+			printk("chroot=%s failed\n", chroot_str);
+		else
+			printk("chroot=%s successed\n",chroot_str);
+	}
 	argv_init[0] = init_filename;
 	kernel_execve(init_filename, argv_init, envp_init);
 }

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] chroot= as a new kernel parameter
  2008-03-01 19:09 [PATCH] chroot= as a new kernel parameter Pawel Plociennik
  2008-03-01 18:47 ` Alexandre Oliva
@ 2008-03-01 19:44 ` Stefan Hellermann
  2008-03-02 11:17   ` Kasper Sandberg
  2008-03-02 15:35 ` Pavel Machek
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 22+ messages in thread
From: Stefan Hellermann @ 2008-03-01 19:44 UTC (permalink / raw)
  To: Pawel Plociennik; +Cc: linux-kernel

Pawel Plociennik schrieb:
> hi *real* hackers,
> 
> it is a my first post to lkml and I hope that you will have not been
> ignored me if I have done some incorrect thing.
> 
> In the short this patch has added a new chroot= kernel parameter which can be used
> to changing a chroot of an init process before it will has been runed.
> I use that for testing variouses distroes without making a separate partition but
> by copied a new root-fs to a new subdirectory on the my *base* filesystem.

Hi!

Gentoos initrd (build by genkernel) has support for a chrooted boot, the parameter is
called subdir=
Maybe other distros have something similar, it's easy to support this with a initrd/initramfs.

Cheers
Stefan

PS: This is my first post to lkml, too :)

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] chroot= as a new kernel parameter
  2008-03-01 19:44 ` Stefan Hellermann
@ 2008-03-02 11:17   ` Kasper Sandberg
  0 siblings, 0 replies; 22+ messages in thread
From: Kasper Sandberg @ 2008-03-02 11:17 UTC (permalink / raw)
  To: Stefan Hellermann; +Cc: Pawel Plociennik, linux-kernel

On Sat, 2008-03-01 at 20:44 +0100, Stefan Hellermann wrote:
> Pawel Plociennik schrieb:
> > hi *real* hackers,
> > 
> > it is a my first post to lkml and I hope that you will have not been
> > ignored me if I have done some incorrect thing.
> > 
> > In the short this patch has added a new chroot= kernel parameter which can be used
> > to changing a chroot of an init process before it will has been runed.
> > I use that for testing variouses distroes without making a separate partition but
> > by copied a new root-fs to a new subdirectory on the my *base* filesystem.
> 
> Hi!
> 
> Gentoos initrd (build by genkernel) has support for a chrooted boot, the parameter is
> called subdir=
> Maybe other distros have something similar, it's easy to support this with a initrd/initramfs.

Hey!

Im a simple guy though, i prefer this being in the kernel. I do not even
use an initramfs.

> 
> Cheers
> Stefan
> 
> PS: This is my first post to lkml, too :)
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] chroot= as a new kernel parameter
  2008-03-01 19:09 [PATCH] chroot= as a new kernel parameter Pawel Plociennik
  2008-03-01 18:47 ` Alexandre Oliva
  2008-03-01 19:44 ` Stefan Hellermann
@ 2008-03-02 15:35 ` Pavel Machek
  2008-03-02 15:53 ` Filippo Zangheri
  2008-03-02 16:00 ` Guillaume Chazarain
  4 siblings, 0 replies; 22+ messages in thread
From: Pavel Machek @ 2008-03-02 15:35 UTC (permalink / raw)
  To: Pawel Plociennik; +Cc: linux-kernel, Andrew Morton

Hi!

> hi *real* hackers,

:-).

> it is a my first post to lkml and I hope that you will have not been
> ignored me if I have done some incorrect thing.
> 
> In the short this patch has added a new chroot= kernel parameter which can be used
> to changing a chroot of an init process before it will has been runed.
> I use that for testing variouses distroes without making a separate partition but
> by copied a new root-fs to a new subdirectory on the my *base* filesystem.

Yes please. I was thinking about doing this long ago, but never got to
coding it.


> diff -urp linux-2.6.24-orig/Documentation/kernel-parameters.txt linux-2.6.24/Documentation/kernel-parameters.txt
> --- linux-2.6.24-orig/Documentation/kernel-parameters.txt	2008-02-25 20:53:26.000000000 -0500
> +++ linux-2.6.24/Documentation/kernel-parameters.txt	2008-02-25 20:51:21.000000000 -0500
> @@ -381,6 +381,8 @@ and is between 256 and 4096 characters. 
>  			Value can be changed at runtime via
>  				/selinux/checkreqprot.
>  	
> +	chroot=		[KNL] call chroot() for init proccess.
> +
>  	clock=		[BUGS=X86-32, HW] gettimeofday clocksource override.
>  			[Deprecated]
>  			Forces specified clocksource (if available) to be used
> diff -urp linux-2.6.24-orig/init/main.c linux-2.6.24/init/main.c
> --- linux-2.6.24-orig/init/main.c	2008-03-01 12:58:37.000000000 -0500
> +++ linux-2.6.24/init/main.c	2008-02-25 20:36:06.000000000 -0500
> @@ -755,8 +755,22 @@ static void __init do_pre_smp_initcalls(
>  		spawn_softlockup_task();
>  }
>  
> +static void *chroot_str;
> +static int __init chroot_setup(char *str)
> +{
> +	chroot_str = str;
> +	return 1;
> +}
> +__setup("chroot=", chroot_setup);
> +
>  static void run_init_process(char *init_filename)
>  {
> +	if(chroot_str) {

'if ('

> +		if(sys_chroot(chroot_str) < 0)

here too.

> +			printk("chroot=%s failed\n", chroot_str);
> +		else
> +			printk("chroot=%s successed\n",chroot_str);

And I do not think we want to printk in the success case.

Thanks, 
							Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] chroot= as a new kernel parameter
  2008-03-01 19:09 [PATCH] chroot= as a new kernel parameter Pawel Plociennik
                   ` (2 preceding siblings ...)
  2008-03-02 15:35 ` Pavel Machek
@ 2008-03-02 15:53 ` Filippo Zangheri
  2008-03-02 16:00 ` Guillaume Chazarain
  4 siblings, 0 replies; 22+ messages in thread
From: Filippo Zangheri @ 2008-03-02 15:53 UTC (permalink / raw)
  To: Pawel Plociennik; +Cc: linux-kernel

Pawel Plociennik ha scritto:
> hi *real* hackers,
(...)

> diff -urp linux-2.6.24-orig/Documentation/kernel-parameters.txt linux-2.6.24/Documentation/kernel-parameters.txt
> --- linux-2.6.24-orig/Documentation/kernel-parameters.txt	2008-02-25 20:53:26.000000000 -0500
> +++ linux-2.6.24/Documentation/kernel-parameters.txt	2008-02-25 20:51:21.000000000 -0500
> @@ -381,6 +381,8 @@ and is between 256 and 4096 characters. 
>  			Value can be changed at runtime via
>  				/selinux/checkreqprot.
>  	
> +	chroot=		[KNL] call chroot() for init proccess.

Isn't the called function 'sys_chroot()'?


(...)
> +		if(sys_chroot(chroot_str) < 0)
> +			printk("chroot=%s failed\n", chroot_str);

Thanks.


-- 
Filippo Zangheri

GPG key ID: 0xE1D879FA
Key fingerprint: 816B CE57 D43C 0A47 EF35 3378 EA5F A72A E1D8 79FA
Key server: pgp.mit.edu

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GE d- s+:- a-- C++ UL+++ P+ L+++ E-- W+ N* o-- K- w--- O-- M--  
V- PS++ PE+ Y+ PGP++ t 5-- X++ R* tv b+ DI-- D---- G-- e++ h--  
r++ z*                                                          
------END GEEK CODE BLOCK------


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] chroot= as a new kernel parameter
  2008-03-01 19:09 [PATCH] chroot= as a new kernel parameter Pawel Plociennik
                   ` (3 preceding siblings ...)
  2008-03-02 15:53 ` Filippo Zangheri
@ 2008-03-02 16:00 ` Guillaume Chazarain
  2008-03-02 23:59   ` Pawel Plociennik
  2008-03-03 14:11   ` Pavel Machek
  4 siblings, 2 replies; 22+ messages in thread
From: Guillaume Chazarain @ 2008-03-02 16:00 UTC (permalink / raw)
  To: Pawel Plociennik; +Cc: linux-kernel

On Sat, Mar 1, 2008 at 8:09 PM, Pawel Plociennik <paplociennik@gmail.com> wrote:
>  In the short this patch has added a new chroot= kernel parameter which can be used
>  to changing a chroot of an init process before it will has been runed.

Wouldn't booting with 'init=/usr/sbin/chroot /path /sbin/init' achieve
the same effect?
Haven't tested it, just wondering.

>  +       if(chroot_str) {
>  +               if(sys_chroot(chroot_str) < 0)
>  +                       printk("chroot=%s failed\n", chroot_str);
>  +               else
>  +                       printk("chroot=%s successed\n",chroot_str);
>  +       }

Continuing booting normally when the chroot failed sounds like a
security issue to me.

Regards.

-- 
Guillaume

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] chroot= as a new kernel parameter
  2008-03-02 23:59   ` Pawel Plociennik
@ 2008-03-02 18:05     ` Guillaume Chazarain
  2008-03-03  1:09       ` Pawel Plociennik
  2008-03-02 19:05     ` Alan Cox
  1 sibling, 1 reply; 22+ messages in thread
From: Guillaume Chazarain @ 2008-03-02 18:05 UTC (permalink / raw)
  To: Pawel Plociennik; +Cc: linux-kernel

On Mon, Mar 3, 2008 at 12:59 AM, Pawel Plociennik
<paplociennik@gmail.com> wrote:
> On Sunday 02 March 2008 11:00, Guillaume Chazarain wrote:
>  > Wouldn't booting with 'init=/usr/sbin/chroot /path /sbin/init' achieve
>  > the same effect?

>  I think that procces which has pid 0 is a special procces

You mean pid 1, right? ;-)

> because it
>  removes a *zombie* procceses so it is good to use a *dedicated*
>  program for it such as a /sbin/init .
>  /usr/sbin/chroot doesn't remove a *zombie* procceses :-(

Sure, but chroot should then exec /sbin/init as per the given kernel
command line. And then you run a real init.

I cannot try it as I don't have another distribution installed in a
subdirectory, but if you could test it we would quickly know if it
works or not.

Thanks.

-- 
Guillaume

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] chroot= as a new kernel parameter
  2008-03-02 23:59   ` Pawel Plociennik
  2008-03-02 18:05     ` Guillaume Chazarain
@ 2008-03-02 19:05     ` Alan Cox
  1 sibling, 0 replies; 22+ messages in thread
From: Alan Cox @ 2008-03-02 19:05 UTC (permalink / raw)
  To: Pawel Plociennik; +Cc: Guillaume Chazarain, linux-kernel

> I think that procces which has pid 0 is a special procces because it

pid 1

> removes a *zombie* procceses so it is good to use a *dedicated*
> program for it such as a /sbin/init .
> /usr/sbin/chroot doesn't remove a *zombie* procceses :-(

It exec's the process so the resulting process is still pid 1

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] chroot= as a new kernel parameter
  2008-03-02 16:00 ` Guillaume Chazarain
@ 2008-03-02 23:59   ` Pawel Plociennik
  2008-03-02 18:05     ` Guillaume Chazarain
  2008-03-02 19:05     ` Alan Cox
  2008-03-03 14:11   ` Pavel Machek
  1 sibling, 2 replies; 22+ messages in thread
From: Pawel Plociennik @ 2008-03-02 23:59 UTC (permalink / raw)
  To: Guillaume Chazarain; +Cc: linux-kernel

On Sunday 02 March 2008 11:00, Guillaume Chazarain wrote:
> Wouldn't booting with 'init=/usr/sbin/chroot /path /sbin/init' achieve
> the same effect?
> Haven't tested it, just wondering.
Hi,

I think that procces which has pid 0 is a special procces because it
removes a *zombie* procceses so it is good to use a *dedicated*
program for it such as a /sbin/init .
/usr/sbin/chroot doesn't remove a *zombie* procceses :-(

Regards,

Pawel Plociennik

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] chroot= as a new kernel parameter
  2008-03-02 18:05     ` Guillaume Chazarain
@ 2008-03-03  1:09       ` Pawel Plociennik
  2008-03-03 14:12         ` Pavel Machek
  0 siblings, 1 reply; 22+ messages in thread
From: Pawel Plociennik @ 2008-03-03  1:09 UTC (permalink / raw)
  To: Guillaume Chazarain; +Cc: linux-kernel

On Sunday 02 March 2008 13:05, Guillaume Chazarain wrote:

> You mean pid 1, right? ;-)
Of course that (my brain has been mistaked) :-(
> 
> Sure, but chroot should then exec /sbin/init as per the given kernel
> command line. And then you run a real init.
> 
> I cannot try it as I don't have another distribution installed in a
> subdirectory, but if you could test it we would quickly know if it
> works or not.
> 
You have right.
I have tested that and it  *works* :-)
so I thing that my patch is *unnecessary* now :-(

Thanks You

Regards,
Pawel

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] chroot= as a new kernel parameter
  2008-03-02 16:00 ` Guillaume Chazarain
  2008-03-02 23:59   ` Pawel Plociennik
@ 2008-03-03 14:11   ` Pavel Machek
  1 sibling, 0 replies; 22+ messages in thread
From: Pavel Machek @ 2008-03-03 14:11 UTC (permalink / raw)
  To: Guillaume Chazarain; +Cc: Pawel Plociennik, linux-kernel

Hi!

> On Sat, Mar 1, 2008 at 8:09 PM, Pawel Plociennik <paplociennik@gmail.com> wrote:
> >  In the short this patch has added a new chroot= kernel parameter which can be used
> >  to changing a chroot of an init process before it will has been runed.
> 
> Wouldn't booting with 'init=/usr/sbin/chroot /path /sbin/init' achieve
> the same effect?
> Haven't tested it, just wondering.

This breaks down when there's no distribution installed in /, or when
distro in / is badly broken.
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] chroot= as a new kernel parameter
  2008-03-03  1:09       ` Pawel Plociennik
@ 2008-03-03 14:12         ` Pavel Machek
  2008-03-03 15:19           ` Guillaume Chazarain
  0 siblings, 1 reply; 22+ messages in thread
From: Pavel Machek @ 2008-03-03 14:12 UTC (permalink / raw)
  To: Pawel Plociennik; +Cc: Guillaume Chazarain, linux-kernel

On Sun 2008-03-02 20:09:03, Pawel Plociennik wrote:
> On Sunday 02 March 2008 13:05, Guillaume Chazarain wrote:
> 
> > You mean pid 1, right? ;-)
> Of course that (my brain has been mistaked) :-(
> > 
> > Sure, but chroot should then exec /sbin/init as per the given kernel
> > command line. And then you run a real init.
> > 
> > I cannot try it as I don't have another distribution installed in a
> > subdirectory, but if you could test it we would quickly know if it
> > works or not.
> > 
> You have right.
> I have tested that and it  *works* :-)
> so I thing that my patch is *unnecessary* now :-(

Actually I disagree here. This means that if distro in / breaks, you
will not be able to boot in ditstro in /foo any more :-(.
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] chroot= as a new kernel parameter
  2008-03-03 14:12         ` Pavel Machek
@ 2008-03-03 15:19           ` Guillaume Chazarain
  2008-03-05 13:38             ` Pawel Plociennik
  0 siblings, 1 reply; 22+ messages in thread
From: Guillaume Chazarain @ 2008-03-03 15:19 UTC (permalink / raw)
  To: Pavel Machek; +Cc: Pawel Plociennik, linux-kernel

On Mon, Mar 3, 2008 at 3:12 PM, Pavel Machek <pavel@ucw.cz> wrote:
> On Sun 2008-03-02 20:09:03, Pawel Plociennik wrote:
>  > so I thing that my patch is *unnecessary* now :-(
>
>  Actually I disagree here. This means that if distro in / breaks, you
>  will not be able to boot in ditstro in /foo any more :-(.

For this case, you can boot with something like:

init=/working_distro/lib/ld-linux.so.2 --library-path
/working_distro/lib  /working_distro/usr/sbin/chroot /working_distro/
/sbin/init

And that's actually how you should setup your grub.conf to avoid
depending on the distro in /.

-- 
Guillaume

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] chroot= as a new kernel parameter
  2008-03-05 13:38             ` Pawel Plociennik
@ 2008-03-05  8:10               ` Pavel Machek
  2008-03-05 13:23               ` Guillaume Chazarain
  1 sibling, 0 replies; 22+ messages in thread
From: Pavel Machek @ 2008-03-05  8:10 UTC (permalink / raw)
  To: Pawel Plociennik; +Cc: Guillaume Chazarain, linux-kernel

Hi!

> On Monday 03 March 2008 10:19, Guillaume Chazarain wrote:
> >
> > init=/working_distro/lib/ld-linux.so.2 --library-path
> > /working_distro/lib  /working_distro/usr/sbin/chroot /working_distro/
> > /sbin/init
> > 
> root=<root> init=/working_distro/lib/ld-linux.so.2 --library-path 
> /working_distro/lib working_distro/usr/sbin/chroot /working_distro/ /sbin/init
> 
> I think that it is *interestly* hack but I am not sure that it will be an usable method for all of a distroes which exists on the world.
> At last my patch is as simple as possible and it has *only* a *few lines of the code* and it can be used
> as *independent* method to various *hundred* distroes.
> 
> root=<root> chroot=<chroot>
> 
> and it looks *beautiful* I think :-)
> 
> so I have sent a patch again which it has corrected a *coding style* and a new description in a kernel-parameters.txt file
> (a suggestions for better description are welcome).
> I think that this can be a *last version* of a patch.
> Because I am *newbie* in a kernel hacking I hope that someone will had been written me what now with it ?
> Maybe send this patch *directly* to *kernel guru* such as Andrew
> Morton which manages a -mm series ?

You need to add Signed-off-by... as per
Documentation/Submitting*... and proper changelog would be nice.

And you can add 

Acked-by: Pavel Machek <pavel@suse.cz>

Yes, I think this should go to mm. ... but better Cc Andrew next time.
								Pavel

> 
> diff -urp linux-2.6.24-orig/Documentation/kernel-parameters.txt linux-2.6.24/Documentation/kernel-parameters.txt
> --- linux-2.6.24-orig/Documentation/kernel-parameters.txt	2008-02-25 20:53:26.000000000 -0500
> +++ linux-2.6.24/Documentation/kernel-parameters.txt	2008-03-04 09:51:52.000000000 -0500
> @@ -381,6 +381,8 @@ and is between 256 and 4096 characters. 
>  			Value can be changed at runtime via
>  				/selinux/checkreqprot.
>  	
> +	chroot=		[KNL] change a root for an init process.
> +
>  	clock=		[BUGS=X86-32, HW] gettimeofday clocksource override.
>  			[Deprecated]
>  			Forces specified clocksource (if available) to be used
> diff -urp linux-2.6.24-orig/init/main.c linux-2.6.24/init/main.c
> --- linux-2.6.24-orig/init/main.c	2008-03-01 12:58:37.000000000 -0500
> +++ linux-2.6.24/init/main.c	2008-03-05 08:23:32.000000000 -0500
> @@ -755,8 +755,20 @@ static void __init do_pre_smp_initcalls(
>  		spawn_softlockup_task();
>  }
>  
> +static void *chroot_str;
> +static int __init chroot_setup(char *str)
> +{
> +	chroot_str = str;
> +	return 1;
> +}
> +__setup("chroot=", chroot_setup);
> +
>  static void run_init_process(char *init_filename)
>  {
> +	if (chroot_str)
> +		if (sys_chroot(chroot_str) < 0)
> +			printk(KERN_WARNING "chroot=%s failed\n", chroot_str);
> +
>  	argv_init[0] = init_filename;
>  	kernel_execve(init_filename, argv_init, envp_init);
>  }

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] chroot= as a new kernel parameter
  2008-03-05 13:38             ` Pawel Plociennik
  2008-03-05  8:10               ` Pavel Machek
@ 2008-03-05 13:23               ` Guillaume Chazarain
  2008-03-06  4:51                 ` Pawel Plociennik
                                   ` (2 more replies)
  1 sibling, 3 replies; 22+ messages in thread
From: Guillaume Chazarain @ 2008-03-05 13:23 UTC (permalink / raw)
  To: Pawel Plociennik; +Cc: Pavel Machek, linux-kernel

On Wed, Mar 5, 2008 at 2:38 PM, Pawel Plociennik <paplociennik@gmail.com> wrote:
>  At last my patch is as simple as possible and it has *only* a *few lines of the code* and it can be used
>  as *independent* method to various *hundred* distroes.

Your method requires a certain kernel, mine does not ;-)

>   static void run_init_process(char *init_filename)
>   {
>  +       if (chroot_str)
>  +               if (sys_chroot(chroot_str) < 0)
>  +                       printk(KERN_WARNING "chroot=%s failed\n", chroot_str);
>  +

As I said before, this chroot= option can be used for security reason
instead of testing purpose, and in this case, continuing booting after
a failed chroot sounds like a security issue.

-- 
Guillaume

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] chroot= as a new kernel parameter
  2008-03-03 15:19           ` Guillaume Chazarain
@ 2008-03-05 13:38             ` Pawel Plociennik
  2008-03-05  8:10               ` Pavel Machek
  2008-03-05 13:23               ` Guillaume Chazarain
  0 siblings, 2 replies; 22+ messages in thread
From: Pawel Plociennik @ 2008-03-05 13:38 UTC (permalink / raw)
  To: Guillaume Chazarain; +Cc: Pavel Machek, linux-kernel

On Monday 03 March 2008 10:19, Guillaume Chazarain wrote:
>
> init=/working_distro/lib/ld-linux.so.2 --library-path
> /working_distro/lib  /working_distro/usr/sbin/chroot /working_distro/
> /sbin/init
> 
root=<root> init=/working_distro/lib/ld-linux.so.2 --library-path 
/working_distro/lib working_distro/usr/sbin/chroot /working_distro/ /sbin/init

I think that it is *interestly* hack but I am not sure that it will be an usable method for all of a distroes which exists on the world.
At last my patch is as simple as possible and it has *only* a *few lines of the code* and it can be used
as *independent* method to various *hundred* distroes.

root=<root> chroot=<chroot>

and it looks *beautiful* I think :-)

so I have sent a patch again which it has corrected a *coding style* and a new description in a kernel-parameters.txt file
(a suggestions for better description are welcome).
I think that this can be a *last version* of a patch.
Because I am *newbie* in a kernel hacking I hope that someone will had been written me what now with it ?
Maybe send this patch *directly* to *kernel guru* such as Andrew Morton which manages a -mm series ?


diff -urp linux-2.6.24-orig/Documentation/kernel-parameters.txt linux-2.6.24/Documentation/kernel-parameters.txt
--- linux-2.6.24-orig/Documentation/kernel-parameters.txt	2008-02-25 20:53:26.000000000 -0500
+++ linux-2.6.24/Documentation/kernel-parameters.txt	2008-03-04 09:51:52.000000000 -0500
@@ -381,6 +381,8 @@ and is between 256 and 4096 characters. 
 			Value can be changed at runtime via
 				/selinux/checkreqprot.
 	
+	chroot=		[KNL] change a root for an init process.
+
 	clock=		[BUGS=X86-32, HW] gettimeofday clocksource override.
 			[Deprecated]
 			Forces specified clocksource (if available) to be used
diff -urp linux-2.6.24-orig/init/main.c linux-2.6.24/init/main.c
--- linux-2.6.24-orig/init/main.c	2008-03-01 12:58:37.000000000 -0500
+++ linux-2.6.24/init/main.c	2008-03-05 08:23:32.000000000 -0500
@@ -755,8 +755,20 @@ static void __init do_pre_smp_initcalls(
 		spawn_softlockup_task();
 }
 
+static void *chroot_str;
+static int __init chroot_setup(char *str)
+{
+	chroot_str = str;
+	return 1;
+}
+__setup("chroot=", chroot_setup);
+
 static void run_init_process(char *init_filename)
 {
+	if (chroot_str)
+		if (sys_chroot(chroot_str) < 0)
+			printk(KERN_WARNING "chroot=%s failed\n", chroot_str);
+
 	argv_init[0] = init_filename;
 	kernel_execve(init_filename, argv_init, envp_init);
 }

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] chroot= as a new kernel parameter
  2008-03-05 13:23               ` Guillaume Chazarain
@ 2008-03-06  4:51                 ` Pawel Plociennik
  2008-03-06  4:54                 ` Pawel Plociennik
  2008-03-06  4:59                 ` Pawel Plociennik
  2 siblings, 0 replies; 22+ messages in thread
From: Pawel Plociennik @ 2008-03-06  4:51 UTC (permalink / raw)
  To: Pavel Machek, linux-kernel; +Cc: linux-kernel

Hi Andrew and other *real* hackers,

I have sent a *last* version of a patch which it has added a new kernel parameter chroot=
It were discusioned a *long time* on a lkml so I hope that it will has been applied.

Thanks,
Pawel 

Acked-by: Pavel Machek <pavel@suse.cz>
Signed-off-by: Pawel Plociennik <paplociennik@gmail.com>

---
diff -urp linux-2.6.24-orig/Documentation/kernel-parameters.txt linux-2.6.24/Documentation/kernel-parameters.txt
--- linux-2.6.24-orig/Documentation/kernel-parameters.txt	2008-02-25 20:53:26.000000000 -0500
+++ linux-2.6.24/Documentation/kernel-parameters.txt	2008-03-04 09:51:52.000000000 -0500
@@ -381,6 +381,8 @@ and is between 256 and 4096 characters. 
 			Value can be changed at runtime via
 				/selinux/checkreqprot.
 	
+	chroot=		[KNL] change a root for init process.
+
 	clock=		[BUGS=X86-32, HW] gettimeofday clocksource override.
 			[Deprecated]
 			Forces specified clocksource (if available) to be used
diff -urp linux-2.6.24-orig/init/main.c linux-2.6.24/init/main.c
--- linux-2.6.24-orig/init/main.c	2008-03-01 12:58:37.000000000 -0500
+++ linux-2.6.24/init/main.c	2008-03-05 15:08:20.000000000 -0500
@@ -755,8 +755,20 @@ static void __init do_pre_smp_initcalls(
 		spawn_softlockup_task();
 }
 
+static void *chroot_str;
+static int __init chroot_setup(char *str)
+{
+	chroot_str = str;
+	return 1;
+}
+__setup("chroot=", chroot_setup);
+
 static void run_init_process(char *init_filename)
 {
+	if (chroot_str)
+		if (sys_chroot(chroot_str) < 0)
+			panic("chroot=%s failed\n", chroot_str);
+
 	argv_init[0] = init_filename;
 	kernel_execve(init_filename, argv_init, envp_init);
 }

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] chroot= as a new kernel parameter
  2008-03-05 13:23               ` Guillaume Chazarain
  2008-03-06  4:51                 ` Pawel Plociennik
@ 2008-03-06  4:54                 ` Pawel Plociennik
  2008-03-06  4:59                 ` Pawel Plociennik
  2 siblings, 0 replies; 22+ messages in thread
From: Pawel Plociennik @ 2008-03-06  4:54 UTC (permalink / raw)
  To: Pavel Machek, linux-kernel

Hi Andrew and other *real* hackers,

I have sent a *last* version of a patch which it has added a new kernel parameter chroot=
It were discusioned a *long time* on a lkml so I hope that it will has been applied.

Thanks,
Pawel 

Acked-by: Pavel Machek <pavel@suse.cz>
Signed-off-by: Pawel Plociennik <paplociennik@gmail.com>

---
diff -urp linux-2.6.24-orig/Documentation/kernel-parameters.txt linux-2.6.24/Documentation/kernel-parameters.txt
--- linux-2.6.24-orig/Documentation/kernel-parameters.txt	2008-02-25 20:53:26.000000000 -0500
+++ linux-2.6.24/Documentation/kernel-parameters.txt	2008-03-04 09:51:52.000000000 -0500
@@ -381,6 +381,8 @@ and is between 256 and 4096 characters. 
 			Value can be changed at runtime via
 				/selinux/checkreqprot.
 	
+	chroot=		[KNL] change a root for init process.
+
 	clock=		[BUGS=X86-32, HW] gettimeofday clocksource override.
 			[Deprecated]
 			Forces specified clocksource (if available) to be used
diff -urp linux-2.6.24-orig/init/main.c linux-2.6.24/init/main.c
--- linux-2.6.24-orig/init/main.c	2008-03-01 12:58:37.000000000 -0500
+++ linux-2.6.24/init/main.c	2008-03-05 15:08:20.000000000 -0500
@@ -755,8 +755,20 @@ static void __init do_pre_smp_initcalls(
 		spawn_softlockup_task();
 }
 
+static void *chroot_str;
+static int __init chroot_setup(char *str)
+{
+	chroot_str = str;
+	return 1;
+}
+__setup("chroot=", chroot_setup);
+
 static void run_init_process(char *init_filename)
 {
+	if (chroot_str)
+		if (sys_chroot(chroot_str) < 0)
+			panic("chroot=%s failed\n", chroot_str);
+
 	argv_init[0] = init_filename;
 	kernel_execve(init_filename, argv_init, envp_init);
 }

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] chroot= as a new kernel parameter
  2008-03-05 13:23               ` Guillaume Chazarain
  2008-03-06  4:51                 ` Pawel Plociennik
  2008-03-06  4:54                 ` Pawel Plociennik
@ 2008-03-06  4:59                 ` Pawel Plociennik
  2 siblings, 0 replies; 22+ messages in thread
From: Pawel Plociennik @ 2008-03-06  4:59 UTC (permalink / raw)
  To: Pavel Machek, linux-kernel

Hi Andrew and other *real* hackers,

I have sent a *last* version of a patch which it has added a new kernel parameter chroot=
It were discusioned a *long time* on a lkml so I hope that it will has been applied.

Thanks,
Pawel 

Acked-by: Pavel Machek <pavel@suse.cz>
Signed-off-by: Pawel Plociennik <paplociennik@gmail.com>

---
diff -urp linux-2.6.24-orig/Documentation/kernel-parameters.txt linux-2.6.24/Documentation/kernel-parameters.txt
--- linux-2.6.24-orig/Documentation/kernel-parameters.txt	2008-02-25 20:53:26.000000000 -0500
+++ linux-2.6.24/Documentation/kernel-parameters.txt	2008-03-04 09:51:52.000000000 -0500
@@ -381,6 +381,8 @@ and is between 256 and 4096 characters. 
 			Value can be changed at runtime via
 				/selinux/checkreqprot.
 	
+	chroot=		[KNL] change a root for init process.
+
 	clock=		[BUGS=X86-32, HW] gettimeofday clocksource override.
 			[Deprecated]
 			Forces specified clocksource (if available) to be used
diff -urp linux-2.6.24-orig/init/main.c linux-2.6.24/init/main.c
--- linux-2.6.24-orig/init/main.c	2008-03-01 12:58:37.000000000 -0500
+++ linux-2.6.24/init/main.c	2008-03-05 15:08:20.000000000 -0500
@@ -755,8 +755,20 @@ static void __init do_pre_smp_initcalls(
 		spawn_softlockup_task();
 }
 
+static void *chroot_str;
+static int __init chroot_setup(char *str)
+{
+	chroot_str = str;
+	return 1;
+}
+__setup("chroot=", chroot_setup);
+
 static void run_init_process(char *init_filename)
 {
+	if (chroot_str)
+		if (sys_chroot(chroot_str) < 0)
+			panic("chroot=%s failed\n", chroot_str);
+
 	argv_init[0] = init_filename;
 	kernel_execve(init_filename, argv_init, envp_init);
 }

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] chroot= as a new kernel parameter
       [not found]       ` <a41Rb-7mN-9@gated-at.bofh.it>
@ 2008-03-06  0:16         ` Bodo Eggert
  0 siblings, 0 replies; 22+ messages in thread
From: Bodo Eggert @ 2008-03-06  0:16 UTC (permalink / raw)
  To: Guillaume Chazarain, Pawel Plociennik, Pavel Machek, linux-kernel

Guillaume Chazarain <guichaz@gmail.com> wrote:
> On Wed, Mar 5, 2008 at 2:38 PM, Pawel Plociennik <paplociennik@gmail.com>

>>  At last my patch is as simple as possible and it has *only* a *few lines of
>>  the code* and it can be used as *independent* method to various *hundred*
>>  distroes.
> 
> Your method requires a certain kernel, mine does not ;-)

Your method requires to type the whole bible on the command line.

>>   static void run_init_process(char *init_filename)
>>   {
>>  +       if (chroot_str)
>>  +               if (sys_chroot(chroot_str) < 0)
>>  +                       printk(KERN_WARNING "chroot=%s failed\n",
>>  chroot_str); +
> 
> As I said before, this chroot= option can be used for security reason
> instead of testing purpose, and in this case, continuing booting after
> a failed chroot sounds like a security issue.

Even if not, continuing on unknown/bad options is a BAD idea. If I made a
typo in the path, the wrong system would be started, leaving me to choose
between waiting (felt) five minutes until I can shut it down cleanly or
to hard reboot and fsck.


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] chroot= as a new kernel parameter
       [not found]   ` <a3k9B-4Cf-43@gated-at.bofh.it>
@ 2008-03-03 16:08     ` Bodo Eggert
  0 siblings, 0 replies; 22+ messages in thread
From: Bodo Eggert @ 2008-03-03 16:08 UTC (permalink / raw)
  To: Pavel Machek, Guillaume Chazarain, Pawel Plociennik, linux-kernel

Pavel Machek <pavel@ucw.cz> wrote:
>> On Sat, Mar 1, 2008 at 8:09 PM, Pawel Plociennik <paplociennik@gmail.com>

>> >  In the short this patch has added a new chroot= kernel parameter which can
>> >  be used to changing a chroot of an init process before it will has been
>> >  runed.
>> 
>> Wouldn't booting with 'init=/usr/sbin/chroot /path /sbin/init' achieve
>> the same effect?
>> Haven't tested it, just wondering.
> 
> This breaks down when there's no distribution installed in /, or when
> distro in / is badly broken.

Yes.

Real life example: I set up a system in qemu and moved it to ~/temp/foo
in order to test it before overwriting the old system. I had to boot into
/bin/sh, mount the home disc and chroot into that directory.

OTOH, I'm not sure if the kernel would have found my home if it were on LVM.



^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2008-03-06  0:16 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-01 19:09 [PATCH] chroot= as a new kernel parameter Pawel Plociennik
2008-03-01 18:47 ` Alexandre Oliva
2008-03-01 19:44 ` Stefan Hellermann
2008-03-02 11:17   ` Kasper Sandberg
2008-03-02 15:35 ` Pavel Machek
2008-03-02 15:53 ` Filippo Zangheri
2008-03-02 16:00 ` Guillaume Chazarain
2008-03-02 23:59   ` Pawel Plociennik
2008-03-02 18:05     ` Guillaume Chazarain
2008-03-03  1:09       ` Pawel Plociennik
2008-03-03 14:12         ` Pavel Machek
2008-03-03 15:19           ` Guillaume Chazarain
2008-03-05 13:38             ` Pawel Plociennik
2008-03-05  8:10               ` Pavel Machek
2008-03-05 13:23               ` Guillaume Chazarain
2008-03-06  4:51                 ` Pawel Plociennik
2008-03-06  4:54                 ` Pawel Plociennik
2008-03-06  4:59                 ` Pawel Plociennik
2008-03-02 19:05     ` Alan Cox
2008-03-03 14:11   ` Pavel Machek
     [not found] <a2zNf-7rl-7@gated-at.bofh.it>
     [not found] ` <a2YVo-4N6-27@gated-at.bofh.it>
     [not found]   ` <a3k9B-4Cf-43@gated-at.bofh.it>
2008-03-03 16:08     ` Bodo Eggert
     [not found] ` <a3k9y-4Cf-35@gated-at.bofh.it>
     [not found]   ` <a3kMn-5Jb-25@gated-at.bofh.it>
     [not found]     ` <a3Wop-6Xn-15@gated-at.bofh.it>
     [not found]       ` <a41Rb-7mN-9@gated-at.bofh.it>
2008-03-06  0:16         ` Bodo Eggert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).