Hi,

the same as to unveil(2) also counts for realpath(3).
https://marc.info/?l=openbsd-bugs&m=156469573812165&w=2
Similar diff attached.

tests are here:
https://github.com/moritzbuhl/realpath-unmount-regress

thanks,
mbuhl

Index: sys/kern/vfs_syscalls.c
===================================================================
RCS file: /cvs/src/sys/kern/vfs_syscalls.c,v
retrieving revision 1.327
diff -u -p -r1.327 vfs_syscalls.c
--- sys/kern/vfs_syscalls.c     25 Jul 2019 01:43:21 -0000      1.327
+++ sys/kern/vfs_syscalls.c     2 Aug 2019 12:45:12 -0000
@@ -948,10 +948,10 @@ sys___realpath(struct proc *p, void *v, 
                VOP_UNLOCK(nd.ni_vp);
                vrele(nd.ni_vp);
        }
-       if (nd.ni_dvp && nd.ni_dvp != nd.ni_vp){
+       if (nd.ni_dvp && nd.ni_dvp != nd.ni_vp)
                VOP_UNLOCK(nd.ni_dvp);
+       if (nd.ni_dvp)
                vrele(nd.ni_dvp);
-       }
 
        error = copyoutstr(nd.ni_cnd.cn_rpbuf, SCARG(uap, resolved),
            MAXPATHLEN, NULL);

Reply via email to