Bug 181155 - [libc] [patch] *access*(2) does not handle invalid amodes properly
Summary: [libc] [patch] *access*(2) does not handle invalid amodes properly
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-09 03:00 UTC by Enji Cooper
Modified: 2014-10-23 00:57 UTC (History)
1 user (show)

See Also:


Attachments
file.txt (758 bytes, patch)
2013-08-09 03:00 UTC, Enji Cooper
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Enji Cooper freebsd_committer 2013-08-09 03:00:00 UTC
Invalid access modes aren't properly handled in FreeBSD, so feeding in a valid like -1 won't result in a failed call.

Fix: Patch attached with submission follows:
How-To-Repeat: access("/", -1);
Comment 1 Enji Cooper freebsd_committer 2014-04-18 18:18:56 UTC
    Just as a note: I need to add something to the manpage for all
affected system calls for this; mknodat and a few other system calls
will need manpage updates .. need to evaluate all of the system calls
to get a full list of everything affected.
Thanks!
-Garrett
Comment 2 Enji Cooper freebsd_committer 2014-04-18 18:23:08 UTC
On Fri, Apr 18, 2014 at 10:18 AM, Garrett Cooper <yaneurabeya@gmail.com> wrote:
>     Just as a note: I need to add something to the manpage for all
> affected system calls for this; mknodat and a few other system calls
> will need manpage updates .. need to evaluate all of the system calls
> to get a full list of everything affected.

    And one more thing: fixing this will make FreeBSD more POSIX
compliant with this system call (
http://pubs.opengroup.org/onlinepubs/009695299/functions/access.html
), will match the behavior on Linux and NetBSD at least:

The access() function may fail if:

[EINVAL]The value of the amode argument is invalid.

Thanks!
-Garrett
Comment 3 commit-hook freebsd_committer 2014-09-15 18:42:35 UTC
A commit references this bug:

Author: ngie
Date: Mon Sep 15 18:41:51 UTC 2014
New revision: 271639
URL: http://svnweb.freebsd.org/changeset/base/271639

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

Changes:
  user/ngie/add-pjdfstest/lib/libc/sys/access.2
  user/ngie/add-pjdfstest/sys/kern/vfs_syscalls.c
Comment 4 commit-hook freebsd_committer 2014-09-15 18:44:36 UTC
A commit references this bug:

Author: ngie
Date: Mon Sep 15 18:43:57 UTC 2014
New revision: 271640
URL: http://svnweb.freebsd.org/changeset/base/271640

Log:
  Bump .Dd for the content change done in r271639

  PR: 181155
  Sponsored by: EMC / Isilon Storage Division

Changes:
  user/ngie/add-pjdfstest/lib/libc/sys/access.2
Comment 5 commit-hook freebsd_committer 2014-09-16 00:56:52 UTC
A commit references this bug:

Author: ngie
Date: Tue Sep 16 00:56:48 UTC 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

Changes:
  head/lib/libc/sys/access.2
  head/sys/kern/vfs_syscalls.c
Comment 6 commit-hook freebsd_committer 2014-09-16 00:59:54 UTC
A commit references this bug:

Author: ngie
Date: Tue Sep 16 00:59:08 UTC 2014
New revision: 271656
URL: http://svnweb.freebsd.org/changeset/base/271656

Log:
  Bump .Dd for the content change done to access(2) in r271655

  PR: 181155
  Sponsored by: EMC / Isilon Storage Division

Changes:
  head/lib/libc/sys/access.2
Comment 7 commit-hook freebsd_committer 2014-09-16 01:00:55 UTC
A commit references this bug:

Author: ngie
Date: Tue Sep 16 00:59:57 UTC 2014
New revision: 271657
URL: http://svnweb.freebsd.org/changeset/base/271657

Log:
  Bump __FreeBSD_version for the change made in r271655

  PR: 181155
  Sponsored by: EMC / Isilon Storage Division

Changes:
  head/sys/sys/param.h
Comment 8 Jilles Tjoelker freebsd_committer 2014-09-28 21:37:40 UTC
It is likely inappropriate to MFC this, since it might break applications without much benefit for existing applications.
Comment 9 Enji Cooper freebsd_committer 2014-10-23 00:57:21 UTC
jilles requested for this commit to not be MFCed, and I agree. Marking the issue resolved.