Skip to content

Commit fc513fa

Browse files
Ronnie Sahlbergsmfrench
authored andcommitted
cifs: don't leak -EAGAIN for stat() during reconnect
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 <[email protected]> Signed-off-by: Steve French <[email protected]> Reviewed-by: Pavel Shilovsky <[email protected]> Reviewed-by: Aurelien Aptel <[email protected]> CC: Stable <[email protected]>
1 parent f8788d8 commit fc513fa

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

fs/cifs/inode.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2073,6 +2073,7 @@ int cifs_revalidate_dentry_attr(struct dentry *dentry)
20732073
struct inode *inode = d_inode(dentry);
20742074
struct super_block *sb = dentry->d_sb;
20752075
char *full_path = NULL;
2076+
int count = 0;
20762077

20772078
if (inode == NULL)
20782079
return -ENOENT;
@@ -2094,15 +2095,18 @@ int cifs_revalidate_dentry_attr(struct dentry *dentry)
20942095
full_path, inode, inode->i_count.counter,
20952096
dentry, cifs_get_time(dentry), jiffies);
20962097

2098+
again:
20972099
if (cifs_sb_master_tcon(CIFS_SB(sb))->unix_ext)
20982100
rc = cifs_get_inode_info_unix(&inode, full_path, sb, xid);
20992101
else
21002102
rc = cifs_get_inode_info(&inode, full_path, NULL, sb,
21012103
xid, NULL);
2102-
2104+
if (rc == -EAGAIN && count++ < 10)
2105+
goto again;
21032106
out:
21042107
kfree(full_path);
21052108
free_xid(xid);
2109+
21062110
return rc;
21072111
}
21082112

0 commit comments

Comments
 (0)