1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00
Commit Graph

403 Commits

Author SHA1 Message Date
Stefan Metzmacher
333707fa37 s3:smbd: move smbXsrv_{session,tcon,open} tables to smbXsrv_client
These should be per client (based on the SMB >= 2.1 client_guid),
this is a preparation for multi-channel support.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-09-19 09:15:12 +02:00
Stefan Metzmacher
e2af19a5d8 s3:smb2_server: use xconn->client->sconn in smbd_smb2_request_next_incoming()
xconn->sconn will go away soon.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-09-19 09:15:12 +02:00
Stefan Metzmacher
4bece82dd6 s3:smb2_server: use xconn->client->sconn in smbd_smb2_request_create()
xconn->sconn will go away soon.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-09-19 09:15:12 +02:00
Stefan Metzmacher
fe00c8e436 s3:smb2_server: use xconn->client->sconn in smbd_smb2_first_negprot()
xconn->sconn will go away soon.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-09-19 09:15:12 +02:00
Stefan Metzmacher
b970db154a s3:smb2_server: use xconn->client->sconn in smbd_smb2_io_handler()
xconn->sconn will go away soon.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-09-19 09:15:12 +02:00
Stefan Metzmacher
7e006d1113 s3:smb2_server: use the global signing key to check if signing is required
If we have a channel session key, we also always have a global session key.

For multi-channel it's possible that the channel session key is not in place
yet, in that case the global session key needs to be used.

In both cases (reauth or session bind) we session setup requests need to be
signed.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-09-19 09:15:10 +02:00
Stefan Metzmacher
3805249deb s3:smb2_server: pass smbXsrv_connection to smbd_smb2_send_break()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:14 +02:00
Stefan Metzmacher
d9716cb0db s3:smb2_server: propagate NTSTATUS from smb2_sendfile_send_data() to smbd_smb2_flush_send_queue()
Calling exit_server() from within a destructor is a bit ugly...

This will result in smbd_server_connection_terminate() instead of
directly calling exit_server(), which will be useful for multi-channel in
future.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:14 +02:00
Stefan Metzmacher
888ddd171a s3:smb2_negprot: remove NBT_HDR_SIZE from smbd_smb2_first_negprot()
This will simplify future features like multi-channel and rdma.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:13 +02:00
Stefan Metzmacher
4a07b14cea s3:smb2_server: pass smbXsrv_connection to smbd_server_connection_terminate*()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:13 +02:00
Stefan Metzmacher
b7eeb658e7 s3:smb2_server: use req->xconn in is_smb2_recvfile_write()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:13 +02:00
Stefan Metzmacher
b76cd04469 s3:smb2_server: remove unused 'sconn' from smbd_smb2_send_break_state
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:13 +02:00
Stefan Metzmacher
4faec1ea91 s3:smb2_server: use req->xconn in smbd_smb2_request_error_ex()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:13 +02:00
Stefan Metzmacher
7ee78c78e0 s3:smb2_server: use req->xconn in smbd_smb2_request_dispatch()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:13 +02:00
Stefan Metzmacher
0e2cf47a99 s3:smb2_server: use req->xconn in smbd_smb2_request_verify_creditcharge()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:13 +02:00
Stefan Metzmacher
323fe07f72 s3:smb2_server: use req->xconn in smbd_smb2_request_check_session()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:13 +02:00
Stefan Metzmacher
65ad96a841 s3:smb2_server: use req->xconn in smbd_smb2_request_process_cancel()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:13 +02:00
Stefan Metzmacher
cedf403bcf s3:smb2_server: remove unused 'sconn' from smbd_smb2_request_pending_state
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:13 +02:00
Stefan Metzmacher
a319b89687 s3:smb2_server: talloc smbd_smb2_request_pending_state on smbXsrv_connection
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:12 +02:00
Stefan Metzmacher
c02afe66eb s3:smb2_server: use req->xconn in smbd_smb2_request_setup_out()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:12 +02:00
Stefan Metzmacher
1ac9e52aae s3:smb2_server: pass smbXsrv_connection to smbd_smb2_request_next_incoming()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:12 +02:00
Stefan Metzmacher
90b27f1559 s3:smb2_server: pass smbXsrv_connection to smbd_smb2_request_create()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:12 +02:00
Stefan Metzmacher
694c048bbd s3:smb2_server: pass smbXsrv_connection to smbd_initialize_smb2()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:12 +02:00
Stefan Metzmacher
3a622c785c s3:smb2_server: pass smbXsrv_connection to smbd_smb2_first_negprot()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:12 +02:00
Stefan Metzmacher
bfc702b9a0 s3:smb2_server: pass smbXsrv_connection to smb2_set_operation_credit()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:12 +02:00
Stefan Metzmacher
f3b24168f9 s3:smb2_server: pass smbXsrv_connection to smb2_validate_message_id()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:12 +02:00
Stefan Metzmacher
aaa072a1f3 s3:smb2_server: pass smbXsrv_connection to smb2_validate_sequence_number()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:12 +02:00
Stefan Metzmacher
330febb7df s3:smb2_server: pass smbXsrv_connection to smbd_smb2_flush_send_queue()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:12 +02:00
Stefan Metzmacher
d1d3294cea s3:smb2_server: rename 'conn' variables to 'xconn'
This makes the code more consistent with other functions
using 'struct smbXsrv_connection *xconn' as local variables.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:12 +02:00
Stefan Metzmacher
59a25a6067 s3:smb2_server: pass smbXsrv_connection to fd handlers
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:12 +02:00
Stefan Metzmacher
39f5566092 s3:smb2_server: remember smbXsrv_connection for each smbd_smb2_request
This prepares the structures for multi-channel support.
Each request needs to respond on the same connection,
where it arrived.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:12 +02:00
Stefan Metzmacher
b38cb03ab6 s3:smb2_server: talloc smbd_smb2_request as child of smbXsrv_connection
As the list of pending requests moved from sconn->smb2.requests to xconn->smb2.requests,
it is more logical to use smbXsrv_connection as talloc parent.

