]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Leave sconn->ev_ctx as NULL for internal fake connections
authorVolker Lendecke <vl@samba.org>
Thu, 12 Feb 2026 19:54:54 +0000 (20:54 +0100)
committerVolker Lendecke <vl@samba.org>
Sun, 1 Mar 2026 20:19:35 +0000 (20:19 +0000)
These connection_structs are only there to access files like msdfs
symlinks or printer driver files. They will never participate in async
processing like sending out events or getting delayed for oplocks. Any
such use is a bug, because if you look at create_conn_struct_tos() we
create an event context that we will never poll on, so events posted
there will never finish. Leave the ev_ctx NULL so that we get an early
crash instead of running into problems later.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source3/rpc_server/mdssvc/mdssvc.c
source3/smbd/msdfs.c
source3/smbd/proto.h

index 0c15f978454299c9563b82548b3060c042d5f667..1e73850ca61523fdb5a044f0d54b9febe22cea18 100644 (file)
@@ -1739,7 +1739,6 @@ NTSTATUS mds_init_ctx(TALLOC_CTX *mem_ctx,
        }
 
        status = create_conn_struct_cwd(mds_ctx,
-                                       ev,
                                        msg_ctx,
                                        session_info,
                                        snum,
index 39a9da5ba4d4a17f3f013e5b589dcca4a57d0932..610ba5e29b9490c7904fc9ed561bcd9da9114d83 100644 (file)
@@ -186,13 +186,13 @@ out:
  SMB_VFS_CONNECT requires root privileges.
 *********************************************************/
 
-static NTSTATUS create_conn_struct_as_root(TALLOC_CTX *ctx,
-                           struct tevent_context *ev,
-                           struct messaging_context *msg,
-                           connection_struct **pconn,
-                           int snum,
-                           const char *path,
-                           const struct auth_session_info *session_info)
+static NTSTATUS create_conn_struct_as_root(
+       TALLOC_CTX *ctx,
+       struct messaging_context *msg,
+       connection_struct **pconn,
+       int snum,
+       const char *path,
+       const struct auth_session_info *session_info)
 {
        connection_struct *conn;
        char *connpath;
@@ -206,7 +206,10 @@ static NTSTATUS create_conn_struct_as_root(TALLOC_CTX *ctx,
                return NT_STATUS_NO_MEMORY;
        }
 
-       sconn->ev_ctx = ev;
+       /*
+        * Leave sconn->ev_ctx as NULL. Trying to run anything async
+        * on a fake is a bug, and we should crash early.
+        */
        sconn->msg_ctx = msg;
 
        conn = conn_new(sconn);
@@ -334,7 +337,6 @@ NTSTATUS create_conn_struct_tos(struct messaging_context *msg,
                                struct conn_struct_tos **_c)
 {
        struct conn_struct_tos *c = NULL;
-       struct tevent_context *ev = NULL;
        NTSTATUS status;
 
        *_c = NULL;
@@ -344,20 +346,9 @@ NTSTATUS create_conn_struct_tos(struct messaging_context *msg,
                return NT_STATUS_NO_MEMORY;
        }
 
-       ev = samba_tevent_context_init(c);
-       if (ev == NULL) {
-               TALLOC_FREE(c);
-               return NT_STATUS_NO_MEMORY;
-       }
-
        become_root();
-       status = create_conn_struct_as_root(c,
-                                           ev,
-                                           msg,
-                                           &c->conn,
-                                           snum,
-                                           path,
-                                           session_info);
+       status = create_conn_struct_as_root(
+               c, msg, &c->conn, snum, path, session_info);
        unbecome_root();
        if (!NT_STATUS_IS_OK(status)) {
                TALLOC_FREE(c);
@@ -440,7 +431,6 @@ NTSTATUS create_conn_struct_tos_cwd(struct messaging_context *msg,
 *********************************************************/
 
 NTSTATUS create_conn_struct_cwd(TALLOC_CTX *mem_ctx,
-                               struct tevent_context *ev,
                                struct messaging_context *msg,
                                const struct auth_session_info *session_info,
                                int snum,
@@ -450,13 +440,8 @@ NTSTATUS create_conn_struct_cwd(TALLOC_CTX *mem_ctx,
        NTSTATUS status;
 
        become_root();
-       status = create_conn_struct_as_root(mem_ctx,
-                                           ev,
-                                           msg,
-                                           c,
-                                           snum,
-                                           path,
-                                           session_info);
+       status = create_conn_struct_as_root(
+               mem_ctx, msg, c, snum, path, session_info);
        unbecome_root();
        return status;
 }
index 2b0902a565df955640f5f0c97bdcbdd5167a0e61..2ee29bf976e703908539a8152c046c4694ea7468 100644 (file)
@@ -506,7 +506,6 @@ NTSTATUS parse_dfs_path_strict(TALLOC_CTX *ctx,
                               char **_remaining_path);
 
 NTSTATUS create_conn_struct_cwd(TALLOC_CTX *mem_ctx,
-                               struct tevent_context *ev,
                                struct messaging_context *msg,
                                const struct auth_session_info *session_info,
                                int snum,