]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ksmbd: send proper error response in smb2_tree_connect()
authorMarios Makassikis <mmakassikis@freebox.fr>
Mon, 18 Dec 2023 15:33:29 +0000 (00:33 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Dec 2023 09:41:53 +0000 (10:41 +0100)
[ Upstream commit cdfb2fef522d0c3f9cf293db51de88e9b3d46846 ]

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>
fs/ksmbd/smb2pdu.c

index 41dd887298a9e1e5bf9b027c0a71ba87c973f6cb..47f919effc1380419e9207043682893c2f53adea 100644 (file)
@@ -1969,13 +1969,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);
@@ -2008,6 +2008,9 @@ out_err1:
                rsp->hdr.Status = STATUS_ACCESS_DENIED;
        }
 
+       if (status.ret != KSMBD_TREE_CONN_STATUS_OK)
+               smb2_set_err_rsp(work);
+
        return rc;
 }