28 Mar, 2020

2 commits

  • Before this patch, multiple users called gfs2_qa_alloc which allocated
    a qadata structure to the inode, if quotas are turned on. Later, in
    file close or evict, the structure was deleted with gfs2_qa_delete.
    But there can be several competing processes who need access to the
    structure. There were races between file close (release) and the others.
    Thus, a release could delete the structure out from under a process
    that relied upon its existence. For example, chown.

    This patch changes the management of the qadata structures to be
    a get/put scheme. Function gfs2_qa_alloc has been changed to gfs2_qa_get
    and if the structure is allocated, the count essentially starts out at
    1. Function gfs2_qa_delete has been renamed to gfs2_qa_put, and the
    last guy to decrement the count to 0 frees the memory.

    Signed-off-by: Bob Peterson

    Bob Peterson
     
  • Before this patch, multiple callers called gfs2_rsqa_alloc to force
    the existence of a reservations structure and a quota data structure
    if needed. However, now the reservations are handled separately, so
    the quota data is only the quota data. So we eliminate the one in
    favor of just calling gfs2_qa_alloc directly.

    Signed-off-by: Bob Peterson

    Bob Peterson
     

05 Jun, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this copyrighted material is made available to anyone wishing to use
    modify copy or redistribute it subject to the terms and conditions
    of the gnu general public license version 2

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

    has been chosen to replace the boilerplate/reference in 44 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Reviewed-by: Kate Stewart
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190531081038.653000175@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

25 Jul, 2018

1 commit


26 Sep, 2017

1 commit

  • Three-entry POSIX ACLs can be stored in the file mode permission bits,
    with no need to store them in extended attributes. When a process sets
    such a minimal ACL, the kernel updates the file mode like chmod does,
    and removes any existing extended attributes for that ACL. Make sure
    the ctime is always updated in that case.

    Fixes xfstest generic/307.

    Signed-off-by: Andreas Gruenbacher
    Signed-off-by: Bob Peterson

    Andreas Gruenbacher
     

31 Aug, 2017

1 commit

  • When changing a file's acl mask, __gfs2_set_acl() will first set the
    group bits of i_mode to the value of the mask, and only then set the
    actual extended attribute representing the new acl.

    If the second part fails (due to lack of space, for example) and the
    file had no acl attribute to begin with, the system will from now on
    assume that the mask permission bits are actual group permission bits,
    potentially granting access to the wrong users.

    Prevent this by only changing the inode mode after the acl has been set.

    Signed-off-by: Ernesto A. Fernández
    Signed-off-by: Bob Peterson

    Ernesto A. Fernández
     

19 Jul, 2017

1 commit

  • When new directory 'DIR1' is created in a directory 'DIR0' with SGID bit
    set, DIR1 is expected to have SGID bit set (and owning group equal to
    the owning group of 'DIR0'). However when 'DIR0' also has some default
    ACLs that 'DIR1' inherits, setting these ACLs will result in SGID bit on
    'DIR1' to get cleared if user is not member of the owning group.

    Fix the problem by moving posix_acl_update_mode() out of
    __gfs2_set_acl() into gfs2_set_acl(). That way the function will not be
    called when inheriting ACLs which is what we want as it prevents SGID
    bit clearing and the mode has been properly set by posix_acl_create()
    anyway.

    Fixes: 073931017b49d9458aa351605b43a7e34598caef
    Signed-off-by: Jan Kara
    Signed-off-by: Bob Peterson

    Jan Kara
     

22 Sep, 2016

1 commit

  • When file permissions are modified via chmod(2) and the user is not in
    the owning group or capable of CAP_FSETID, the setgid bit is cleared in
    inode_change_ok(). Setting a POSIX ACL via setxattr(2) sets the file
    permissions as well as the new ACL, but doesn't clear the setgid bit in
    a similar way; this allows to bypass the check in chmod(2). Fix that.

    References: CVE-2016-7097
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Jeff Layton
    Signed-off-by: Jan Kara
    Signed-off-by: Andreas Gruenbacher

    Jan Kara
     

13 May, 2016

1 commit

  • Switch to the generic xattr handlers and take the necessary glocks at
    the layer below. The following are the new xattr "entry points"; they
    are called with the glock held already in the following cases:

    gfs2_xattr_get: From SELinux, during lookups.
    gfs2_xattr_set: The glock is never held.
    gfs2_get_acl: From gfs2_create_inode -> posix_acl_create and
    gfs2_setattr -> posix_acl_chmod.
    gfs2_set_acl: From gfs2_setattr -> posix_acl_chmod.

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

    Al Viro
     

07 Dec, 2015

1 commit


19 Mar, 2015

1 commit

  • When removing a default acl or setting an access acl that is entirely
    represented in the file mode, we end up with acl == NULL in gfs2_set_acl(). In
    that case, bring gfs2 in line with other file systems and cache the NULL acl
    with set_cached_acl() instead of invalidating the cache with
    forget_cached_acl().

    Signed-off-by: Andreas Gruenbacher
    Signed-off-by: Bob Peterson

    Andreas Gruenbacher
     

10 Feb, 2015

1 commit


19 Mar, 2014