This prepares the structures for multi-channel support.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:11 +02:00
Stefan Metzmacher
92e96bedfb s3:smb2_server: move sconn->smb2.requests to xconn->smb2.requests
This prepares the structures for multi-channel support.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:11 +02:00
Stefan Metzmacher
36e3484260 s3:smb2_server: move sconn->smb2.*credits* to xconn->smb2.credits.*
This prepares the structures for multi-channel support.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:11 +02:00
Stefan Metzmacher
e644406bcd s3:smb2_server: move sconn->smb2.send_queue* to xconn->smb2.send_queue*
This prepares the structures for multi-channel support.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:11 +02:00
Stefan Metzmacher
f9ef2a5850 s3:smb2_server: move sconn->smb2.request_read_state to xconn->smb2.request_read_state
This prepares the structures for multi-channel support.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:11 +02:00
Stefan Metzmacher
3e236983df s3:smb2_server: use xconn->transport.fde also for smb2
This prepares the structures for multi-channel support.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:11 +02:00
Stefan Metzmacher
b05b4cab25 s3:smbd: move sconn->status to xconn->transport.status
This prepares the structures for multi-channel support.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:11 +02:00
Stefan Metzmacher
9557ac4b46 s3:smbd: move sconn->smb1.fde to xconn->transport.fde
This prepares the structures for multi-channel support.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:11 +02:00
Stefan Metzmacher
0ccffffe07 s3:smbd: move sconn->sock to xconn->transport.sock
This prepares the structures for multi-channel support.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:11 +02:00
Volker Lendecke
5f3a765672 smbd: Factor out smbd_smb2_send_break
Most of this routine can be re-used for sending lease breaks

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Tue Jul  8 19:54:09 CEST 2014 on sn-devel-104
2014-07-08 19:54:09 +02:00
Volker Lendecke
afb2b64e75 smbd: Rename smbd_smb2_send_oplock_break_state->buf to ->body
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-07-08 17:28:11 +02:00
Volker Lendecke
0d4bf9150f smbd: no "dyn" in smbd_smb2_send_oplock_break
We don't need the assignment to state->vector[1+SMBD_SMB2_DYN_IOV_OFS],
this is zero-initialized by talloc_zero

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-07-08 17:28:11 +02:00
Volker Lendecke
b7fe854140 smbd: Make hdr a field of its own in smbd_smb2_send_oplock_break
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-07-08 17:28:11 +02:00
Volker Lendecke
49de2e9df6 smbd: Make tf a field of its own in smbd_smb2_send_oplock_break
This actually saves a few bytes in .text. Maybe due to the struct assignments?

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-07-08 17:28:11 +02:00
Volker Lendecke
6fcc4f8aeb smbd: Make nbt_hdr a field of its own in smbd_smb2_send_oplock_break
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-07-08 17:28:11 +02:00
Jeremy Allison
37b4c9e08f s3: smb2 - Negprot should return INVALID_PARAMETER if flags2 signed bit is set.
MS-SMB2: 3.3.5.2.4 Verifying the Signature.
If the SMB2 header of the SMB2 NEGOTIATE
request has the SMB2_FLAGS_SIGNED bit set in the
Flags field, the server MUST fail the request
with STATUS_INVALID_PARAMETER.

