31 Mar, 2016

1 commit

  • When get_acl() is called for an inode whose ACL is not cached yet, the
    get_acl inode operation is called to fetch the ACL from the filesystem.
    The inode operation is responsible for updating the cached acl with
    set_cached_acl(). This is done without locking at the VFS level, so
    another task can call set_cached_acl() or forget_cached_acl() before the
    get_acl inode operation gets to calling set_cached_acl(), and then
    get_acl's call to set_cached_acl() results in caching an outdate ACL.

    Prevent this from happening by setting the cached ACL pointer to a
    task-specific sentinel value before calling the get_acl inode operation.
    Move the responsibility for updating the cached ACL from the get_acl
    inode operations to get_acl(). There, only set the cached ACL if the
    sentinel value hasn't changed.

    The sentinel values are chosen to have odd values. Likewise, the value
    of ACL_NOT_CACHED is odd. In contrast, ACL object pointers always have
    an even value (ACLs are aligned in memory). This allows to distinguish
    uncached ACLs values from ACL objects.

    In addition, switch from guarding inode->i_acl and inode->i_default_acl
    upates by the inode->i_lock spinlock to using xchg() and cmpxchg().

    Filesystems that do not want ACLs returned from their get_acl inode
    operations to be cached must call forget_cached_acl() to prevent the VFS
    from doing so.

    (Patch written by Al Viro and Andreas Gruenbacher.)

    Signed-off-by: Andreas Gruenbacher
    Signed-off-by: Al Viro

    Andreas Gruenbacher
     

07 Dec, 2015

1 commit


16 Apr, 2015

1 commit


26 Sep, 2014

1 commit

  • Silence a few warnings about missing symbols that are due to missing
    includes of nfs3_fs.h.

    Fixes: 00a36a1090350 (NFS: Move v3 declarations out of internal.h)
    Fixes: cb8c20fa53ec2 (NFS: Move NFS v3 acl functions to nfs3_fs.h)
    Signed-off-by: Trond Myklebust

    Trond Myklebust
     

27 Aug, 2014

1 commit

  • When creating a new object on the NFS server, we should not be sending
    posix setacl requests unless the preceding posix_acl_create returned a
    non-trivial acl. Doing so, causes Solaris servers in particular to
    return an EINVAL.

    Fixes: 013cdf1088d72 (nfs: use generic posix ACL infrastructure,,,)
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1132786
    Cc: stable@vger.kernel.org # 3.14+
    Signed-off-by: Trond Myklebust

    Trond Myklebust
     

04 Aug, 2014

1 commit

  • There was a check for result being not NULL. But get_acl() may return
    NULL, or ERR_PTR, or actual pointer.
    The purpose of the function where current change is done is to "list
    ACLs only when they are available", so any error condition of get_acl()
    mustn't be elevated, and returning 0 there is still valid.

    Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=81111
    Signed-off-by: Andrey Utkin
    Reviewed-by: Christoph Hellwig
    Fixes: 74adf83f5d77 (nfs: only show Posix ACLs in listxattr if actually...)
    Cc: stable@vger.kernel.org # 3.14+
    Signed-off-by: Trond Myklebust

    Andrey Utkin
     

09 Jul, 2014

1 commit

  • The big ACL switched nfs to use generic_listxattr, which calls all existing
    ->list handlers. Add a custom .listxattr implementation that only lists
    the ACLs if they actually are present on the given inode.

    Signed-off-by: Christoph Hellwig
    Reported-by: Philippe Troin
    Tested-by: Philippe Troin
    Fixes: 013cdf1088d7 (nfs: use generic posix ACL infrastructure ...)
    Cc: stable@vger.kernel.org # 3.14+
    Signed-off-by: Trond Myklebust

    Christoph Hellwig
     

04 Feb, 2014

2 commits


01 Feb, 2014

1 commit

  • nfs3_get_acl() tries to skip posix equivalent ACLs, but misinterprets
    the return value of posix_acl_equiv_mode(). Fix it.

    This is a regression introduced by
    "nfs: use generic posix ACL infrastructure for v3 Posix ACLs"

    CC: Christoph Hellwig
    CC: linux-nfs@vger.kernel.org
    CC: linux-fsdevel@vger.kernel.org

    Signed-off-by: Trond Myklebust

    Noah Massey
     

26 Jan, 2014

2 commits


18 Sep, 2012

1 commit

  • - Pass the user namespace the uid and gid values in the xattr are stored
    in into posix_acl_from_xattr.

    - Pass the user namespace kuid and kgid values should be converted into
    when storing uid and gid values in an xattr in posix_acl_to_xattr.

    - Modify all callers of posix_acl_from_xattr and posix_acl_to_xattr to
    pass in &init_user_ns.

    In the short term this change is not strictly needed but it makes the
    code clearer. In the longer term this change is necessary to be able to
    mount filesystems outside of the initial user namespace that natively
    store posix acls in the linux xattr format.

    Cc: Theodore Tso
    Cc: Andrew Morton
    Cc: Andreas Dilger
    Cc: Jan Kara
    Cc: Al Viro
    Signed-off-by: "Eric W. Biederman"

    Eric W. Biederman
     