2 commits

  • Here is a revised patch based on Steve's feedback:

    This patch eliminates function gfs2_set_mode which was only called in
    one place, and always returned 0.

    Signed-off-by: Bob Peterson
    Signed-off-by: Steven Whitehouse

    Bob Peterson
     
  • This patch increases the maximum number of ACLs from 25 to 300 for
    a 4K block size. The value is adjusted accordingly if the block size
    is smaller. Note that this is an arbitrary limit with a performance
    tradeoff, and that the physical limit is slightly over 500.

    Signed-off-by: Bob Peterson
    Signed-off-by: Steven Whitehouse

    Bob Peterson
     

06 Mar, 2014

1 commit

  • Return -E2BIG rather than -EINVAL if hit the maximum size limits of
    ACLs, as the former errno is consistent with VFS xattr syscalls.

    This is pointed out by Dave Chinner in previous discussion thread:
    http://www.spinics.net/lists/linux-fsdevel/msg71125.html

    Signed-off-by: Jie Liu
    Signed-off-by: Steven Whitehouse

    Jie Liu
     

26 Jan, 2014

3 commits


13 Feb, 2013

1 commit

  • Where kuid_t values are compared use uid_eq and where kgid_t values
    are compared use gid_eq. This is unfortunately necessary because
    of the type safety that keeps someone from accidentally mixing
    kuids and kgids with other types.

    Cc: Steven Whitehouse
    Signed-off-by: "Eric W. Biederman"

    Eric W. Biederman
     

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
     

04 May, 2012

1 commit

  • This cleans up the mode setting code when creating inodes. The
    SGID bit was being reset by setattr_copy() when the user creating a
    subdirectory was not in the owning group. When ACLs are in use this
    SGID bit should have been propagated if the ACL allows creation of
    a subdirectory. GFS2's behaviour now matches that of the other ACL
    supporting filesystems in this regard.

    Signed-off-by: Steven Whitehouse

    Steven Whitehouse
     

23 Nov, 2011

1 commit


21 Oct, 2011

1 commit

  • The aim of this patch is to use the newly enhanced ->dirty_inode()
    super block operation to deal with atime updates, rather than
    piggy backing that code into ->write_inode() as is currently
    done.

    The net result is a simplification of the code in various places
    and a reduction of the number of gfs2_dinode_out() calls since
    this is now implied by ->dirty_inode().

    Some of the mark_inode_dirty() calls have been moved under glocks
    in order to take advantage of then being able to avoid locking in
    ->dirty_inode() when we already have suitable locks.

    One consequence is that generic_write_end() now correctly deals
    with file size updates, so that we do not need a separate check
    for that afterwards. This also, indirectly, means that fdatasync
    should work correctly on GFS2 - the current code always syncs the
    metadata whether it needs to or not.

    Has survived testing with postmark (with and without atime) and
    also fsx.

    Signed-off-by: Steven Whitehouse

    Steven Whitehouse
     

01 Aug, 2011

2 commits


26 Jul, 2011

4 commits

  • Replace the ->check_acl method with a ->get_acl method that simply reads an
    ACL from disk after having a cache miss. This means we can replace the ACL
    checking boilerplate code with a single implementation in namei.c.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Al Viro

    Christoph Hellwig
     
  • new helper: posix_acl_create(&acl, gfp, mode_p). Replaces acl with
    modified clone, on failure releases acl and replaces with NULL.
    Returns 0 or -ve on error. All callers of posix_acl_create_masq()
    switched.

    Signed-off-by: Al Viro

    Al Viro
     
  • new helper: posix_acl_chmod(&acl, gfp, mode). Replaces acl with modified
    clone or with NULL if that has failed; returns 0 or -ve on error. All
    callers of posix_acl_chmod_masq() switched to that - they'd been doing
    exactly the same thing.

    Signed-off-by: Al Viro

    Al Viro
     
  • This moves logic for checking the cached ACL values from low-level
    filesystems into generic code. The end result is a streamlined ACL
    check that doesn't need to load the inode->i_op->check_acl pointer at
    all for the common cached case.

    The filesystems also don't need to check for a non-blocking RCU walk
    case in their acl_check() functions, because that is all handled at a
    VFS layer.

    Signed-off-by: Linus Torvalds
    Signed-off-by: Al Viro

    Linus Torvalds
     

20 Jul, 2011

2 commits


21 Jan, 2011

1 commit


07 Jan, 2011

1 commit


25 May, 2010

1 commit


22 May, 2010

1 commit


21 May, 2010

1 commit


17 Dec, 2009

1 commit

  • Add a flags argument to struct xattr_handler and pass it to all xattr
    handler methods. This allows using the same methods for multiple
    handlers, e.g. for the ACL methods which perform exactly the same action
    for the access and default ACLs, just using a different underlying
    attribute. With a little more groundwork it'll also allow sharing the
    methods for the regular user/trusted/secure handlers in extN, ocfs2 and
    jffs2 like it's already done for xfs in this patch.

    Also change the inode argument to the handlers to a dentry to allow
    using the handlers mechnism for filesystems that require it later,
    e.g. cifs.

    [with GFS2 bits updated by Steven Whitehouse ]

    Signed-off-by: Christoph Hellwig
    Reviewed-by: James Morris
    Acked-by: Joel Becker
    Signed-off-by: Al Viro

    Christoph Hellwig
     

03 Dec, 2009

3 commits