Found and fix confirmed by Microsoft test tool.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ira Cooper <ira@samba.org>
2014-06-18 07:15:13 +02:00
Stefan Metzmacher
51077c6be6 s3:smb2_server: call smbd_smb2_flush_send_queue() directly
This avoids recursion into smbd_smb2_io_handler(),
which avoids confusion when analysing out put of
performance analysing tools, e.g. callgrind.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sat May 31 04:25:36 CEST 2014 on sn-devel-104
2014-05-31 04:25:36 +02:00
Stefan Metzmacher
629f4e8769 s3:smb2_server: fix invalid TALLOC_FREE(iov) in smbd_smb2_inbuf_parse_compound()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-05-31 01:59:18 +02:00
Stefan Metzmacher
e49bae7ac9 s3:smb2_server: remove unused get_min_receive_file_size() wrapper function
smb2req always comes from talloc_zero().

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri Apr 11 23:55:17 CEST 2014 on sn-devel-104
2014-04-11 23:55:17 +02:00
Stefan Metzmacher
535103e7a3 s3:smb2_server: only allocate the required buffer in the smb2 recvfile() code path
This way the buffer will likely be allocated within the existing talloc_pool,
which avoids one malloc() per request.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-04-11 21:41:08 +02:00
Stefan Metzmacher
80de72bb57 s3:smb2_server: prepare smbd_smb2_request_verify_sizes() for the optimized recvfile() case
For recvfile we haven't read and may not allocated the dyn buffer.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-04-11 21:41:08 +02:00
Stefan Metzmacher
95df39b99f s3:smb2_server: make sure we don't try recvfile for special NBT messages
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-04-11 21:41:08 +02:00
Stefan Metzmacher
796874912d s3:smb2_server: use the same logic to avoid recvfile() for IPC/PRINT shares
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-04-11 21:41:08 +02:00
Stefan Metzmacher
986935854f s3:smb2_server: avoid talloc_zero_array() in smbd_smb2_request_setup_out()
In the common case with just one request, we can use a preallocated
req->out.vector.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Mar  6 00:59:29 CET 2014 on sn-devel-104
2014-03-06 00:59:29 +01:00
Stefan Metzmacher
cf77f16e3a s3:smb2_server: don't assume that req->out.vector is always a valid talloc pointer
We use 'req' instead as it has the same lifetime.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-03-05 13:59:23 -08:00
Stefan Metzmacher
2edc7308d6 s3:smb2_server: avoid talloc_zero_array() in smbd_smb2_request_error_ex()
It is only important that the content of info->data stays alive
for the lifetime of the request, but the DATA_BLOB structure itself
can be on the stack, while passing it as 'dyn' to smbd_smb2_request_done_ex().

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-03-05 13:59:22 -08:00
Stefan Metzmacher
adaf517c87 s3:smb2_server: optimize smbd_smb2_generate_outbody() for the common case
Use a preallocated buffer for the first response in the compound chain.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-03-05 13:59:22 -08:00
Stefan Metzmacher
fd4c82f6f5 s3:smb2_server: add smbd_smb2_generate_outbody() helper
We can add optimization there later.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-03-05 13:59:20 -08:00
Stefan Metzmacher
a6ce8001b4 s3:smb2_read: avoid 2 talloc* calls when using sendfile()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-03-05 13:59:20 -08:00
Stefan Metzmacher
0ac924b2bb s3:smb2_server: avoid a call to data_blob_clear_free() if not needed
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-03-05 13:59:20 -08:00
Stefan Metzmacher
ec498a2414 s3:smb2_server: optimize smbd_smb2_request_setup_out()
We can use a preallocated buffer for the possible error
response of the first response in the compound chain.

