Skip to content

Commit 3998f0b

Browse files
Ronnie Sahlbergsmfrench
authored andcommitted
cifs: Do not leak EDEADLK to dgetents64 for STATUS_USER_SESSION_DELETED
RHBZ: 1994393 If we hit a STATUS_USER_SESSION_DELETED for the Create part in the Create/QueryDirectory compound that starts a directory scan we will leak EDEADLK back to userspace and surprise glibc and the application. Pick this up initiate_cifs_search() and retry a small number of tries before we return an error to userspace. Cc: [email protected] Reported-by: Xiaoli Feng <[email protected]> Signed-off-by: Ronnie Sahlberg <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 332c404 commit 3998f0b

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

fs/cifs/readdir.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ int get_symlink_reparse_path(char *full_path, struct cifs_sb_info *cifs_sb,
369369
*/
370370

371371
static int
372-
initiate_cifs_search(const unsigned int xid, struct file *file,
372+
_initiate_cifs_search(const unsigned int xid, struct file *file,
373373
const char *full_path)
374374
{
375375
__u16 search_flags;
@@ -451,6 +451,27 @@ initiate_cifs_search(const unsigned int xid, struct file *file,
451451
return rc;
452452
}
453453

454+
static int
455+
initiate_cifs_search(const unsigned int xid, struct file *file,
456+
const char *full_path)
457+
{
458+
int rc, retry_count = 0;
459+
460+
do {
461+
rc = _initiate_cifs_search(xid, file, full_path);
462+
/*
463+
* If we don't have enough credits to start reading the
464+
* directory just try again after short wait.
465+
*/
466+
if (rc != -EDEADLK)
467+
break;
468+
469+
usleep_range(512, 2048);
470+
} while (retry_count++ < 5);
471+
472+
return rc;
473+
}
474+
454475
/* return length of unicode string in bytes */
455476
static int cifs_unicode_bytelen(const char *str)
456477
{

0 commit comments

Comments
 (0)