<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>

<?rfc toc="yes"?>
<?rfc tocompact="yes"?>
<?rfc tocdepth="3"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes" ?>
<?rfc compact="yes" ?>
<?rfc subcompact="no" ?>

<rfc
    category="std"
    ipr="trust200902"
    number="8275" submissionType="IETF" consensus="yes">

<front>
    <title abbrev="NFSv4 Umask">
      Allowing Inheritable NFSv4 Access Control Entries to Override the Umask
    </title>

    <author fullname="J. Bruce Fields"
            initials="J. B."
            surname="Fields">
      <organization abbrev="Red Hat">Red Hat, Inc.</organization>
      <address>
        <email>bfields@redhat.com</email>
      </address>
    </author>
    <author fullname="Andreas Gruenbacher"
            initials="A."
	    surname="Gruenbacher">
      <organization abbrev="Red Hat">Red Hat, Inc.</organization>
      <address>
        <email>agruenba@redhat.com</email>
      </address>
    </author>

    <date year="2017" month="November"/>

    <area>Transport</area>
    <workgroup>NFSv4</workgroup>

    <keyword>NFSv4</keyword>

    <abstract>
      <t>


	In many environments, inheritable NFSv4 Access Control Entries
	(ACEs) can be rendered ineffective by the application of the
	per-process file mode
   creation mask (umask).  This can be addressed by transmitting the
	umask and create mode as separate pieces of data, allowing the
	server to make more intelligent decisions about the permissions
	to set on new files.  This document proposes a protocol
	extension to accomplish that.

      </t>
    </abstract>
</front>

<middle>

