Linux-CIFS Archive on lore.kernel.org
 help / color / Atom feed
* [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; 2+ 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] 2+ messages in thread

* [PATCH] cifs: don't leak -EAGAIN for stat() during reconnect
  2020-02-18  4:18 [PATCH 0/1] dont leak -EAGAIN Ronnie Sahlberg
@ 2020-02-18  4:18 ` Ronnie Sahlberg
  0 siblings, 0 replies; 2+ messages in thread
From: Ronnie Sahlberg @ 2020-02-18  4:18 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 | 4 ++++
 1 file changed, 4 insertions(+)

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);
-- 
2.13.6


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

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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

Linux-CIFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-cifs/0 linux-cifs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-cifs linux-cifs/ https://lore.kernel.org/linux-cifs \
		linux-cifs@vger.kernel.org
	public-inbox-index linux-cifs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-cifs


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git