This avoids a talloc_array_zero() call for the common case.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-03-05 13:59:20 -08:00
Stefan Metzmacher
66877dfaa5 s3:smb2_server: optimize req->in.vector allocation
We can avoid a talloc_zero_array() call in the
common case (without compound requests) and use a
preallocated array instead.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-03-05 13:59:20 -08:00
Stefan Metzmacher
52ccb40d59 s3:smbd: maintain smbd_server_connection->status
If this isn't NT_STATUS_OK, we skip any io on the socket.

This avoids possible problems during shutdown.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2014-02-21 11:48:12 +01:00
Volker Lendecke
f25e2b93d3 smbd: Fix CID 1138328 Logically dead code
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2013-12-17 01:57:13 +01:00
Stefan Metzmacher
3cc0651d9f s3:smb2_server: avoid calling set_current_user_info() for each request
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>

Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Wed Nov 27 16:31:44 CET 2013 on sn-devel-104
2013-11-27 16:31:44 +01:00
Stefan Metzmacher
36efaac259 s3:smb2_server: generate a header blob for the sendfile path
We need to pass the NBT header, SMB2 header and SMB2 Read header
as header blob to SMB_VFS_SENDFILE(). This allows the usage
of MSG_SEND or other tricks to avoid multiple TCP packets
on the wire.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
2013-11-27 14:39:11 +01:00
Stefan Metzmacher
9d33a3f3e8 s3:smb2_server: allocate smbd_smb2_request on talloc_tos()
This matches the behavior for smb1 requests
and avoids an additional malloc() per request.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
2013-11-27 14:39:10 +01:00
Stefan Metzmacher
acfd4b068a s3:smb2_server: use tevent_req_notify_callback() in smbd_smb2_request_pending_queue()
If the request is already done we can avoid one iteration
of tevent_loop_once(), which means we avoids one
talloc_stackframe_pool/talloc_free pair.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
2013-11-27 14:39:10 +01:00
Stefan Metzmacher
4244a2686c s3:smb2_server: for performance reasons we use tevent_fd and readv/writev directly
Going via tevent_req_create/talloc_free at multiple layer costs
too much cpu cycles per request.

I tested downloading a 16GB (sparse) file with smbclient -b1 -mNT1,
and -mSMB2_02. Using smb2 max read = 64512, which means smb1 and smb2
will use the same read size.

I build with -O3 -g and compared the results with valgrind --tool=callgrind.

With -mNT1 the server uses about 2.000.000.000 cpu cycles.

This patch reduces the userspace cpu cycles for -mSMB2_02
from about ~ 8.000.000.000 down to ~ 4.000.000.000.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
2013-11-27 14:39:10 +01:00
Stefan Metzmacher
9393e28df5 s3:smb2_server: fix drain_socket error handling
smbd_smb2_request_error_ex() should return NTSTATUS and the caller
will terminate the connection.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
2013-11-27 14:39:10 +01:00
Michael Adam
c3a5fecdc1 smbd:smb2: fix error code when the header says the request is signed but we don't have a sesseion
I.e. when the request is a session setup.
We replied with ACCESS_DENIED, but windows expects USER_SESSION_DELETED

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>

Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Wed Oct  2 22:07:44 CEST 2013 on sn-devel-104
2013-10-02 22:07:44 +02:00
Stefan Metzmacher
4a7b792bc6 s3:smb2_server: don't rely on the SMB2_HDR_FLAG_SIGNED if signing is required
Windows (at least the test suites) may skip the SMB2_HDR_FLAG_SIGNED
in a reauth session setup, but still provide a valid signature.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2013-10-02 15:11:22 +02:00
Richard Sharpe
bea2af9369 Revert my accidental commit.
Signed-off-by: Richard Sharpe <rsharpe@samba.org>

