Skip to content

Commit b90dc5d

Browse files
namjaejeongregkh
authored andcommitted
ksmbd: remove unsafe_memcpy use in session setup
commit d782d6e upstream. Kees pointed out to just use directly ->Buffer instead of pointing ->Buffer using offset not to use unsafe_memcpy(). Suggested-by: Kees Cook <kees@kernel.org> Signed-off-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 107a48d commit b90dc5d

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

fs/smb/server/smb2pdu.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,8 +1345,7 @@ static int ntlm_negotiate(struct ksmbd_work *work,
13451345
return rc;
13461346

13471347
sz = le16_to_cpu(rsp->SecurityBufferOffset);
1348-
chgblob =
1349-
(struct challenge_message *)((char *)&rsp->hdr.ProtocolId + sz);
1348+
chgblob = (struct challenge_message *)rsp->Buffer;
13501349
memset(chgblob, 0, sizeof(struct challenge_message));
13511350

13521351
if (!work->conn->use_spnego) {
@@ -1379,9 +1378,7 @@ static int ntlm_negotiate(struct ksmbd_work *work,
13791378
goto out;
13801379
}
13811380

1382-
sz = le16_to_cpu(rsp->SecurityBufferOffset);
1383-
unsafe_memcpy((char *)&rsp->hdr.ProtocolId + sz, spnego_blob, spnego_blob_len,
1384-
/* alloc is larger than blob, see smb2_allocate_rsp_buf() */);
1381+
memcpy(rsp->Buffer, spnego_blob, spnego_blob_len);
13851382
rsp->SecurityBufferLength = cpu_to_le16(spnego_blob_len);
13861383

13871384
out:
@@ -1463,10 +1460,7 @@ static int ntlm_authenticate(struct ksmbd_work *work,
14631460
if (rc)
14641461
return -ENOMEM;
14651462

1466-
sz = le16_to_cpu(rsp->SecurityBufferOffset);
1467-
unsafe_memcpy((char *)&rsp->hdr.ProtocolId + sz, spnego_blob,
1468-
spnego_blob_len,
1469-
/* alloc is larger than blob, see smb2_allocate_rsp_buf() */);
1463+
memcpy(rsp->Buffer, spnego_blob, spnego_blob_len);
14701464
rsp->SecurityBufferLength = cpu_to_le16(spnego_blob_len);
14711465
kfree(spnego_blob);
14721466
}

0 commit comments

Comments
 (0)