posix_acl: Clear SGID bit when setting file permissions
authorJan Kara <jack@suse.cz>
Tue, 25 Oct 2016 13:44:26 +0000 (08:44 -0500)
committerWilly Tarreau <w@1wt.eu>
Wed, 7 Jun 2017 22:46:47 +0000 (00:46 +0200)
commitdd2421b5edbadc5404e1cbc8fdc552f1558cc541
tree4962f5b0f323fa0429f2a25fced706154382ca47
parent27bf4b6e27baa89d93ce9f2da7878e126748d721
posix_acl: Clear SGID bit when setting file permissions

commit 073931017b49d9458aa351605b43a7e34598caef upstream.

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.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
[wt: dropped hfsplus changes : no xattr in 3.10]
Signed-off-by: Willy Tarreau <w@1wt.eu>
14 files changed:
fs/9p/acl.c
fs/btrfs/acl.c
fs/ext2/acl.c
fs/ext3/acl.c
fs/ext4/acl.c
fs/f2fs/acl.c
fs/gfs2/acl.c
fs/jffs2/acl.c
fs/jfs/xattr.c
fs/ocfs2/acl.c
fs/posix_acl.c
fs/reiserfs/xattr_acl.c
fs/xfs/xfs_acl.c
include/linux/posix_acl.h