Autobuild-User(master): Richard Sharpe <sharpe@samba.org>
Autobuild-Date(master): Thu May 23 06:53:17 CEST 2013 on sn-devel-104
2013-05-23 06:53:17 +02:00
Richard Sharpe
27df444d0b Make sure that if an smbd is exiting because of an error we let the user know.
Signed-off-by: Richard Sharpe <realrichardsharpe@gmail.com>
2013-05-21 23:16:59 -07:00
Jeremy Allison
cbff488550 Remove the compound_related_in_progress state from the smb2 global state.
And also remove the restriction that we can't read a new
request whilst we're in this state.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Richard Sharpe <realrichardsharpe@samba.org>
2013-05-07 17:58:45 +02:00
Jeremy Allison
10cbcfd167 The core of the fix to allow opens to go async inside a compound request.
This is only allowed for opens that cause an oplock break, otherwise it
is not allowed. See [MS-SMB2].pdf note <194> on Section 3.3.5.2.7.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>
2013-05-07 17:58:45 +02:00
Jeremy Allison
1102e73832 Move a variable into the area of code where it's used.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>
2013-05-07 17:58:45 +02:00
Jeremy Allison
a026fc6b69 Ensure we don't try and cancel anything that is in a compound-related request.
Too hard to deal with splitting off the replies.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>
2013-05-07 17:58:45 +02:00
Jeremy Allison
1a7cec37e7 Add the internals of is_smb2_recvfile_write.
This turns on the real receivefile detection, and completes
the receivefile code path changes.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan (metze) Metzmacher <metze@samba.org>
2013-04-19 14:11:19 -07:00
Jeremy Allison
53b87f2fba The guts of the receivefile code changes.
If an incoming PDU might qualify, only read
SMBD_SMB2_SHORT_RECEIVEFILE_WRITE_LEN = (SMB2_HEADER + SMB2_WRITE_BODY_LEN)
bytes rather than the whole PDU.

Next time we're called, use is_smb2_recvfile_write() to decide if
this is an SMB2_WRITE that fit the receivefile criteria, otherwise
just read the rest of the PDU.

If we did do a short receivefile read, set up the smb2_req->smb1req->unread_bytes
value to show what bytes remain in the TCP buffers.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan (metze) Metzmacher <metze@samba.org>
2013-04-19 14:11:15 -07:00
Jeremy Allison
fdcaf0fa36 Add stub static function that will turn on/off receivefile code path.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan (metze) Metzmacher <metze@samba.org>
2013-04-19 14:11:11 -07:00
Jeremy Allison
4b91097002 Add extra fields into struct smbd_smb2_request_read_state to support receivefile.
Initialize min_recv_size with the size that will trigger the
receivefile write path.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan (metze) Metzmacher <metze@samba.org>
2013-04-19 14:11:07 -07:00
Jeremy Allison
61da7f00b3 Add utility function get_min_receive_file_size().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan (metze) Metzmacher <metze@samba.org>
2013-04-19 14:11:00 -07:00
Jeremy Allison
63739440f1 Allow smbd_smb2_request_error_ex() to cope with unread bytes on error.
Drain the socket if a RECVFILE write failed.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan (metze) Metzmacher <metze@samba.org>
2013-04-19 14:10:55 -07:00
Jeremy Allison
5530cc4816 Fix bad SMB2 opcode reading in server.
SMB2 opcodes are 16-bit values. We should *never*
be reading them with IVAL(inhdr, SMB2_HDR_OPCODE),
it should always be SVAL(inhdr, SMB2_HDR_OPCODE).

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>

Autobuild-User(master): Richard Sharpe <sharpe@samba.org>
Autobuild-Date(master): Tue Apr  2 07:28:48 CEST 2013 on sn-devel-104
2013-04-02 07:28:48 +02:00
Karolin Seeger
92e17d5fd0 smb2_server: Fix typo in comment.
Karolin

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Fri Nov  2 15:40:22 CET 2012 on sn-devel-104
2012-11-02 15:40:22 +01:00
Michael Adam
73fa347507 s3:smbd:smb2: fix a comment typo in the crediting code.
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>

Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Fri Nov  2 10:09:36 CET 2012 on sn-devel-104
2012-11-02 10:09:36 +01:00
Jeremy Allison
c2f5b2466b Fix bug #9214 - Bad user supplied SMB2 credit value can cause smbd to call smb_panic.
Terminate the connection cleanly instead.
2012-10-03 12:49:15 -07:00
Stefan Metzmacher
9249871f40 s3:smb2_server: avoid segfault in smbd_smb2_request_pending_queue()
Because we should not call smbd_smb2_request_error() on an
request that is still running.

If the subreq implementes a cancel function, this should
take care of triggering smbd_smb2_request_error.

metze

Signed-off-by: Michael Adam <obnox@samba.org>
2012-09-22 10:18:58 +02:00
Michael Adam
1ae6f9c626 s3:smbd:smb2: simplify smbd_smb2_request_validate() and smbd_smb2_request_dispatch()
removes unnneccary checks/assignments for compound_related and next_status
and duplicate setting of error status.

