Skip to content

Commit

Permalink
ksmbd: Fix wrong return value and message length check in smb2_ioctl()
Browse files Browse the repository at this point in the history
commit b1763d2 upstream.

Commit c7803b0 ("smb3: fix ksmbd bigendian bug in oplock
break, and move its struct to smbfs_common") use the defination
of 'struct validate_negotiate_info_req' in smbfs_common, the
array length of 'Dialects' changed from 1 to 4, but the protocol
does not require the client to send all 4. This lead the request
which satisfied with protocol and server to fail.

So just ensure the request payload has the 'DialectCount' in
smb2_ioctl(), then fsctl_validate_negotiate_info() will use it
to validate the payload length and each dialect.

Also when the {in, out}_buf_len is less than the required, should
goto out to initialize the status in the response header.

Fixes: f7db8fd ("ksmbd: add validation in smb2_ioctl")
Cc: stable@vger.kernel.org
Signed-off-by: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>
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
z00467499 authored and gregkh committed Oct 21, 2022
1 parent 7df7cc5 commit f287d4b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions fs/ksmbd/smb2pdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -7637,11 +7637,16 @@ int smb2_ioctl(struct ksmbd_work *work)
goto out;
}

if (in_buf_len < sizeof(struct validate_negotiate_info_req))
return -EINVAL;
if (in_buf_len < offsetof(struct validate_negotiate_info_req,
Dialects)) {
ret = -EINVAL;
goto out;
}

if (out_buf_len < sizeof(struct validate_negotiate_info_rsp))
return -EINVAL;
if (out_buf_len < sizeof(struct validate_negotiate_info_rsp)) {
ret = -EINVAL;
goto out;
}

ret = fsctl_validate_negotiate_info(conn,
(struct validate_negotiate_info_req *)&req->Buffer[0],
Expand Down

0 comments on commit f287d4b

Please sign in to comment.