]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: implement session check from MS-SMB2 3.3.5.9 Receiving an SMB2 CREATE Request
authorRalph Boehme <slow@samba.org>
Thu, 10 Jul 2025 14:48:22 +0000 (16:48 +0200)
committerRalph Boehme <slow@samba.org>
Tue, 5 Aug 2025 14:52:34 +0000 (14:52 +0000)
If the server implements the SMB 3.x dialect family and all of the following conditions are TRUE, the
server MUST look up an Open in GlobalOpenTable where Open.IsReplayEligible is TRUE and
Open.CreateGuid matches the CreateGuid in the SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2
create context and Open.ClientGuid matches the ClientGuid of the connection that received this
request:

...

If an Open is found, the server MUST perform the following:

...

If Open.Session.SessionId is not equal to the current Session.SessionId, the server MUST fail
the request with STATUS_DUPLICATE_OBJECTID.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
selftest/knownfail.d/samba3.smb2.replay
source3/smbd/smb2_create.c
source3/smbd/smbXsrv_open.c
source3/smbd/smbXsrv_open.h

index c1d524dbe2e6211a32ac3782603e8d2873a290b7..e2c3d908539c3e2df2b65803b0c2ef7973731e52 100644 (file)
@@ -1,4 +1,3 @@
 ^samba3.smb2.replay.durable-reconnect-replay1\(nt4_dc\)
-^samba3.smb2.replay.durable-reconnect-replay2\(nt4_dc\)
 ^samba3.smb2.replay.durable-reconnect-replay3\(nt4_dc\)
 ^samba3.smb2.replay.replay-twice-durable\(nt4_dc\)
index 8412622e6cbbc127decfe9ad09171d5eb2b3bbff..f6b49a0f96bbb4f312a82b87c83f99422a63bd54 100644 (file)
@@ -1453,6 +1453,7 @@ static void smbd_smb2_cc_before_exec_dhc2q(struct tevent_req *req)
        }
 
        status = smb2srv_open_lookup_replay_cache(smb2req->xconn,
+                                                 smb2req->session,
                                                  *state->create_guid,
                                                  state->fname,
                                                  now,
index cd85440e909f8dd36615d03bfb09bd4003c6c0cb..fabd8aff889e28312da0b8b8b1d287a4fe9831a8 100644 (file)
@@ -1121,6 +1121,7 @@ NTSTATUS smb2srv_open_lookup(struct smbXsrv_connection *conn,
  * retry loop on the client.
  */
 NTSTATUS smb2srv_open_lookup_replay_cache(struct smbXsrv_connection *conn,
+                                         struct smbXsrv_session *session,
                                          struct GUID create_guid,
                                          const char *name,
                                          NTTIME now,
@@ -1221,8 +1222,13 @@ NTSTATUS smb2srv_open_lookup_replay_cache(struct smbXsrv_connection *conn,
                                           now,
                                           &op);
        if (NT_STATUS_IS_OK(status)) {
+               if (op->session->global->session_global_id !=
+                   session->global->session_global_id)
+               {
+                       TALLOC_FREE(frame);
+                       return NT_STATUS_DUPLICATE_OBJECTID;
+               }
                DBG_DEBUG("Found local open\n");
-
                /*
                 * We found an open the caller can reuse.
                 */
index 72752967a7877c0aac6debf1cef0bd76d1091185..d6d0ed35105021a3541c338e2d058b2c91e151fc 100644 (file)
@@ -54,6 +54,7 @@ NTSTATUS smb2srv_open_lookup(struct smbXsrv_connection *conn,
 NTSTATUS smbXsrv_open_purge_replay_cache(struct smbXsrv_client *client,
                                         const struct GUID *create_guid);
 NTSTATUS smb2srv_open_lookup_replay_cache(struct smbXsrv_connection *conn,
+                                         struct smbXsrv_session *session,
                                          struct GUID create_guid,
                                          const char *name,
                                          NTTIME now,