Q: chroot(9) returning EFAULT

Paul Herman pherman at frenchfries.net
Mon Mar 15 17:37:19 PST 2004


Hey guys,

I'm working on a syscall that has a chroot in it, and for the life
of me, I can't figure out why chroot(9) keeps returning EFAULT.  I
took the lead from jail(2) in kern_jail.c and I basically have
something like this:

int
my_syscall(struct my_syscall_args *uap)
{
       struct chroot_args ca;

       MALLOC(ca.path, const char *, MAXPATHLEN , M_TEMP, M_WAITOK);
       error = copystr(someotherpath, ca.path, MAXPATHLEN, 0);
       if (error)
               return (error);
       error = chroot(&ca);
       if (error)
                return (error);
       FREE(ca.path, M_TEMP);
}

Where someotherpath was allocated by another thread but still
exists in kernel space.  However, even if ca.path points to a
char[MAXPATHLEN] on the stack it still returns EFAULT.  Help!  I'm
definately missing something here and I don't see it.  Any ideas?

-Paul.





More information about the Kernel mailing list