12 Mar, 2012

1 commit

  • Fix a number of "warning: symbol 'foo' was not declared. Should it be
    static?" conditions.

    Fix 2 cases of "warning: Using plain integer as NULL pointer"

    fs/nfs/delegation.c:263:31: warning: restricted fmode_t degrades to integer
    - We want to allow upgrades to a WRITE delegation, but should otherwise
    consider servers that hand out duplicate delegations to be borken.

    Signed-off-by: Trond Myklebust

    Trond Myklebust
     

01 Aug, 2011

1 commit


26 Jul, 2011

1 commit


26 Jan, 2011

1 commit

  • nfsacl_encode() allocates memory in certain cases. This of course
    is not guaranteed to work.

    Since commit 9f06c719 "SUNRPC: New xdr_streams XDR encoder API", the
    kernel's XDR encoders can't return a result indicating possibly a
    failure, so a memory allocation failure in nfsacl_encode() has become
    fatal (ie, the XDR code Oopses) in some cases.

    However, the allocated memory is a tiny fixed amount, on the order
    of 40-50 bytes. We can easily use a stack-allocated buffer for
    this, with only a wee bit of nose-holding.

    Signed-off-by: Chuck Lever
    Signed-off-by: Trond Myklebust

    Chuck Lever
     

15 May, 2010

1 commit


30 Mar, 2010

1 commit

  • …it slab.h inclusion from percpu.h

    percpu.h is included by sched.h and module.h and thus ends up being
    included when building most .c files. percpu.h includes slab.h which
    in turn includes gfp.h making everything defined by the two files
    universally available and complicating inclusion dependencies.

    percpu.h -> slab.h dependency is about to be removed. Prepare for
    this change by updating users of gfp and slab facilities include those
    headers directly instead of assuming availability. As this conversion
    needs to touch large number of source files, the following script is
    used as the basis of conversion.

    http://userweb.kernel.org/~tj/misc/slabh-sweep.py

    The script does the followings.

    * Scan files for gfp and slab usages and update includes such that
    only the necessary includes are there. ie. if only gfp is used,
    gfp.h, if slab is used, slab.h.

    * When the script inserts a new include, it looks at the include
    blocks and try to put the new include such that its order conforms
    to its surrounding. It's put in the include block which contains
    core kernel includes, in the same order that the rest are ordered -
    alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
    doesn't seem to be any matching order.

    * If the script can't find a place to put a new include (mostly
    because the file doesn't have fitting include block), it prints out
    an error message indicating which .h file needs to be added to the
    file.

    The conversion was done in the following steps.

    1. The initial automatic conversion of all .c files updated slightly
    over 4000 files, deleting around 700 includes and adding ~480 gfp.h
    and ~3000 slab.h inclusions. The script emitted errors for ~400
    files.

    2. Each error was manually checked. Some didn't need the inclusion,
    some needed manual addition while adding it to implementation .h or
    embedding .c file was more appropriate for others. This step added
    inclusions to around 150 files.

    3. The script was run again and the output was compared to the edits
    from #2 to make sure no file was left behind.

    4. Several build tests were done and a couple of problems were fixed.
    e.g. lib/decompress_*.c used malloc/free() wrappers around slab
    APIs requiring slab.h to be added manually.

    5. The script was run on all .h files but without automatically
    editing them as sprinkling gfp.h and slab.h inclusions around .h
    files could easily lead to inclusion dependency hell. Most gfp.h
    inclusion directives were ignored as stuff from gfp.h was usually
    wildly available and often used in preprocessor macros. Each
    slab.h inclusion directive was examined and added manually as
    necessary.

    6. percpu.h was updated not to include slab.h.

    7. Build test were done on the following configurations and failures
    were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
    distributed build env didn't work with gcov compiles) and a few
    more options had to be turned off depending on archs to make things
    build (like ipr on powerpc/64 which failed due to missing writeq).

    * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
    * powerpc and powerpc64 SMP allmodconfig
    * sparc and sparc64 SMP allmodconfig
    * ia64 SMP allmodconfig
    * s390 SMP allmodconfig
    * alpha SMP allmodconfig
    * um on x86_64 SMP allmodconfig

    8. percpu.h modifications were reverted so that it could be applied as
    a separate patch and serve as bisection point.

    Given the fact that I had only a couple of failures from tests on step
    6, I'm fairly confident about the coverage of this conversion patch.
    If there is a breakage, it's likely to be something in one of the arch
    headers which should be easily discoverable easily on most builds of
    the specific arch.

    Signed-off-by: Tejun Heo <tj@kernel.org>
    Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>

    Tejun Heo
     

18 Jun, 2009

1 commit


11 Mar, 2009

