Q: chroot(9) returning EFAULT
Paul Herman
pherman at frenchfries.net
Mon Mar 15 18:15:31 PST 2004
On Mon, 15 Mar 2004, Matthew Dillon wrote:
> chroot() is expecting arguments in userspace, you are handing it
> kernelspace addresses.
That's what I figured, but then how does jail(2) do it? It's
ca.path points to the stack? That's what got me.
> What you need to do is to separate chroot() into chroot() (which
> takes userspace arguments) and kern_chroot() (which takes kernelspace
> arguments). Then you can call kern_chroot() directly.
That's what I'll end up doing, in my case that would be the best
solution anyway. I'm porting the jail_attach(2)/jls(8) stuff from
5.x and jail_attach(2) chroot()s into a struct vnode rather than a
path (in case someone mv()s the jail root), so it'd be best for me
to just break up chroot() into chroot(char *path) and
vchroot(struct vnode *) and have one just call the other. While
I'm making changes, I can write up a kern_chroot(), no problem.
I still don't quite get how the jail(2) syscall gets away with it.
It does:
{
struct prison j;
struct chroot_args ca;
[...]
ca.path = j.pr_path; /* !!!! */
error = chroot(&ca);
[...]
}
hmmm...
-Paul.
More information about the Kernel
mailing list