tech-kern archive

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

Re: rename(), wapbl and deadlock



On Thu, Dec 17, 2009 at 11:29:53PM +0100, Manuel Bouyer wrote:
> I found a problem with this patch: rename fail with EPERM if the
> file is not writable; even though the directory is. This is a change
> in semantic:
> horn.soc.lip6.fr:/mnt/src/tooldir.NetBSD-5.0_STABLE-i386/bin>touch truc
> horn.soc.lip6.fr:/mnt/src/tooldir.NetBSD-5.0_STABLE-i386/bin>chmod 555 truc
> horn.soc.lip6.fr:/mnt/src/tooldir.NetBSD-5.0_STABLE-i386/bin>mv truc machin
> mv: rename truc to machin: Permission denied

I found it: this code
        /* Check permissions. */
        error = VOP_ACCESS(fromchild_vnode, VWRITE, to_name->cn_cred);
        if (error) {
                goto fail_withlocks;
        }

needs to be changed to:
        /* Check permissions. */
        error = VOP_ACCESS(fromchild_vnode, VWRITE, to_name->cn_cred);
        if (error && newparent && doingdirectory) {
                goto fail_withlocks;
        }

because we want to check the permission on the source only if
we gave to rewrite the source to change ..

-- 
Manuel Bouyer <bouyer%antioche.eu.org@localhost>
     NetBSD: 26 ans d'experience feront toujours la difference
--


Home | Main Index | Thread Index | Old Index