diff options
author | Carlos Maiolino <cmaiolino@redhat.com> | 2013-06-21 13:45:53 -0400 |
---|---|---|
committer | Ben Myers <bpm@sgi.com> | 2013-07-10 11:21:51 -0400 |
commit | 42c49d7f249c2487f36d3314753d5d8ebcee8249 (patch) | |
tree | 6c0863677aa03d43d5a5c3e8cb5a53c4b1653b08 /fs/xfs | |
parent | b0a9dab78aee2a479d7c226e6939d553967e4024 (diff) |
xfs: fix sgid inheritance for subdirectories inheriting default acls [V3]
XFS removes sgid bits of subdirectories under a directory containing a default
acl.
When a default acl is set, it implies xfs to call xfs_setattr_nonsize() in its
code path. Such function is shared among mkdir and chmod system calls, and
does some checks unneeded by mkdir (calling inode_change_ok()). Such checks
remove sgid bit from the inode after it has been granted.
With this patch, we extend the meaning of XFS_ATTR_NOACL flag to avoid these
checks when acls are being inherited (thanks hch).
Also, xfs_setattr_mode, doesn't need to re-check for group id and capabilities
permissions, this only implies in another try to remove sgid bit from the
directories. Such check is already done either on inode_change_ok() or
xfs_setattr_nonsize().
Changelog:
V2: Extends the meaning of XFS_ATTR_NOACL instead of wrap the tests into another
function
V3: Remove S_ISDIR check in xfs_setattr_nonsize() from the patch
Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Ben Myers <bpm@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r-- | fs/xfs/xfs_iops.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index c69bbc493cb0..8865261e5417 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c | |||
@@ -467,9 +467,6 @@ xfs_setattr_mode( | |||
467 | ASSERT(tp); | 467 | ASSERT(tp); |
468 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); | 468 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); |
469 | 469 | ||
470 | if (!in_group_p(inode->i_gid) && !capable(CAP_FSETID)) | ||
471 | mode &= ~S_ISGID; | ||
472 | |||
473 | ip->i_d.di_mode &= S_IFMT; | 470 | ip->i_d.di_mode &= S_IFMT; |
474 | ip->i_d.di_mode |= mode & ~S_IFMT; | 471 | ip->i_d.di_mode |= mode & ~S_IFMT; |
475 | 472 | ||
@@ -495,15 +492,18 @@ xfs_setattr_nonsize( | |||
495 | 492 | ||
496 | trace_xfs_setattr(ip); | 493 | trace_xfs_setattr(ip); |
497 | 494 | ||
498 | if (mp->m_flags & XFS_MOUNT_RDONLY) | 495 | /* If acls are being inherited, we already have this checked */ |
499 | return XFS_ERROR(EROFS); | 496 | if (!(flags & XFS_ATTR_NOACL)) { |
497 | if (mp->m_flags & XFS_MOUNT_RDONLY) | ||
498 | return XFS_ERROR(EROFS); | ||
500 | 499 | ||
501 | if (XFS_FORCED_SHUTDOWN(mp)) | 500 | if (XFS_FORCED_SHUTDOWN(mp)) |
502 | return XFS_ERROR(EIO); | 501 | return XFS_ERROR(EIO); |
503 | 502 | ||
504 | error = -inode_change_ok(inode, iattr); | 503 | error = -inode_change_ok(inode, iattr); |
505 | if (error) | 504 | if (error) |
506 | return XFS_ERROR(error); | 505 | return XFS_ERROR(error); |
506 | } | ||
507 | 507 | ||
508 | ASSERT((mask & ATTR_SIZE) == 0); | 508 | ASSERT((mask & ATTR_SIZE) == 0); |
509 | 509 | ||