From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 88485399CE9 for ; Sat, 5 Sep 2026 21:43:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788644637; cv=none; b=UkR6Cz2osYN0YKXzv3/vKOXtoMYxuUWzn/A1JcRakNnbBujP7lXaRnwE2XVwTh9/ZFiciPwSp8OXc8+yKdMZGcqvYdtGsAzhgUaF5kgQL7jxJWdf1Db3aiSAw4xNLD4bS0t2FgyHv4N/Rv7jmAUcEAN/FzdCh9Bn5zggNF2AVzQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788644637; c=relaxed/simple; bh=gQ/Y6h3xT/dyzJO0kAU5hJ3E5PLPQ+pC3qrEbF6Y7q0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mhok3FT/1szjh8jDoZea6pAYaCnQHibW2dUaWIW0XlTfSBMC069nfvdBsev+pMUESsyNmxuex3PS8RBYE24lLVSoAz/bvFYFs6/vV3tjAH6HqhDdchgCTA7rE7UGAX/aF0CWa0rQxMQyEzXtCQp1iE1yP+mQ5IBMwUSS0k7FIRg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ssw3G30i; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ssw3G30i" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF8FC1F00A3D; Sat, 5 Sep 2026 21:43:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788644636; bh=IBXdFOvML0PuOPQfDIofrIFa5BJNthYpmpjxXldOVOQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ssw3G30il0f5EmxgZDauP/xv3A503kFLjcaUExEnV3A5RLyY5LcT8o20hnxMuS4Ii jv3mLzoF5aqzv2RE6Ds3BHgV2xmG8vx15AFLDdr8CsbEwIbvGGitbTZhWk4pjH0Gmf zQcavDxMdNgfP9L2uNhZpIfI1/JDAMZrtg/PAMCwbdDlvVwFgPmoZbGzyfXD2df0ah 9wCoG/jUhp6PkZkHmfiq4KylVge7JbH4/QNHou3g6FwBU67UPwtIaEtfXt3moAicOW 6owj2W09iI4NsTtN/R9mAdmZ47KVgHotVQEcJJLHFHzezd26vDKK2WBnSOcjmownxY HRrzgkBf5GEOQ== From: Sasha Levin To: stable@vger.kernel.org Cc: Chuck Lever , Sasha Levin Subject: [PATCH 5.15.y] nfsd: gate nfs2 setacl by argp->mask Date: Sat, 5 Sep 2026 17:43:53 -0400 Message-ID: <20260905214353.703392-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026090350-onyx-repaying-474c@gregkh> References: <2026090350-onyx-repaying-474c@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Chuck Lever [ Upstream commit a3a7e20ed66d3f04d37883c398da8a113b430769 ] The NFSACL v2 SETACL path shares the decoder convention used by its v3 sibling: nfsaclsvc_decode_setaclargs() fills in argp->acl_access only when NFS_ACL is set in the request mask and argp->acl_default only when NFS_DFACL is set, leaving the other pointer NULL because the argument buffer is zeroed up to pc_argzero before decode. nfsacld_proc_setacl() then hands both pointers to set_posix_acl() unconditionally. set_posix_acl(idmap, dentry, type, NULL) is the VFS "remove this ACL type" operation, so an omitted arm is indistinguishable from an explicit request to delete that ACL. A SETACL carrying only NFS_ACL silently strips the directory's default ACL; mask=0 strips both. This is the same defect just fixed in nfsd3_proc_setacl(); apply the same remedy. Gate each set_posix_acl() call on its mask bit and initialize error to 0 so that a request with neither bit set leaves the on-disk ACLs untouched and returns success. The out_drop_lock path and the unconditional posix_acl_release() in nfsaclsvc_release_setacl() already tolerate the skipped arms. Fixes: a257cdd0e217 ("[PATCH] NFSD: Add server support for NFSv3 ACLs.") Cc: stable@vger.kernel.org Signed-off-by: Chuck Lever [ retained the older user-namespace and inode set_posix_acl() API in place of the newer mount-idmap and dentry API. ] Signed-off-by: Sasha Levin --- fs/nfsd/nfs2acl.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/fs/nfsd/nfs2acl.c b/fs/nfsd/nfs2acl.c index 44b74d83560b5..6e2ed6947033c 100644 --- a/fs/nfsd/nfs2acl.c +++ b/fs/nfsd/nfs2acl.c @@ -115,14 +115,19 @@ static __be32 nfsacld_proc_setacl(struct svc_rqst *rqstp) inode_lock(inode); - error = set_posix_acl(&init_user_ns, inode, ACL_TYPE_ACCESS, - argp->acl_access); - if (error) - goto out_drop_lock; - error = set_posix_acl(&init_user_ns, inode, ACL_TYPE_DEFAULT, - argp->acl_default); - if (error) - goto out_drop_lock; + error = 0; + if (argp->mask & NFS_ACL) { + error = set_posix_acl(&init_user_ns, inode, ACL_TYPE_ACCESS, + argp->acl_access); + if (error) + goto out_drop_lock; + } + if (argp->mask & NFS_DFACL) { + error = set_posix_acl(&init_user_ns, inode, ACL_TYPE_DEFAULT, + argp->acl_default); + if (error) + goto out_drop_lock; + } inode_unlock(inode); -- 2.53.0