From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 87F1315E96 for ; Sun, 17 Aug 2025 02:28:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755397695; cv=none; b=obKi/RVgCfOTWYYg5wsjJlyULDGQNZWzChY1LuDvBqjz16yBkg0rCn7gAZMlo5jxU4qs9m/2eTxjOsgw24BgbCmvco1aBxjJsIw7d3PeS3evUuCBAasKN3FsHiudO11vSV7fPcuOp8KXpB9vYZ1zey2hhOUliBG35pckUtfLkHM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755397695; c=relaxed/simple; bh=F+7nQfwYxBSq2NlteLWxIxXqb//U47gTEkKi+8ZJDVk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CDdKLfCSKDyxiD43GyDDQ4o2BhRFp2gn3whaxXtLhI/Ph/IDmxpKWFvnEGaEVm0LHU4BlUUnJ54yqwNk9W35vEM54PKpkGjTA7NlNLH0OCI/54RXdqmA7Q7JrZRVVofEypZBgj1Cxkig+/r4GpLRYXX/vks3CvLtMvOEbGlr+Bo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PNFAq5Q+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PNFAq5Q+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A5284C4CEEF; Sun, 17 Aug 2025 02:28:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755397695; bh=F+7nQfwYxBSq2NlteLWxIxXqb//U47gTEkKi+8ZJDVk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PNFAq5Q+yZoux5rTZhjjMqlZikepOuCQap1+U3Qv5PpGAT93LLVaUk4FF5wVSGK0L hnZ5bs5lhYi+ppzhwNYAIwPXu9t1hYDIzabDROdlA+OfKVSGdpRY0RCLDuxT6GO3Mz ACpv4dpGistZ4K40j8VvBriupc2zACdkhv2gycbvpMK72M+KVr4RgXgNHy+oSnm1xT VsgmdQpjyRLUSQ3nRYNwiyLSg+W+L9RIjQrSY0pCTn21CHCBvXu3rX6HKxa0cezXIU 2esaeTWjTR5gwMtykMO7neprnvvBuPeJORwxF1NKMaGE41OJQNM/lC28Qz3jI6H0Ja CbcAO1NNagTiw== From: Sasha Levin To: stable@vger.kernel.org Cc: Trond Myklebust , Sasha Levin Subject: [PATCH 5.4.y 1/3] NFSv4: Fix nfs4_bitmap_copy_adjust() Date: Sat, 16 Aug 2025 22:28:10 -0400 Message-ID: <20250817022812.1338100-1-sashal@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <2025081556-illusive-crawlers-8c0e@gregkh> References: <2025081556-illusive-crawlers-8c0e@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: Trond Myklebust [ Upstream commit a71029b86752e8d40301af235a6bbf4896cc1402 ] Don't remove flags from the set retrieved from the cache_validity. We do want to retrieve all attributes that are listed as being invalid, whether or not there is a delegation set. Signed-off-by: Trond Myklebust Stable-dep-of: b01f21cacde9 ("NFS: Fix the setting of capabilities when automounting a new filesystem") Signed-off-by: Sasha Levin --- fs/nfs/nfs4proc.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 3477da3c2190..2145360d81ac 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -282,7 +282,7 @@ const u32 nfs4_fs_locations_bitmap[3] = { }; static void nfs4_bitmap_copy_adjust(__u32 *dst, const __u32 *src, - struct inode *inode) + struct inode *inode, unsigned long flags) { unsigned long cache_validity; @@ -290,22 +290,19 @@ static void nfs4_bitmap_copy_adjust(__u32 *dst, const __u32 *src, if (!inode || !nfs4_have_delegation(inode, FMODE_READ)) return; - cache_validity = READ_ONCE(NFS_I(inode)->cache_validity); - if (!(cache_validity & NFS_INO_REVAL_FORCED)) - cache_validity &= ~(NFS_INO_INVALID_CHANGE - | NFS_INO_INVALID_SIZE); + cache_validity = READ_ONCE(NFS_I(inode)->cache_validity) | flags; + /* Remove the attributes over which we have full control */ + dst[1] &= ~FATTR4_WORD1_RAWDEV; if (!(cache_validity & NFS_INO_INVALID_SIZE)) dst[0] &= ~FATTR4_WORD0_SIZE; if (!(cache_validity & NFS_INO_INVALID_CHANGE)) dst[0] &= ~FATTR4_WORD0_CHANGE; -} -static void nfs4_bitmap_copy_adjust_setattr(__u32 *dst, - const __u32 *src, struct inode *inode) -{ - nfs4_bitmap_copy_adjust(dst, src, inode); + if (!(cache_validity & NFS_INO_INVALID_OTHER)) + dst[1] &= ~(FATTR4_WORD1_MODE | FATTR4_WORD1_OWNER | + FATTR4_WORD1_OWNER_GROUP); } static void nfs4_setup_readdir(u64 cookie, __be32 *verifier, struct dentry *dentry, @@ -3333,12 +3330,15 @@ static int nfs4_do_setattr(struct inode *inode, const struct cred *cred, .inode = inode, .stateid = &arg.stateid, }; + unsigned long adjust_flags = NFS_INO_INVALID_CHANGE; int err; + if (sattr->ia_valid & (ATTR_MODE|ATTR_UID|ATTR_GID)) + adjust_flags |= NFS_INO_INVALID_OTHER; + do { - nfs4_bitmap_copy_adjust_setattr(bitmask, - nfs4_bitmask(server, olabel), - inode); + nfs4_bitmap_copy_adjust(bitmask, nfs4_bitmask(server, olabel), + inode, adjust_flags); err = _nfs4_do_setattr(inode, &arg, &res, cred, ctx); switch (err) { @@ -4143,8 +4143,7 @@ static int _nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, .rpc_resp = &res, }; - nfs4_bitmap_copy_adjust(bitmask, nfs4_bitmask(server, label), inode); - + nfs4_bitmap_copy_adjust(bitmask, nfs4_bitmask(server, label), inode, 0); nfs_fattr_init(fattr); return nfs4_call_sync(server->client, server, &msg, &args.seq_args, &res.seq_res, 0); } @@ -4732,8 +4731,8 @@ static int _nfs4_proc_link(struct inode *inode, struct inode *dir, const struct } nfs4_inode_make_writeable(inode); - nfs4_bitmap_copy_adjust_setattr(bitmask, nfs4_bitmask(server, res.label), inode); - + nfs4_bitmap_copy_adjust(bitmask, nfs4_bitmask(server, res.label), inode, + NFS_INO_INVALID_CHANGE); status = nfs4_call_sync(server->client, server, &msg, &arg.seq_args, &res.seq_res, 1); if (!status) { update_changeattr(dir, &res.cinfo, res.fattr->time_start, 0); -- 2.50.1