<section anchor="sec:intro" title="Problem Statement">
  <t>
    On Unix-like systems, each process is associated with a file mode
    creation mask (umask). The umask specifies which permissions must be
    turned off when creating new file system objects.
  </t>

  <t>
    When applying the mode, Section 6.4.1.1 of <xref target='RFC7530'/>
    recommends that servers SHOULD restrict permissions granted to any
    user or group named in the Access Control List (ACL) to be no more
    than the permissions granted by the MODE4_RGRP, MODE4_WGRP, and
    MODE4_XGRP bits.  Servers aiming to provide clients with Unix-like
    chmod behavior may also be motivated by the same requirements in
    <xref target='SUSv4'/>.  (See the discussion of additional and
    alternate access control mechanisms in "File
    Permissions", Section 4.4 of <xref target='SUSv4'/>.)
  </t>

  <t>
    On many existing installations, all ordinary users use
    the same effective group ID by default.  To prevent granting all users full
    access to each other's files, such installations usually default to
    a umask with very restrictive permissions.  As a result, inherited
    ACL entries (inheritable ACEs) describing the permissions to be
    granted to named users and groups are often ignored.  This makes
    inheritable ACEs useless in some common cases.
  </t>

  <t>
    Linux solves this problem on local file systems by ignoring the umask
    whenever a newly created file inherits ACEs from its parent; see <xref target='LinuxACL'/>.
  </t>

  <t>
    The same solution should work for NFS.  However, the NFSv4 protocol
    does not currently give the client a way to transmit the umask of
    the process opening a file.  And clients have no way of atomically
    checking for inheritable permissions and applying the umask only
    when necessary.  As a result, the server receives an OPEN with a
    mode attribute that already has the umask applied.
  </t>

  <t>
    This document solves the problem by defining a new attribute that
    allows the client to transmit umask and the mode specified at file
    creation separately, allowing the client to ignore the umask in the
    presence of inheritable ACEs.  At least in the Linux case, this
    allows NFSv4 to provide the same semantics available using local
    access.
  </t>

</section>

<section anchor="ssc:solution:conv" title="Conventions Used in This Document">
  <t>
 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL
      NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED",
      "MAY", and "OPTIONAL" in this document are to be interpreted as
      described in BCP 14 <xref target="RFC2119" /> <xref target="RFC8174" /> when, and only when, they appear in all capitals, as shown here.
  </t>
</section>

<section anchor="sec:extension" title="Protocol Extension Considerations">

  <t>
    This document presents an extension to minor version 2 of the NFSv4
    protocol as described in <xref target='RFC8178'/>.  It
    describes a new OPTIONAL feature.  NFSv4.2 servers and clients
    implemented without knowledge of this extension will continue to
    interoperate with clients and servers that are aware of the
    extension (whether or not they support it).
  </t>

  <t>
    Note that <xref target='RFC7862'/> does not define NFSv4.2 as
    non-extensible, so <xref
    target='RFC8178'/> treats it as an extensible minor version. This Standards Track RFC
    extends NFSv4.2 but does not update <xref target='RFC7862'/>
    or <xref target='RFC7863'/>.
  </t>

</section>

<section anchor="xdr" title="XDR Extraction">
  <t>
    The additional lines of External Data Representation (XDR)
    <xref target='RFC4506' /> description
    embedded in this document can be extracted
    by feeding this document
    into the following shell script:
  </t>

  <t>
    &lt;CODE BEGINS&gt;
  </t>

  <figure>
    <artwork>
#!/bin/sh
grep '^ *///' $* | sed 's?^ */// ??' | sed 's?^ *///$??'
    </artwork>
  </figure>

  <t>
    &lt;CODE ENDS&gt;
  </t>

  <t>
    That is, if the above script is stored in a file called "extract.sh", and
    this document is in a file called "umask.txt", then the reader can do:
  </t>

  <figure>
    <artwork>
sh extract.sh &lt; umask.txt &gt; umask.x
    </artwork>
  </figure>

  <t>
    The effect of the script is to remove leading white space from each
    line, plus a sentinel sequence of "///".
  </t>

  <t>
    Once that extraction is done, these added lines need to be
    inserted into an appropriate base XDR of the generated
    XDR from <xref target="RFC7863"/> together with XDR from
    any additional extensions to be recognized by the implementation.
    This will result in a ready-to-compile XDR file.
  </t>

</section>

<section anchor="sec:solution" title="The mode_umask Attribute">

  <t>
    &lt;CODE BEGINS&gt;
  </t>
  <figure>
    <artwork>
///   struct mode_umask4 {
///     mode4  mu_mode;
///     mode4  mu_umask;
///   };
///
///   %/*
///   % * New For UMASK
///   % */
///   const FATTR4_MODE_UMASK         = 81;
    </artwork>
  </figure>
  <t>
    &lt;CODE ENDS&gt;
  </t>

  <texttable anchor="tbl:rec_attr">
    <ttcol align="left">Name</ttcol>
    <ttcol align="left">Id</ttcol>
    <ttcol align="left">Data Type</ttcol>
    <ttcol align="left">Acc</ttcol>
    <ttcol align="left">Defined in</ttcol>
    <c>mode_umask</c>    <c>81</c> <c>mode_umask4</c>           <c>  W</c> <c><xref target="sec:solution" /></c>
  </texttable>

  <t>
    The NFSv4.2 mode_umask attribute is based on the umask and on the
    mode bits specified at open time, which together determine the mode
    of a newly created UNIX file.  Only the nine low-order mode4 bits of
    mu_umask are defined.  A server MUST return NFS4ERR_INVAL if bits
    other than those nine are set.
  </t>

  <t>
    The mode_umask attribute is only meaningful for operations that
    create objects (CREATE and OPEN); in other operations that take
    fattr4 arguments, the server MUST reject it with NFS4ERR_INVAL.
  </t>

  <t>
    The server MUST return NFS4ERR_INVAL if the client attempts to set
    both mode and mode_umask in the same operation.
  </t>

  <t>
    When the server supports the mode_umask attribute, a client creating
    a file should use mode_umask in place of mode, with mu_mode set to
    the unmodified mode provided by the user and mu_umask set to the
    umask of the requesting process.
  </t>

  <t>
    The server then uses mode_umask as follows:
    <list style="symbols">
      <t>On a server that supports ACL attributes, if an object inherits
      any ACEs from its parent directory, mu_mode SHOULD be used
      and mu_umask ignored.</t>

      <t>Otherwise, mu_umask MUST be used to limit the mode: all bits
      in the mode that are set in the unmask MUST be turned off; the
      mode assigned to the new object becomes (mu_mode &amp; ~mu_umask)
      instead.</t>
    </list>
  </t>

</section>


<section anchor="sec:security" title="Security Considerations">
  <t>
    The mode_umask attribute shifts to the server the decision about
    when to apply the umask.  Because the server MUST apply the umask if
    there are no inheritable permissions, the traditional semantics are
    preserved in the absence of a permission inheritance mechanism.
    The only relaxation of permissions comes in the case in which servers follow
    the recommendation that they ignore the umask in the presence of
    inheritable permissions.
  </t>

  <t>
    The practice of ignoring the umask when there are inheritable
    permissions in the form of a "POSIX" default ACL is of long standing
    and has not given rise to security issues. The "POSIX" default ACL
    mechanism and the mechanism for permission inheritance in NFSv4 are
    equivalent from a security perspective.
  </t>
</section>

<section anchor="sec:IANA" title="IANA Considerations">
  <t>This document does not require any IANA actions.</t>
</section>

</middle>

<back>

  <references title="Normative References">

<?rfc include="reference.RFC.2119" ?>
<?rfc include="reference.RFC.4506" ?>
<?rfc include="reference.RFC.7530" ?>
<?rfc include="reference.RFC.7862" ?>
<?rfc include="reference.RFC.7863" ?>
<?rfc include="reference.RFC.8174" ?>

<!--Note: draft-ietf-nfsv4-versioning-08 is now RFC 8178-->
<?rfc include="reference.RFC.8178" ?>

</references>

<references title="Informative References">

  <reference anchor="LinuxACL" target='http://kernel.org/doc/man-pages/online/pages/man5/acl.5.html'>
    <front>
      <title>ACL(5) - Access Control Lists</title>
      <author initials='A' surname='Gruenbacher' fullname='Andreas Gruenbacher'></author>
      <date month="March" year="2002"/>
    </front>
    <seriesInfo name='Linux man pages online,' value='ACL(5)'/>
  </reference>

  <reference anchor='SUSv4'>
    <front>
      <title>Single UNIX Specification, Version 4</title>
      <author>
        <organization>The Open Group</organization>
      </author>
      <date year="2013"/>
    </front>
  </reference>

</references>

<section title="Acknowledgments" numbered='no'>
<t>
Thanks to Trond Myklebust and Dave Noveck for their review and the suggestion to define
this as a (mode, umask) pair rather than just umask.  Thanks to Warren Kumari, Adam Roach, Spencer Dawkins, Mike Kupfer,
and Thomas Haynes for their review and to Thomas Haynes for help with XDR.
</t>
</section>


</back>


</rfc>