1 commit

  • Fix a memory leak due to allocation in the XDR layer. In cases where the
    RPC call needs to be retransmitted, we end up allocating new pages without
    clearing the old ones. Fix this by moving the allocation into
    nfs3_proc_setacls().

    Also fix an issue discovered by Kevin Rudd, whereby the amount of memory
    reserved for the acls in the xdr_buf->head was miscalculated, and causing
    corruption.

    Signed-off-by: Trond Myklebust

    Trond Myklebust
     

08 Oct, 2008

1 commit


10 Jul, 2008

1 commit


10 Oct, 2007

1 commit


09 Jun, 2006

1 commit

  • Fix two errors in the client-side acl cache: First, when nfs3_proc_getacl
    requests only the default acl of a file and the access acl is not cached
    already, a NULL access acl entry is cached instead of ERR_PTR(-EAGAIN)
    ("not cached").

    Second, update the cached acls in nfs3_proc_setacls: nfs_refresh_inode does
    not always invalidate the cached acls, and when it does not, the cached acls
    get out of sync.

    Signed-off-by: Andreas Gruenbacher
    Signed-off-by: Trond Myklebust

    Andreas Gruenbacher
     

21 Mar, 2006

1 commit

  • Clean-up: replace rpc_call() helper with direct call to rpc_call_sync.

    This makes NFSv2 and NFSv3 synchronous calls more computationally
    efficient, and reduces stack consumption in functions that used to
    invoke rpc_call more than once.

    Test plan:
    Compile kernel with CONFIG_NFS enabled. Connectathon on NFS version 2,
    version 3, and version 4 mount points.

    Signed-off-by: Chuck Lever
    Signed-off-by: Trond Myklebust

    Chuck Lever
     

19 Aug, 2005

2 commits

  • Down the road we want to eliminate the use of the global kernel lock entirely
    from the NFS client. To do this, we need to protect the fields in the
    nfs_inode structure adequately. Start by serializing updates to the
    "cache_validity" field.

    Note this change addresses an SMP hang found by njw@osdl.org, where processes
    deadlock because nfs_end_data_update and nfs_revalidate_mapping update the
    "cache_validity" field without proper serialization.

    Test plan:
    Millions of fsx ops on SMP clients. Run Nick Wilson's breaknfs program on
    large SMP clients.

    Signed-off-by: Chuck Lever
    Cc: Trond Myklebust
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Chuck Lever
     
  • Certain bits in nfsi->flags can be manipulated with atomic bitops, and some
    are better manipulated via logical bitmask operations.

    This patch splits the flags field into two. The next patch introduces atomic
    bitops for one of the fields.

    Test plan:
    Millions of fsx ops on SMP clients.

    Signed-off-by: Chuck Lever
    Cc: Trond Myklebust
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Chuck Lever
     

29 Jun, 2005

1 commit


23 Jun, 2005

4 commits

  • Initialize the inode cache values correctly.
    Clean up __nfs3_forget_cached_acls()

    Signed-off-by: Trond Myklebust

    Trond Myklebust
     
  • Attach acls to inodes in the icache to avoid unnecessary GETACL RPC
    round-trips. As long as the client doesn't retrieve any acls itself, only the
    default acls of exiting directories and the default and access acls of new
    directories will end up in the cache, which preserves some memory compared to
    always caching the access and default acl of all files.

    Signed-off-by: Andreas Gruenbacher
    Acked-by: Olaf Kirch
    Signed-off-by: Andrew Morton
    Signed-off-by: Trond Myklebust

    Andreas Gruenbacher
     
  • NFSv3 has no concept of a umask on the server side: The client applies
    the umask locally, and sends the effective permissions to the server.
    This behavior is wrong when files are created in a directory that has a
    default ACL. In this case, the umask is supposed to be ignored, and
    only the default ACL determines the file's effective permissions.

    Usually its the server's task to conditionally apply the umask. But
    since the server knows nothing about the umask, we have to do it on the
    client side. This patch tries to fetch the parent directory's default
    ACL before creating a new file, computes the appropriate create mode to
    send to the server, and finally sets the new file's access and default
    acl appropriately.

    Many thanks to Buck Huppmann for sending the initial
    version of this patch, as well as for arguing why we need this change.

    Signed-off-by: Andreas Gruenbacher
    Acked-by: Olaf Kirch
    Signed-off-by: Andrew Morton
    Signed-off-by: Trond Myklebust

    Andreas Gruenbacher
     
  • This adds acl support fo nfs clients via the NFSACL protocol extension, by
    implementing the getxattr, listxattr, setxattr, and removexattr iops for the
    system.posix_acl_access and system.posix_acl_default attributes. This patch
    implements a dumb version that uses no caching (and thus adds some overhead).
    (Another patch in this patchset adds caching as well.)

    Signed-off-by: Andreas Gruenbacher
    Acked-by: Olaf Kirch
    Signed-off-by: Andrew Morton
    Signed-off-by: Trond Myklebust

    Andreas Gruenbacher