From eba8ab0e3e2a951b76ffaea7c1e2f93471c8a4e1 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Tue, 11 Dec 2018 02:48:49 +0000 Subject: [PATCH] Remove special case handling for getfhat(fd, NULL, handle). There is no reason for it to behave differently from openat(fd, NULL). Also the handling did not worked because the substituted path was from the system address space, causing EFAULT. Submitted by: Jack Halford MFC after: 1 week Differential revision: https://reviews.freebsd.org/D18501 --- lib/libc/sys/getfh.2 | 6 +++--- sys/kern/vfs_syscalls.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/libc/sys/getfh.2 b/lib/libc/sys/getfh.2 index 1877a37a02b..0f17927ba7d 100644 --- a/lib/libc/sys/getfh.2 +++ b/lib/libc/sys/getfh.2 @@ -29,7 +29,7 @@ .\" @(#)getfh.2 8.1 (Berkeley) 6/9/93 .\" $FreeBSD$ .\" -.Dd December 7, 2018 +.Dd December 11, 2018 .Dt GETFH 2 .Os .Sh NAME @@ -76,12 +76,12 @@ and .Fn lgetfh except when the .Fa path -specifies a relative or NULL path, or the +specifies a relative path, or the .Dv AT_BENEATH flag is provided. For .Fn getfhat -and relative or NULL +and relative .Fa path , the status is retrieved from a file relative to the directory associated with the file descriptor diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index fdf5aca0be2..17e0e597fe9 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -4196,8 +4196,8 @@ sys_getfhat(struct thread *td, struct getfhat_args *uap) if ((uap->flags & ~(AT_SYMLINK_NOFOLLOW | AT_BENEATH)) != 0) return (EINVAL); - return (kern_getfhat(td, uap->flags, uap->fd, uap->path ? uap->path : ".", - UIO_USERSPACE, uap->fhp)); + return (kern_getfhat(td, uap->flags, uap->fd, uap->path, UIO_USERSPACE, + uap->fhp)); } static int