Skip to content

Commit

Permalink
ksmbd: send proper error response in smb2_tree_connect()
Browse files Browse the repository at this point in the history
commit cdfb2fe upstream.

Currently, smb2_tree_connect doesn't send an error response packet on
error.

This causes libsmb2 to skip the specific error code and fail with the
following:
 smb2_service failed with : Failed to parse fixed part of command
 payload. Unexpected size of Error reply. Expected 9, got 8

Signed-off-by: Marios Makassikis <mmakassikis@freebox.fr>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Marios Makassikis authored and gregkh committed Jan 12, 2023
1 parent 4cd4317 commit ad678f3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions fs/ksmbd/smb2pdu.c
Expand Up @@ -1926,13 +1926,13 @@ int smb2_tree_connect(struct ksmbd_work *work)
if (conn->posix_ext_supported)
status.tree_conn->posix_extensions = true;

out_err1:
rsp->StructureSize = cpu_to_le16(16);
inc_rfc1001_len(work->response_buf, 16);
out_err1:
rsp->Capabilities = 0;
rsp->Reserved = 0;
/* default manual caching */
rsp->ShareFlags = SMB2_SHAREFLAG_MANUAL_CACHING;
inc_rfc1001_len(work->response_buf, 16);

if (!IS_ERR(treename))
kfree(treename);
Expand Down Expand Up @@ -1965,6 +1965,9 @@ int smb2_tree_connect(struct ksmbd_work *work)
rsp->hdr.Status = STATUS_ACCESS_DENIED;
}

if (status.ret != KSMBD_TREE_CONN_STATUS_OK)
smb2_set_err_rsp(work);

return rc;
}

Expand Down

0 comments on commit ad678f3

Please sign in to comment.