From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C65A4C433F5 for ; Wed, 23 Feb 2022 02:30:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236930AbiBWCbD (ORCPT ); Tue, 22 Feb 2022 21:31:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236936AbiBWC3n (ORCPT ); Tue, 22 Feb 2022 21:29:43 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77CEE541AB; Tue, 22 Feb 2022 18:29:01 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 19FCFB81DD2; Wed, 23 Feb 2022 02:29:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0B70C340E8; Wed, 23 Feb 2022 02:28:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645583339; bh=kS8D6bkfgqqgmMhggKntZnsLULvt63AbdUvRgellOS4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Grlcqg4NocKZlNVn/5Et/3ZED/Yg9IuYVcCjDIZqi+N6TZGkj78d8wB7jUP9vAGTJ L+cau7zJiLXcIE1XMHXzRh5hblbOgi7nFqycbaIHD2bqjyioVjgtyckCzlrHCvXDpk tN+WZuzZTfSY+2FaKQn59ZjuGJoKHzv4Vi73hR/028eavCITWJ/d70+vvLKALNO3IF Jr0L0o16FCYWJgV+EiMTNq9LBUv1zyk3WRpXcSv+77g82mkaW148QHtfMquHijxsFs X+NivdK0rC502bT220Lw37brXQNBD/5ODwsF7DWgjhd3cAr1+8zZTUDlIq+BeaiN6Y hwYXAjPWL3+eg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ronnie Sahlberg , Shyam Prasad N , Steve French , Sasha Levin , sfrench@samba.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org Subject: [PATCH AUTOSEL 5.16 20/30] cifs: modefromsids must add an ACE for authenticated users Date: Tue, 22 Feb 2022 21:28:09 -0500 Message-Id: <20220223022820.240649-20-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220223022820.240649-1-sashal@kernel.org> References: <20220223022820.240649-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ronnie Sahlberg [ Upstream commit 0c6f4ebf8835d01866eb686d47578cde80097981 ] When we create a file with modefromsids we set an ACL that has one ACE for the magic modefromsid as well as a second ACE that grants full access to all authenticated users. When later we chante the mode on the file we strip away this, and other, ACE for authenticated users in set_chmod_dacl() and then just add back/update the modefromsid ACE. Thus leaving the file with a single ACE that is for the mode and no ACE to grant any user any rights to access the file. Fix this by always adding back also the modefromsid ACE so that we do not drop the rights to access the file. Signed-off-by: Ronnie Sahlberg Reviewed-by: Shyam Prasad N Signed-off-by: Steve French Signed-off-by: Sasha Levin --- fs/cifs/cifsacl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c index 5df21d63dd04e..bf861fef2f0c3 100644 --- a/fs/cifs/cifsacl.c +++ b/fs/cifs/cifsacl.c @@ -949,6 +949,9 @@ static void populate_new_aces(char *nacl_base, pnntace = (struct cifs_ace *) (nacl_base + nsize); nsize += setup_special_mode_ACE(pnntace, nmode); num_aces++; + pnntace = (struct cifs_ace *) (nacl_base + nsize); + nsize += setup_authusers_ACE(pnntace); + num_aces++; goto set_size; } @@ -1613,7 +1616,7 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 *pnmode, nsecdesclen = secdesclen; if (pnmode && *pnmode != NO_CHANGE_64) { /* chmod */ if (mode_from_sid) - nsecdesclen += sizeof(struct cifs_ace); + nsecdesclen += 2 * sizeof(struct cifs_ace); else /* cifsacl */ nsecdesclen += 5 * sizeof(struct cifs_ace); } else { /* chown */ -- 2.34.1