Subject: Re: openat(2) and friends
To: David Brownlee <abs@NetBSD.org>
From: Rhialto <rhialto@azenomei.knuffel.net>
List: tech-kern
Date: 03/08/2005 15:31:22
On Tue 08 Mar 2005 at 15:16:23 +0100, Rhialto wrote:
> I seem to recall that fchdir() had explicit checks against this sort of
> thing, but I'm not sure where (of couse I should RTFS). Depending on
> how this is checked, the same check may apply to openat(2) already.

This is checked in sys_fchdir() in kern/vfs_syscalls.c:

        /*
         * Disallow changing to a directory not under the process's
         * current root directory (if there is one).
         */
        if (cwdi->cwdi_rdir && !vn_isunder(vp, NULL, p)) {
                vrele(vp);
                error = EPERM;  /* operation not permitted */
                goto out;
        }

Similar checks are also in sys_fchroot() and sys_chroot(), and in
kern/uipc_usrreq.c:unp_externalize().

-Olaf.
-- 
___ Olaf 'Rhialto' Seibert                            --  rhialto/at/falu.nl
\X/ Hi! I'm a signature virus! Copy me to your .signature to help me spread!