And remove (now) unused next_status from struct smbd_smb2_request.

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
2012-09-22 10:18:58 +02:00
Michael Adam
27d38b5c27 s3:smbd:smb2: add check for session_status for compound requests 2012-09-22 10:18:57 +02:00
Stefan Metzmacher
4384485f82 s3:smb2_server: do the req->next_status check before the signing checks
Windows 2012 returns NT_STATUS_INVALID_PARAMETER to
the smb2.compound.invalid1 test if that uses signing
(instead of NT_STATUS_ACCESS_DENIED).

metze
2012-09-22 10:18:57 +02:00
Stefan Metzmacher
2552b66323 s3:smb2_server: reset req->last_session_id and req->last_tid after using it
If we can find a valid session or tcon we'll set it after the lookup,
but it need to make sure to reset it if we don't find the session.

This fixes a problem where a compound unrelated request between
related requests doesn't reset the session.

If we have 3 requests in a compound chain, request 3 should never
use the id's cached from request 1. It should only every inherit
handles from request 2.

metze
2012-09-22 10:18:57 +02:00
Ira Cooper
7595194619 s3: Compound requests should continue processing.
This patch addresses #9173.

Signed-off-by: Michael Adam <obnox@samba.org>
2012-09-22 10:18:56 +02:00
Stefan Metzmacher
bc77745cfa s3:smb2_server: fix usage of invalid memory in smb2_signing_check_pdu()
metze

Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Thu Sep 20 07:18:31 CEST 2012 on sn-devel-104
2012-09-20 07:18:31 +02:00
Stefan Metzmacher
069db9b630 s3:smb2_break: encrypt OPLOCK BREAK notifications
metze

Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Thu Aug 23 10:01:14 CEST 2012 on sn-devel-104
2012-08-23 10:01:14 +02:00
Stefan Metzmacher
54dfd08cb2 s3:smb2_server: use smbXsrv_session->nonce_*
metze
2012-08-23 08:23:07 +02:00
Stefan Metzmacher
6c7ffa9092 s3:smb2_server: remove dump_data() from smbd_smb2_request_pending_timer()
This was just for debugging...

metze
2012-08-23 08:23:07 +02:00
Stefan Metzmacher
9397d6709f s3:smb2_server: add SMB3 encryption support
metze
2012-08-17 14:51:57 +02:00
Stefan Metzmacher
16edb6eb7b s3:smb2_server: try to sign an error response if we have a signing key
metze

Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Fri Aug 17 00:54:01 CEST 2012 on sn-devel-104
2012-08-17 00:54:01 +02:00
Stefan Metzmacher
19ca98a162 s3:smb2_server: verify the signature before the session_status
metze
2012-08-16 23:13:07 +02:00
Stefan Metzmacher
f4432fea6a s3:smb2_server: add some const to print_req_vectors()
metze
2012-08-16 23:13:07 +02:00
Stefan Metzmacher
b596a116fd s3:smb2_server: do calculations based on SMBD_SMB2_NUM_IOV_PER_REQ in smbd_smb2_request_validate()
metze
2012-08-15 14:45:04 +02:00
Stefan Metzmacher
a0cf42b709 s3:smb2_server: add smbd_smb2_request->do_encryption
For now it's always false...

metze
2012-08-09 08:21:35 +02:00
Stefan Metzmacher
b5a72f4f35 s3:smb2_server: check the session before we could response with an error.
metze
2012-08-09 08:21:35 +02:00
Stefan Metzmacher
f15d9a6670 s3:smb2_server: do central file_id check if the operation requires it
Note that it's fine to call file_fsp_smb2() twice, the 2nd call
just returns smb2req->compat_chain_fsp without a 2nd lookup.

