Skip to content

Commit c119f4e

Browse files
namjaejeonsmfrench
authored andcommitted
ksmbd: fix slab-out-of-bounds in smb2_allocate_rsp_buf
If ->ProtocolId is SMB2_TRANSFORM_PROTO_NUM, smb2 request size validation could be skipped. if request size is smaller than sizeof(struct smb2_query_info_req), slab-out-of-bounds read can happen in smb2_allocate_rsp_buf(). This patch allocate response buffer after decrypting transform request. smb3_decrypt_req() will validate transform request size and avoid slab-out-of-bound in smb2_allocate_rsp_buf(). Reported-by: Norbert Szetei <[email protected]> Cc: [email protected] Signed-off-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 0bbac3f commit c119f4e

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

fs/smb/server/server.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,20 +167,17 @@ static void __handle_ksmbd_work(struct ksmbd_work *work,
167167
int rc;
168168
bool is_chained = false;
169169

170-
if (conn->ops->allocate_rsp_buf(work))
171-
return;
172-
173170
if (conn->ops->is_transform_hdr &&
174171
conn->ops->is_transform_hdr(work->request_buf)) {
175172
rc = conn->ops->decrypt_req(work);
176-
if (rc < 0) {
177-
conn->ops->set_rsp_status(work, STATUS_DATA_ERROR);
178-
goto send;
179-
}
180-
173+
if (rc < 0)
174+
return;
181175
work->encrypted = true;
182176
}
183177

178+
if (conn->ops->allocate_rsp_buf(work))
179+
return;
180+
184181
rc = conn->ops->init_rsp_hdr(work);
185182
if (rc) {
186183
/* either uid or tid is not correct */

0 commit comments

Comments
 (0)