Received: by 10.223.185.111 with SMTP id b44csp917724wrg; Fri, 9 Mar 2018 16:49:55 -0800 (PST) X-Google-Smtp-Source: AG47ELuGPiusuziT/RSzfD0J6Vakph9zHa8/neLkIGt3lqntnr+To03KEjXMDv25cK6T0OGL0MzN X-Received: by 2002:a17:902:b901:: with SMTP id bf1-v6mr360605plb.175.1520642995383; Fri, 09 Mar 2018 16:49:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520642995; cv=none; d=google.com; s=arc-20160816; b=uq64SM9pyuL3lGny3TgFfNfj631BkGS4MLj1wGRfsxH1upCJSFdIt0603bOQR4yr3M LivAEeTF3bJ/SQ2isMp+te0DtIsrmfvb8WySbtjpfUvU9BLmOp2IEVZdYH4iY/bUgLpd bKJofv1YjwghWihlWpRmW7zzraAXr236ZzkhJlseSRk80sn52XW8I357IcD5AfR9m8+L wbJq0egt1/NAqG30HdQRr3aMt5DQF09inGlK1pmx3I8O6erdYmYhSg93rs+yWOovVPZx BYVE8AkxEb9OpqUAuFxYIGDUBZxZbaEo0K57VJEtI3ZEdPALEyuBYez8Xp82Ya3McCzm W3/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=1hDlqHNTd1qgwz+X2t2U4pVlrPG/ByXcO7kIDKPAKwI=; b=i6OoCrJODC17/7eD3TbWXspNVWKQEs4TWbNyKDE2tJ9hjgHk3soR01iew9Y4lUGmTi XyIbiRKz14U6jrr/cCmWdCnJPlOtmxe9MG6eL87vEzxHPcmDWLQHl9T4ddN0pMB2+rxj 5HmCL57USDE6SpV74mfDUn2clPVox+SwLehgu20Ku+PQUjPQcnyMnN37uPyrGefwmC/+ FeJ9mZhQ/fmUq0FYJyWhkUH+P5cH9r9nRyXRG5PlPJfyE0XqYNae7HoN35gSgxz3ZTVM woopZhlHGQ2hc7GtafdEDAo06CBFBZ98C1kj4q1HRdfjjRN+brnuFRXB7xaBjnNxMeTj mJkg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p11si1480986pgs.537.2018.03.09.16.49.41; Fri, 09 Mar 2018 16:49:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933232AbeCJAsu (ORCPT + 99 others); Fri, 9 Mar 2018 19:48:50 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:38794 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751325AbeCJATn (ORCPT ); Fri, 9 Mar 2018 19:19:43 -0500 Received: from localhost (unknown [185.236.200.248]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3A152F4D; Sat, 10 Mar 2018 00:19:43 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, linux-btrfs@vger.kernel.org, David Sterba , Jan Kara , Nikolay Borisov Subject: [PATCH 4.4 12/36] btrfs: Dont clear SGID when inheriting ACLs Date: Fri, 9 Mar 2018 16:18:28 -0800 Message-Id: <20180310001807.896983748@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180310001807.213987241@linuxfoundation.org> References: <20180310001807.213987241@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jan Kara commit b7f8a09f8097db776b8d160862540e4fc1f51296 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 moving posix_acl_update_mode() out of __btrfs_set_acl() into btrfs_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 CC: stable@vger.kernel.org CC: linux-btrfs@vger.kernel.org CC: David Sterba Signed-off-by: Jan Kara Signed-off-by: David Sterba Signed-off-by: Nikolay Borisov Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/acl.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) --- a/fs/btrfs/acl.c +++ b/fs/btrfs/acl.c @@ -82,12 +82,6 @@ static int __btrfs_set_acl(struct btrfs_ switch (type) { case ACL_TYPE_ACCESS: name = POSIX_ACL_XATTR_ACCESS; - if (acl) { - ret = posix_acl_update_mode(inode, &inode->i_mode, &acl); - if (ret) - return ret; - } - ret = 0; break; case ACL_TYPE_DEFAULT: if (!S_ISDIR(inode->i_mode)) @@ -123,6 +117,13 @@ out: int btrfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) { + int ret; + + if (type == ACL_TYPE_ACCESS && acl) { + ret = posix_acl_update_mode(inode, &inode->i_mode, &acl); + if (ret) + return ret; + } return __btrfs_set_acl(NULL, inode, acl, type); }