diff --git a/lib/libc/sys/access.2 b/lib/libc/sys/access.2 index 65b8fb6bfbb..edc6194756c 100644 --- a/lib/libc/sys/access.2 +++ b/lib/libc/sys/access.2 @@ -133,8 +133,16 @@ and .Sh RETURN VALUES .Rv -std .Sh ERRORS -Access to the file is denied if: +.Fn access , +.Fn eaccess , +or +.Fn faccessat +will fail if: .Bl -tag -width Er +.It Bq Er EINVAL +The value of the +.Fa mode +argument is invalid. .It Bq Er ENOTDIR A component of the path prefix is not a directory. .It Bq Er ENAMETOOLONG diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 1406e0f8bc5..b3b7ed5defd 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -2055,6 +2055,9 @@ kern_accessat(struct thread *td, int fd, char *path, enum uio_seg pathseg, cap_rights_t rights; int error; + if (amode != F_OK && (amode & ~(R_OK | W_OK | X_OK)) != 0) + return (EINVAL); + /* * Create and modify a temporary credential instead of one that * is potentially shared.