metze
2012-08-09 08:21:35 +02:00
Stefan Metzmacher
1c76e99ae4 s3:smb2_server: s/i/idx in smbd_smb2_request_pending_queue()
metze

Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Wed Aug  8 17:32:26 CEST 2012 on sn-devel-104
2012-08-08 17:32:26 +02:00
Stefan Metzmacher
83d262088b s3:smb2_server: make use of SMBD_SMB2_OUT_HDR_PTR() in smbd_smb2_request_pending_queue()
metze
2012-08-08 12:52:52 +02:00
Stefan Metzmacher
0067de2074 s3:smb2_server: remove useless variable 'i'
metze
2012-08-08 12:52:51 +02:00
Stefan Metzmacher
63d92a192d s3:smb2_server: rewrite dup_smb2_vec3() using SMBD_SMB2_*_IOV_OFS and helper variables
metze
2012-08-08 12:52:51 +02:00
Stefan Metzmacher
fc8e3bd569 s3:smb2_server: make use of SMBD_SMB2_* macros in smbd_smb2_request_done_ex()
metze
2012-08-08 12:52:51 +02:00
Stefan Metzmacher
97b5aaa648 s3:smb2_server: make use of SMBD_SMB2_* macros in smbd_smb2_request_verify_sizes()
metze
2012-08-08 12:52:50 +02:00
Stefan Metzmacher
05ae95a0d5 s3:smb2_server: use the common buffer layout for smbd_smb2_request_pending*
metze
2012-08-08 12:52:50 +02:00
Stefan Metzmacher
9f51d610d2 s3:smb2_server: don't try to update req->in.vector[0] in smbd_smb2_request_pending_queue()
req->in.vector[0] is reserved for the transport and might be removed in future.
This is currently always { NULL, 0 }, as it's not used, by our
transport layer code. The SMB2 layer should never touch this!

metze
2012-08-08 12:50:22 +02:00
Stefan Metzmacher
c9ecfd6f3d s3:smb2_server: sign the last request at the start of smbd_smb2_request_reply()
This means we correctly sign all responses in a compound chain.

metze
2012-08-08 05:13:42 +02:00
Stefan Metzmacher
c3016915a1 s3:smb2_server: fix SMB2 signing of compound responses
We need to defer the signing until we know the response
doesn't change anymore before it goes over the wire.

metze

Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Tue Aug  7 20:29:30 CEST 2012 on sn-devel-104
2012-08-07 20:29:30 +02:00
Stefan Metzmacher
40f771e010 s3:smb2_server: there's no need to copy req->out.vector when we just keep the last request
metze
2012-08-07 18:32:47 +02:00
Stefan Metzmacher
8d63efe273 s3:smb2_server: use memmove instead of copying single vector elements
metze
2012-08-07 18:32:47 +02:00
Stefan Metzmacher
9b8973d3b5 s3:smb2_server: make use of SMBD_SMB2_OUT_HDR_PTR() smbd_smb2_request_pending_queue()
metze
2012-08-07 18:32:46 +02:00
Stefan Metzmacher
bfc87a4a76 s3:smb2_server: check for compound based on SMBD_SMB2_NUM_IOV_PER_REQ
metze
2012-08-07 18:32:46 +02:00
Stefan Metzmacher
5730272690 s3:smb2_server: make use of SMBD_SMB2_OUT_*_IOV smbd_smb2_request_reply()
metze
2012-08-07 18:32:46 +02:00
Stefan Metzmacher
727b1d1fa8 s3:smb2_server: check for compound based on SMBD_SMB2_NUM_IOV_PER_REQ
metze
2012-08-07 18:32:45 +02:00
Stefan Metzmacher
2da62179de s3:smb2_server: make use of SMBD_SMB2_*_IOV_OFS
metze
2012-08-07 18:32:45 +02:00
Stefan Metzmacher
d609bb9b42 s3:smb2_server: make use of helper macros in smb2_calculate_credits()
metze
2012-08-07 18:32:45 +02:00
Stefan Metzmacher
efaea8e0e1 s3:smb2_server: make use of helper macros in smbd_smb2_request_validate()
metze
2012-08-07 18:32:45 +02:00
Stefan Metzmacher
4e6e1ecb6e s3:smb2_server: make use of SMBD_SMB2_NUM_IOV_PER_REQ
metze
2012-08-07 18:32:44 +02:00
Stefan Metzmacher
e7bf8e7e23 s3:smb2_server: do one central as_root check if the operation requires it
metze

Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Tue Aug  7 13:14:38 CEST 2012 on sn-devel-104
2012-08-07 13:14:38 +02:00
Stefan Metzmacher
eec941e411 s3:smb2_server: do one central tcon check if the operation requires it
metze
2012-08-07 11:16:37 +02:00
Stefan Metzmacher
59b9dfa0cb s3:smb2_server: do one central session check if the operation requires it
metze
2012-08-07 11:16:37 +02:00
Stefan Metzmacher
aba6df9f55 s3:smb2_server: add and use smbd_smb2_call()
metze
2012-08-07 11:16:37 +02:00
Stefan Metzmacher
e01333242f s3:smb2_server: add .as_root to smbd_smb2_dispatch_table
metze
2012-08-07 11:16:36 +02:00
Stefan Metzmacher
f69ed57d0f s3:smb2_server: add .need_tcon to smbd_smb2_dispatch_table
metze
2012-08-07 11:16:36 +02:00
Stefan Metzmacher
46f7a60e78 s3:smb2_server: add .need_session to smbd_smb2_dispatch_table
metze
2012-08-07 11:16:36 +02:00
Stefan Metzmacher
357110c10b s3:smb2_server: introduce a smbd_smb2_dispatch_table (for now just with names)
metze
2012-08-07 11:16:36 +02:00
Stefan Metzmacher
5ac4d3d274 s3:smb2_server: move 'conn' to main block of smbd_smb2_request_dispatch()
metze
2012-08-07 11:16:36 +02:00
Stefan Metzmacher
721096b1ad s3:smb2_server: make use of smbd_smb2_inbuf_parse_compound() in smbd_smb2_request_read*()
This changes the way we read SMB2 traffic from the socket,
now as create just one large buffer for the whole NBT payload
and then split it into iovec elements in smbd_smb2_inbuf_parse_compound()

