Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Sep 2014 00:56:47 +0000 (UTC)
From:      Garrett Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r271655 - in head: lib/libc/sys sys/kern
Message-ID:  <201409160056.s8G0ulaf017811@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Tue Sep 16 00:56:47 2014
New Revision: 271655
URL: http://svnweb.freebsd.org/changeset/base/271655

Log:
  Validate the mode argument in access, eaccess, and faccessat for optional
  POSIX compliance and to improve compatibility with Linux and NetBSD
  
  The issue was identified with lib/libc/sys/t_access:access_inval from
  NetBSD
  
  Update the manpage accordingly
  
  PR: 181155
  Reviewed by: jilles (code), jmmv (code), wblock (manpage), wollman (code)
  MFC after: 4 weeks
  Phabric: D678 (code), D786 (manpage)
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/lib/libc/sys/access.2
  head/sys/kern/vfs_syscalls.c

Modified: head/lib/libc/sys/access.2
==============================================================================
--- head/lib/libc/sys/access.2	Tue Sep 16 00:11:01 2014	(r271654)
+++ head/lib/libc/sys/access.2	Tue Sep 16 00:56:47 2014	(r271655)
@@ -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

Modified: head/sys/kern/vfs_syscalls.c
==============================================================================
--- head/sys/kern/vfs_syscalls.c	Tue Sep 16 00:11:01 2014	(r271654)
+++ head/sys/kern/vfs_syscalls.c	Tue Sep 16 00:56:47 2014	(r271655)
@@ -2055,6 +2055,9 @@ kern_accessat(struct thread *td, int fd,
 	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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201409160056.s8G0ulaf017811>