From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x22550DL1iwU4CX55Fh+DHpVc1Rq6gvNpk/6+fQKLnXo55oyxL+ThKFCBJoWSqfUPvokrvVA9 ARC-Seal: i=1; a=rsa-sha256; t=1517256812; cv=none; d=google.com; s=arc-20160816; b=ji6mGHfr74TVCzLg43IAHIM9vVbYp86JXvO9gZ3QNwk6vW/tHoLF6VywmzPt6WGgHT A9hPCtMgS2oNnFZdO94H6DsAglXc4KRfYMYtdf8vgPqT/hz4o3FF9tvFRpmxIbdGU+NW bpeVTjvzZeUBWEPjjB6ryNRK9PEquA1F4GazbRvVvKcerAwsZGVfxxpCyVd28v1YDGUN SNuvn2+UjWPrjKX3uOVE1M41++DSBlyEWWdk/0F5oAjL9ikWq5zSeKS2kwyeGMdb+kdC KDZuGjdhUfvYN35Y3u2obgINI4TqAKSbmT5GyQpXZiN+e8dmzMr7m8ZnL+rtm8Mu1RyO Zb9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=D6TwqN7vkneUNKyGYOU76sinkIh68+9O9UpZMrVUjXc=; b=qys14Tgk2BKnqODAWzvtJ1z86/vCA8EmviHA1jVMwVAhASmydtRMUyenk5FFYjyVO3 ai+cJDzUKtZ46eZsjA15HomD3cZU9rBEYV3gVGEY5+jDsnSLXsDcRmSv4p8oV9o+mg+l sf8M5tzqOV40MhKKmc7D3PXCrq0HQ5Eatk9VQmWZIf/x2MokJYC5uHITVgrAvnU7/qLd 7jU+9PuDkU72CjZLMclfQFi3ai3LtZrGgDRkbKbNpThjimv1L1Xkr3ZnL0nHB4KGTNpu OsRdZrJlC6dCoqEGOMSFGTEvlOgAkvUuaUgG/KfhWKYbyAOeLPZbgWK+ukUvLFMOsu5O S+aw== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, linux-ext4@vger.kernel.org, Jan Kara Subject: [PATCH 4.4 41/74] ext2: Dont clear SGID when inheriting ACLs Date: Mon, 29 Jan 2018 13:56:46 +0100 Message-Id: <20180129123849.432485603@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180129123847.507563674@linuxfoundation.org> References: <20180129123847.507563674@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-LABELS: =?utf-8?b?IlxcU2VudCI=?= X-GMAIL-THRID: =?utf-8?q?1590959079348499568?= X-GMAIL-MSGID: =?utf-8?q?1590959079348499568?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jan Kara commit a992f2d38e4ce17b8c7d1f7f67b2de0eebdea069 upstream. 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 creating __ext2_set_acl() function that does not call posix_acl_update_mode() and use it when inheriting ACLs. That prevents SGID bit clearing and the mode has been properly set by posix_acl_create() anyway. Fixes: 073931017b49d9458aa351605b43a7e34598caef CC: stable@vger.kernel.org CC: linux-ext4@vger.kernel.org Signed-off-by: Jan Kara Signed-off-by: Greg Kroah-Hartman --- fs/ext2/acl.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) --- a/fs/ext2/acl.c +++ b/fs/ext2/acl.c @@ -178,11 +178,8 @@ ext2_get_acl(struct inode *inode, int ty return acl; } -/* - * inode->i_mutex: down - */ -int -ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type) +static int +__ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type) { int name_index; void *value = NULL; @@ -192,13 +189,6 @@ ext2_set_acl(struct inode *inode, struct switch(type) { case ACL_TYPE_ACCESS: name_index = EXT2_XATTR_INDEX_POSIX_ACL_ACCESS; - if (acl) { - error = posix_acl_update_mode(inode, &inode->i_mode, &acl); - if (error) - return error; - inode->i_ctime = CURRENT_TIME_SEC; - mark_inode_dirty(inode); - } break; case ACL_TYPE_DEFAULT: @@ -225,6 +215,24 @@ ext2_set_acl(struct inode *inode, struct } /* + * inode->i_mutex: down + */ +int +ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type) +{ + int error; + + if (type == ACL_TYPE_ACCESS && acl) { + error = posix_acl_update_mode(inode, &inode->i_mode, &acl); + if (error) + return error; + inode->i_ctime = CURRENT_TIME_SEC; + mark_inode_dirty(inode); + } + return __ext2_set_acl(inode, acl, type); +} + +/* * Initialize the ACLs of a new inode. Called from ext2_new_inode. * * dir->i_mutex: down @@ -241,12 +249,12 @@ ext2_init_acl(struct inode *inode, struc return error; if (default_acl) { - error = ext2_set_acl(inode, default_acl, ACL_TYPE_DEFAULT); + error = __ext2_set_acl(inode, default_acl, ACL_TYPE_DEFAULT); posix_acl_release(default_acl); } if (acl) { if (!error) - error = ext2_set_acl(inode, acl, ACL_TYPE_ACCESS); + error = __ext2_set_acl(inode, acl, ACL_TYPE_ACCESS); posix_acl_release(acl); } return error;