diff mbox series

cifs: don't leak -EAGAIN for stat() during reconnect

Message ID 20200218041842.13986-2-lsahlber@redhat.com (mailing list archive)
State New, archived
Headers show
Series cifs: don't leak -EAGAIN for stat() during reconnect | expand

Commit Message

Ronnie Sahlberg Feb. 18, 2020, 4:18 a.m. UTC
If from cifs_revalidate_dentry_attr() the SMB2/QUERY_INFO call fails with an
error, such as STATUS_SESSION_EXPIRED, causing the session to be reconnected
it is possible we will leak -EAGAIN back to the application even for
system calls such as stat() where this is not a valid error.

Fix this by re-trying the operation from within cifs_revalidate_dentry_attr()
if cifs_get_inode_info*() returns -EAGAIN.

This fixes stat() and possibly also other system calls that uses
cifs_revalidate_dentry*().

Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
 fs/cifs/inode.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index b5e6635c578e..cf36dcd9dafd 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -2073,7 +2073,9 @@  int cifs_revalidate_dentry_attr(struct dentry *dentry)
 	struct inode *inode = d_inode(dentry);
 	struct super_block *sb = dentry->d_sb;
 	char *full_path = NULL;
+	int count = 0;
 
+again:
 	if (inode == NULL)
 		return -ENOENT;
 
@@ -2099,6 +2101,8 @@  int cifs_revalidate_dentry_attr(struct dentry *dentry)
 	else
 		rc = cifs_get_inode_info(&inode, full_path, NULL, sb,
 					 xid, NULL);
+	if (rc == -EAGAIN && count++ < 10)
+		goto again;
 
 out:
 	kfree(full_path);