Patch "NFSv4: nfs_atomic_open() can race when looking up a non-regular file" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    NFSv4: nfs_atomic_open() can race when looking up a non-regular file

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     nfsv4-nfs_atomic_open-can-race-when-looking-up-a-non.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit b5f93faf85c022030412ee6bfb928b60025634dd
Author: Trond Myklebust <trond.myklebust@xxxxxxxxxxxxxxx>
Date:   Thu Jan 6 18:24:03 2022 -0500

    NFSv4: nfs_atomic_open() can race when looking up a non-regular file
    
    [ Upstream commit 1751fc1db36f6f411709e143d5393f92d12137a9 ]
    
    If the file type changes back to being a regular file on the server
    between the failed OPEN and our LOOKUP, then we need to re-run the OPEN.
    
    Fixes: 0dd2b474d0b6 ("nfs: implement i_op->atomic_open()")
    Signed-off-by: Trond Myklebust <trond.myklebust@xxxxxxxxxxxxxxx>
    Signed-off-by: Anna Schumaker <Anna.Schumaker@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 4ef392c42ec8a..a23b7a5dec9ee 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1782,12 +1782,17 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry,
 		if ((lookup_flags & LOOKUP_DIRECTORY) && inode &&
 		    !S_ISDIR(inode->i_mode))
 			res = ERR_PTR(-ENOTDIR);
+		else if (inode && S_ISREG(inode->i_mode))
+			res = ERR_PTR(-EOPENSTALE);
 	} else if (!IS_ERR(res)) {
 		inode = d_inode(res);
 		if ((lookup_flags & LOOKUP_DIRECTORY) && inode &&
 		    !S_ISDIR(inode->i_mode)) {
 			dput(res);
 			res = ERR_PTR(-ENOTDIR);
+		} else if (inode && S_ISREG(inode->i_mode)) {
+			dput(res);
+			res = ERR_PTR(-EOPENSTALE);
 		}
 	}
 	if (switched) {



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux