Re: [PATCH 2/2] posix_acl: Clear SGID bit when modifying file permissions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Honza,

2016-05-26 17:02 GMT+02:00 Jan Kara <jack@xxxxxxx>:
> When file permissions are modified via chmod(2) and the user modifying the
> permissions is not capable of setting SGID bit for the file, the bit gets
> cleared in inode_change_ok(). However this is not the case when file
> permissions get modified via setfacl(1).

this looks like a bug we need to fix, but the two patches are horrible.
How about introducing the following helper in fs/posix_acl.c instead?

int posix_acl_update_mode(struct inode *inode, struct posix_acl **acl)
{
       int error;

       error = posix_acl_equiv_mode(*acl, &inode->i_mode);
       if (error < 0)
               return error;
       if (error == 0)
               *acl = NULL;
       if (!in_group_p(inode->i_gid) &&
           !capable_wrt_inode_uidgid(inode, CAP_FSETID))
               inode->i_mode &= ~S_ISGID;
       return 0;
}

Once all filesystems use that, posix_acl_equiv_mode can be made static.

Thanks,
Andreas
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux