linux-cifs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cifs: don't leak -EAGAIN for stat() during reconnect
@ 2020-02-18 20:01 Ronnie Sahlberg
  2020-02-18 23:26 ` Steve French
  0 siblings, 1 reply; 8+ messages in thread
From: Ronnie Sahlberg @ 2020-02-18 20:01 UTC (permalink / raw)
  To: linux-cifs; +Cc: Ronnie Sahlberg

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 | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index b5e6635c578e..1212ace05258 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -2073,6 +2073,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;
@@ -2094,15 +2095,18 @@ int cifs_revalidate_dentry_attr(struct dentry *dentry)
 		 full_path, inode, inode->i_count.counter,
 		 dentry, cifs_get_time(dentry), jiffies);
 
+again:
 	if (cifs_sb_master_tcon(CIFS_SB(sb))->unix_ext)
 		rc = cifs_get_inode_info_unix(&inode, full_path, sb, xid);
 	else
 		rc = cifs_get_inode_info(&inode, full_path, NULL, sb,
 					 xid, NULL);
-
+	if (is_retryable_error(rc) && count++ < 10)
+		goto again;
 out:
 	kfree(full_path);
 	free_xid(xid);
+
 	return rc;
 }
 
-- 
2.13.6


^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [PATCH] cifs: don't leak -EAGAIN for stat() during reconnect
@ 2020-02-18  4:48 Ronnie Sahlberg
  2020-02-18 11:47 ` Aurélien Aptel
  0 siblings, 1 reply; 8+ messages in thread
From: Ronnie Sahlberg @ 2020-02-18  4:48 UTC (permalink / raw)
  To: linux-cifs; +Cc: Ronnie Sahlberg

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 | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index b5e6635c578e..1c6f659110d0 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -2073,6 +2073,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;
@@ -2094,15 +2095,18 @@ int cifs_revalidate_dentry_attr(struct dentry *dentry)
 		 full_path, inode, inode->i_count.counter,
 		 dentry, cifs_get_time(dentry), jiffies);
 
+again:
 	if (cifs_sb_master_tcon(CIFS_SB(sb))->unix_ext)
 		rc = cifs_get_inode_info_unix(&inode, full_path, sb, xid);
 	else
 		rc = cifs_get_inode_info(&inode, full_path, NULL, sb,
 					 xid, NULL);
-
+	if (rc == -EAGAIN && count++ < 10)
+		goto again;
 out:
 	kfree(full_path);
 	free_xid(xid);
+
 	return rc;
 }
 
-- 
2.13.6


^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [PATCH 0/1] dont leak -EAGAIN
@ 2020-02-18  4:18 Ronnie Sahlberg
  2020-02-18  4:18 ` [PATCH] cifs: don't leak -EAGAIN for stat() during reconnect Ronnie Sahlberg
  0 siblings, 1 reply; 8+ messages in thread
From: Ronnie Sahlberg @ 2020-02-18  4:18 UTC (permalink / raw)
  To: linux-cifs

Steve, List

Please find a small patch to fix an issue where during a session reconnect we may leak
-EAGAIN back to the application instead of retrying the operation once reconnect has completed.

This can affects for example the stat() call :
  stat("/mnt", 0x55b802c096f8) = -1 EAGAIN (Resource temporarily unavailable) <0.002447>
causing applications such as 'ls' to fail with an error as this is not a valid return
for stat()




^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-02-24 20:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-18 20:01 [PATCH] cifs: don't leak -EAGAIN for stat() during reconnect Ronnie Sahlberg
2020-02-18 23:26 ` Steve French
2020-02-24 19:36   ` Pavel Shilovsky
2020-02-24 20:22     ` Steve French
  -- strict thread matches above, loose matches on Subject: below --
2020-02-18  4:48 Ronnie Sahlberg
2020-02-18 11:47 ` Aurélien Aptel
2020-02-18 19:58   ` ronnie sahlberg
2020-02-18  4:18 [PATCH 0/1] dont leak -EAGAIN Ronnie Sahlberg
2020-02-18  4:18 ` [PATCH] cifs: don't leak -EAGAIN for stat() during reconnect Ronnie Sahlberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).