cifs: don't call cifs_dfs_query_info_nonascii_quirk() if nodfs was set

Also return EOPNOTSUPP if path is remote but nodfs was set.

Fixes: a2809d0e16 ("cifs: quirk for STATUS_OBJECT_NAME_INVALID returned for non-ASCII dfs refs")
Cc: stable@vger.kernel.org
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Signed-off-by: Enzo Matsumiya <ematsumiya@suse.de>
Signed-off-by: Steve French <stfrench@microsoft.com>
This commit is contained in:
Enzo Matsumiya 2022-05-18 13:31:55 -03:00 committed by Steve French
parent d80c69846d
commit 421ef3d565
1 changed files with 12 additions and 4 deletions

View File

@ -3432,6 +3432,7 @@ static int is_path_remote(struct mount_ctx *mnt_ctx)
struct cifs_tcon *tcon = mnt_ctx->tcon; struct cifs_tcon *tcon = mnt_ctx->tcon;
struct smb3_fs_context *ctx = mnt_ctx->fs_ctx; struct smb3_fs_context *ctx = mnt_ctx->fs_ctx;
char *full_path; char *full_path;
bool nodfs = cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_DFS;
if (!server->ops->is_path_accessible) if (!server->ops->is_path_accessible)
return -EOPNOTSUPP; return -EOPNOTSUPP;
@ -3449,14 +3450,20 @@ static int is_path_remote(struct mount_ctx *mnt_ctx)
rc = server->ops->is_path_accessible(xid, tcon, cifs_sb, rc = server->ops->is_path_accessible(xid, tcon, cifs_sb,
full_path); full_path);
#ifdef CONFIG_CIFS_DFS_UPCALL #ifdef CONFIG_CIFS_DFS_UPCALL
if (nodfs) {
if (rc == -EREMOTE)
rc = -EOPNOTSUPP;
goto out;
}
/* path *might* exist with non-ASCII characters in DFS root
* try again with full path (only if nodfs is not set) */
if (rc == -ENOENT && is_tcon_dfs(tcon)) if (rc == -ENOENT && is_tcon_dfs(tcon))
rc = cifs_dfs_query_info_nonascii_quirk(xid, tcon, cifs_sb, rc = cifs_dfs_query_info_nonascii_quirk(xid, tcon, cifs_sb,
full_path); full_path);
#endif #endif
if (rc != 0 && rc != -EREMOTE) { if (rc != 0 && rc != -EREMOTE)
kfree(full_path); goto out;
return rc;
}
if (rc != -EREMOTE) { if (rc != -EREMOTE) {
rc = cifs_are_all_path_components_accessible(server, xid, tcon, rc = cifs_are_all_path_components_accessible(server, xid, tcon,
@ -3468,6 +3475,7 @@ static int is_path_remote(struct mount_ctx *mnt_ctx)
} }
} }
out:
kfree(full_path); kfree(full_path);
return rc; return rc;
} }