Skip to content

Commit a19f316

Browse files
z00467499gregkh
authored andcommitted
ksmbd: Fix wrong return value and message length check in smb2_ioctl()
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>
1 parent 39b6855 commit a19f316

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

fs/ksmbd/smb2pdu.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7617,11 +7617,16 @@ int smb2_ioctl(struct ksmbd_work *work)
76177617
goto out;
76187618
}
76197619

7620-
if (in_buf_len < sizeof(struct validate_negotiate_info_req))
7621-
return -EINVAL;
7620+
if (in_buf_len < offsetof(struct validate_negotiate_info_req,
7621+
Dialects)) {
7622+
ret = -EINVAL;
7623+
goto out;
7624+
}
76227625

7623-
if (out_buf_len < sizeof(struct validate_negotiate_info_rsp))
7624-
return -EINVAL;
7626+
if (out_buf_len < sizeof(struct validate_negotiate_info_rsp)) {
7627+
ret = -EINVAL;
7628+
goto out;
7629+
}
76257630

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

0 commit comments

Comments
 (0)