lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Tue, 4 Mar 2008 22:23:28 -0800
From:	"Leibowitz, Michael" <michael.leibowitz@...el.com>
To:	<serge@...lyn.com>
Cc:	<linux-kernel@...r.kernel.org>
Subject: Re: CLONE_NEWNS and bind mounts to make "chroot" jail

I'm not 100% sure if this is what you meant, but I did get the following
to work: 

chdir("/jail"); 
unshare(CLONE_NEWNS);
mount("/jail", "/jail", NULL, MS_BIND, NULL);
pivot_root("/jail", "/jail/old_root");
chdir("/");
mount("/old_root/bin", "bin", NULL, MS_BIND, NULL);
mount("/old_root/usr", "usr", NULL, MS_BIND, NULL);
mount("/old_root/lib", "lib", NULL, MS_BIND, NULL);
umount2("/old_root", MNT_DETACH);
exec("/busybox");

Thanks for the help.  

On Tue, 2008-03-04 at 15:45 -0600, serge@...lyn.com wrote:
> Quoting Leibowitz, Michael (michael.leibowitz@...el.com):
> Yes, you
> 	cd /jail
> 	mount --bind /jail /jail
> 	pivot_root . old_root
> 
> but . is now mounted over.
> >   char *newargv[]= { "sh", NULL };
> > 
> >   chdir("/jail");
> >   unshare(CLONE_NEWNS));
> >   mount("/jail", "/jail", NULL, MS_BIND, NULL));
> >   mount("/bin", "bin", NULL, MS_BIND, NULL));
> >   mount("/usr", "usr", NULL, MS_BIND, NULL));
> >   mount("/lib", "lib", NULL, MS_BIND, NULL));
> >   if (pivot_root(".", "old_root")) perror("pivot_root . old_root");
> >   exec("./bash-static"); /* copied to /jail prior to running */

-- 
Michael Leibowitz <michael.leibowitz@...el.com>

Download attachment "signature.asc" of type "application/pgp-signature" (190 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