Commit b6cce493 authored by Ross Lagerwall's avatar Ross Lagerwall Committed by Khalid Elmously

cifs: Check uniqueid for SMB2+ and return -ESTALE if necessary

BugLink: https://bugs.launchpad.net/bugs/1848780

[ Upstream commit a108471b ]

Commit 7196ac11 ("Fix to check Unique id and FileType when client
refer file directly.") checks whether the uniqueid of an inode has
changed when getting the inode info, but only when using the UNIX
extensions. Add a similar check for SMB2+, since this can be done
without an extra network roundtrip.
Signed-off-by: default avatarRoss Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: default avatarSteve French <smfrench@gmail.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarConnor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent b9423cfe
...@@ -829,8 +829,21 @@ cifs_get_inode_info(struct inode **inode, const char *full_path, ...@@ -829,8 +829,21 @@ cifs_get_inode_info(struct inode **inode, const char *full_path,
} }
} else } else
fattr.cf_uniqueid = iunique(sb, ROOT_I); fattr.cf_uniqueid = iunique(sb, ROOT_I);
} else {
if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) &&
validinum == false && server->ops->get_srv_inum) {
/*
* Pass a NULL tcon to ensure we don't make a round
* trip to the server. This only works for SMB2+.
*/
tmprc = server->ops->get_srv_inum(xid,
NULL, cifs_sb, full_path,
&fattr.cf_uniqueid, data);
if (tmprc)
fattr.cf_uniqueid = CIFS_I(*inode)->uniqueid;
} else } else
fattr.cf_uniqueid = CIFS_I(*inode)->uniqueid; fattr.cf_uniqueid = CIFS_I(*inode)->uniqueid;
}
/* query for SFU type info if supported and needed */ /* query for SFU type info if supported and needed */
if (fattr.cf_cifsattrs & ATTR_SYSTEM && if (fattr.cf_cifsattrs & ATTR_SYSTEM &&
...@@ -871,6 +884,13 @@ cifs_get_inode_info(struct inode **inode, const char *full_path, ...@@ -871,6 +884,13 @@ cifs_get_inode_info(struct inode **inode, const char *full_path,
} else { } else {
/* we already have inode, update it */ /* we already have inode, update it */
/* if uniqueid is different, return error */
if (unlikely(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM &&
CIFS_I(*inode)->uniqueid != fattr.cf_uniqueid)) {
rc = -ESTALE;
goto cgii_exit;
}
/* if filetype is different, return error */ /* if filetype is different, return error */
if (unlikely(((*inode)->i_mode & S_IFMT) != if (unlikely(((*inode)->i_mode & S_IFMT) !=
(fattr.cf_mode & S_IFMT))) { (fattr.cf_mode & S_IFMT))) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment