DragonFly BSD
DragonFly kernel List (threaded) for 2004-03
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: Q: chroot(9) returning EFAULT

From: Paul Herman <pherman@xxxxxxxxxxxxxxx>
Date: Mon, 15 Mar 2004 18:13:27 -0800 (PST)

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);



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]