From 90b57bdecc2f4dcfc4b29b2f73cc88d5fa0bceed Mon Sep 17 00:00:00 2001 From: Bob Beck Date: Tue, 26 Nov 2019 00:26:37 +0000 Subject: Don't use LOCKPARENT on namei calls for realpath(). We don't require this anymore since we now behave like posix. Fixes a problem where a symlink to / would return ENOTDIR because the parent could not be locked - noticed by Raimo Niskanen ok guenther@ deraadt@ --- sys/kern/vfs_syscalls.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'sys') diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 23a96822126..ce04de981bd 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_syscalls.c,v 1.336 2019/10/06 16:24:14 beck Exp $ */ +/* $OpenBSD: vfs_syscalls.c,v 1.337 2019/11/26 00:26:36 beck Exp $ */ /* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */ /* @@ -928,13 +928,8 @@ sys___realpath(struct proc *p, void *v, register_t *retval) if (*c != '/') break; } - if (*c == '\0') - /* root directory */ - NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | SAVENAME | REALPATH, - UIO_SYSSPACE, pathname, p); - else - NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | LOCKPARENT | SAVENAME | - REALPATH, UIO_SYSSPACE, pathname, p); + NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | SAVENAME | REALPATH, + UIO_SYSSPACE, pathname, p); nd.ni_cnd.cn_rpbuf = rpbuf; nd.ni_cnd.cn_rpi = strlen(rpbuf); @@ -949,11 +944,6 @@ sys___realpath(struct proc *p, void *v, register_t *retval) VOP_UNLOCK(nd.ni_vp); vrele(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); -- cgit v1.2.3