The branch, master has been updated
       via  12f516e4680 rpc_server3: Fix a memleak for internal pipes
       via  481176ec745 spools: avoid leaking memory into the callers mem_ctx
       via  4c3fb2a5912 pidl: set the per-request memory context in the pidl 
generator
      from  10d753868e8 s3: smbd: fix deferred renames

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 12f516e4680753460e7fe8811e6c6ff70057580c
Author: Volker Lendecke <[email protected]>
Date:   Tue Mar 23 17:06:15 2021 +0100

    rpc_server3: Fix a memleak for internal pipes
    
    state->call should not be talloc'ed off a long-lived context
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14675
    CI: https://gitlab.com/samba-team/samba/-/merge_requests/1861
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Samuel Cabrero <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>
    
    Autobuild-User(master): Ralph Böhme <[email protected]>
    Autobuild-Date(master): Wed Mar 31 12:14:01 UTC 2021 on sn-devel-184

commit 481176ec745c14b78fca68e01a61c83405a4b97b
Author: Ralph Boehme <[email protected]>
Date:   Mon Mar 22 12:06:39 2021 +0100

    spools: avoid leaking memory into the callers mem_ctx
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14675
    CI: https://gitlab.com/samba-team/samba/-/merge_requests/1861
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Volker Lendecke <[email protected]>

commit 4c3fb2a5912966a61e7ebdb05eb3231a0e1d6033
Author: Ralph Boehme <[email protected]>
Date:   Tue Mar 23 11:40:21 2021 +0100

    pidl: set the per-request memory context in the pidl generator
    
    The talloc memory context referenced by the pipe_struct mem_ctx member is 
used
    as talloc parent for RPC response data by the RPC service implementations.
    
    In Samba versions up to 4.10 all talloc children of p->mem_ctx were freed 
after
    a RPC response was delivered by calling talloc_free_children(p->mem_ctx). 
Commit
    60fa8e255254d38e9443bf96f2c0f31430be6ab8 removed this call which resulted 
in all
    memory allocations on this context not getting released, which can consume
    significant memory in long running RPC connections.
    
    Instead of putting the talloc_free_children(p->mem_ctx) back, just use the
    mem_ctx argument of the ${pipename}_op_dispatch_internal() function which 
is a
    dcesrv_call_state object created by dcesrv_process_ncacn_packet() and 
released
    by the RPC server when the RPC request processing is finished.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14675
    CI: https://gitlab.com/samba-team/samba/-/merge_requests/1861
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Volker Lendecke <[email protected]>

-----------------------------------------------------------------------

Summary of changes:
 pidl/lib/Parse/Pidl/Samba4/NDR/ServerCompat.pm | 2 ++
 source3/rpc_server/rpc_handles.c               | 6 ------
 source3/rpc_server/rpc_ncacn_np.c              | 2 +-
 source3/rpc_server/spoolss/srv_spoolss_nt.c    | 6 ++++--
 4 files changed, 7 insertions(+), 9 deletions(-)


Changeset truncated at 500 lines:

diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/ServerCompat.pm 
b/pidl/lib/Parse/Pidl/Samba4/NDR/ServerCompat.pm
index 54feea0a9ef..d1368c3dbca 100644
--- a/pidl/lib/Parse/Pidl/Samba4/NDR/ServerCompat.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/NDR/ServerCompat.pm
@@ -299,6 +299,7 @@ sub boilerplate_iface($)
        $self->pidl("/* Update pipes struct opnum */");
        $self->pidl("p->opnum = opnum;");
        $self->pidl("p->dce_call = dce_call;");
+       $self->pidl("p->mem_ctx = mem_ctx;");
        $self->pidl("/* Update pipes struct session info */");
        $self->pidl("pipe_session_info = p->session_info;");
        $self->pidl("p->session_info = dce_call->auth_state->session_info;");
@@ -344,6 +345,7 @@ sub boilerplate_iface($)
        $self->pidl("");
 
        $self->pidl("p->dce_call = NULL;");
+       $self->pidl("p->mem_ctx = NULL;");
        $self->pidl("/* Restore session info */");
        $self->pidl("p->session_info = pipe_session_info;");
        $self->pidl("p->auth.auth_type = 0;");
diff --git a/source3/rpc_server/rpc_handles.c b/source3/rpc_server/rpc_handles.c
index 45968746440..9ef93231466 100644
--- a/source3/rpc_server/rpc_handles.c
+++ b/source3/rpc_server/rpc_handles.c
@@ -60,12 +60,6 @@ int make_base_pipes_struct(TALLOC_CTX *mem_ctx,
                return ENOMEM;
        }
 
-       p->mem_ctx = talloc_named(p, 0, "pipe %s %p", pipe_name, p);
-       if (!p->mem_ctx) {
-               talloc_free(p);
-               return ENOMEM;
-       }
-
        p->msg_ctx = msg_ctx;
        p->transport = transport;
 
diff --git a/source3/rpc_server/rpc_ncacn_np.c 
b/source3/rpc_server/rpc_ncacn_np.c
index 598efd1f339..8cd84fee8b4 100644
--- a/source3/rpc_server/rpc_ncacn_np.c
+++ b/source3/rpc_server/rpc_ncacn_np.c
@@ -475,7 +475,7 @@ static struct tevent_req 
*rpcint_bh_raw_call_send(TALLOC_CTX *mem_ctx,
                return tevent_req_post(req, ev);
        }
 
-       state->call = talloc_zero(hs->conn, struct dcesrv_call_state);
+       state->call = talloc_zero(state, struct dcesrv_call_state);
        if (tevent_req_nomem(state->call, req)) {
                return tevent_req_post(req, ev);
        }
diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.c 
b/source3/rpc_server/spoolss/srv_spoolss_nt.c
index c60f91b5581..1ccfd11ff7e 100644
--- a/source3/rpc_server/spoolss/srv_spoolss_nt.c
+++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c
@@ -5731,7 +5731,8 @@ static WERROR 
construct_printer_driver_info_level(TALLOC_CTX *mem_ctx,
        }
 
        if (pinfo2->drivername == NULL || pinfo2->drivername[0] == '\0') {
-               return WERR_UNKNOWN_PRINTER_DRIVER;
+               result = WERR_UNKNOWN_PRINTER_DRIVER;
+               goto done;
        }
 
        DBG_INFO("Construct printer driver [%s] for [%s]\n",
@@ -7023,7 +7024,8 @@ static WERROR update_printer(struct pipes_struct *p,
                raddr = tsocket_address_inet_addr_string(p->remote_address,
                                                         p->mem_ctx);
                if (raddr == NULL) {
-                       return WERR_NOT_ENOUGH_MEMORY;
+                       result = WERR_NOT_ENOUGH_MEMORY;
+                       goto done;
                }
 
                /* add_printer_hook() will call reload_services() */


-- 
Samba Shared Repository

Reply via email to