metze

Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Mon Aug  6 21:54:35 CEST 2012 on sn-devel-104
2012-08-06 21:54:35 +02:00
Stefan Metzmacher
fbd663c143 s3:smb2_server: make use of smbd_smb2_inbuf_parse_compound() in smbd_smb2_request_create()
metze
2012-08-06 20:02:32 +02:00
Stefan Metzmacher
9e9d784def s3:smb2_server: remove const from smbd_smb2_first_negprot()
metze
2012-08-06 20:02:32 +02:00
Stefan Metzmacher
c1b3454259 s3:smb2_server: add smbd_smb2_inbuf_parse_compound()
metze
2012-08-06 20:02:32 +02:00
Stefan Metzmacher
4384b1e73b s3:smb2_server: make use of SMBD_SMB2_* macros
metze
2012-08-05 20:55:41 +02:00
Stefan Metzmacher
7327310754 s3:smb2_server: use 'i' instead of '1' as vector index in smbd_smb2_request_pending_timer()
If we reach this code i is currently always 1, but it's easier to unstand this
way.

metze

Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Sun Aug  5 20:00:26 CEST 2012 on sn-devel-104
2012-08-05 20:00:26 +02:00
Stefan Metzmacher
c66a45d3f2 s3:smb2_server: simplify the talloc_pool handling for smbd_smb2_request
metze
2012-07-25 12:15:01 +02:00
Volker Lendecke
abda9d3347 s3: Fix Coverity ID 709217 Dereference after null check
A few lines before we did check for x != NULL. I think this might
fix a potential remote crash.

Signed-off-by: Michael Adam <obnox@samba.org>

Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Tue Jul  3 15:30:17 CEST 2012 on sn-devel-104
2012-07-03 15:30:16 +02:00
Michael Adam
bfc38d74cc s3:smbd:smb2: change smbXsrv_tcon0 to smbXsrv_tcon in smbd_smb2_request_check_tcon()
smbXsrv_tcon0 is the internal name for the (current) version0 of the
structure. Externally, only smbXsrv_tcon should be used.
2012-07-03 13:39:40 +02:00
Stefan Metzmacher
1a622fe641 s3:smb2_server: remove max_charge check in smbd_smb2_request_verify_creditcharge()
The client can send any credit charge value, it's ok to send more than needed.

metze

Signed-off-by: Michael Adam <obnox@samba.org>
2012-06-29 15:21:08 +02:00
Stefan Metzmacher
34a9892ec1 s3:smb2_server: make the logic in smbd_smb2_request_verify_creditcharge() simpler
We just need a max_charge variable to make the algorithm independent
of multi_credit support.

metze
2012-06-29 00:14:56 +02:00
Stefan Metzmacher
967f2c44b3 s3:smb2_server: simplify smbd_smb2_request_verify_creditcharge() a bit.
A credit charge of 0 is really not a special case, it just means the same
as 1.

metze
2012-06-29 00:14:56 +02:00
Stefan Metzmacher
1db83d2b37 s3:smb2_server: grant extra credits for multi-credit requests
metze
2012-06-29 00:14:55 +02:00
Stefan Metzmacher
648b959b13 s3:smb2_server: implement credit granting similar to windows
This makes it much easier to compare traces.

metze
2012-06-29 00:14:55 +02:00