blob: 219476cecdfa48e27ed0dbb9c03d0d06c2710e6b [file] [log] [blame]
From a3f54a11d0484d028f3ff3c5211ebf446b0552c3 Mon Sep 17 00:00:00 2001
From: Ronnie Sahlberg <>
Date: Wed, 19 Feb 2020 06:01:03 +1000
Subject: [PATCH] cifs: don't leak -EAGAIN for stat() during reconnect
commit fc513fac56e1b626ae48a74d7551d9c35c50129e upstream.
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
Signed-off-by: Ronnie Sahlberg <>
Signed-off-by: Steve French <>
Reviewed-by: Pavel Shilovsky <>
Reviewed-by: Aurelien Aptel <>
CC: Stable <>
Signed-off-by: Paul Gortmaker <>
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 2887009aca32..7e35b2560e79 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -2003,6 +2003,7 @@ 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;
if (inode == NULL)
return -ENOENT;
@@ -2024,15 +2025,18 @@ int cifs_revalidate_dentry_attr(struct dentry *dentry)
full_path, inode, inode->i_count.counter,
dentry, cifs_get_time(dentry), jiffies);
if (cifs_sb_master_tcon(CIFS_SB(sb))->unix_ext)
rc = cifs_get_inode_info_unix(&inode, full_path, sb, xid);
rc = cifs_get_inode_info(&inode, full_path, NULL, sb,
xid, NULL);
+ if (rc == -EAGAIN && count++ < 10)
+ goto again;
return rc;