[SCM] Samba Shared Repository - branch v4-17-test updated

Jule Anger janger at samba.org
Fri Jan 27 09:46:01 UTC 2023


The branch, v4-17-test has been updated
       via  ddf64adea13 s3/lib: Prevent use after free of messaging_ctdb_fde_ev structs
      from  e12898ff72c VERSION: Bump version up to Samba 4.17.6...

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-17-test


- Log -----------------------------------------------------------------
commit ddf64adea1358f0effb2148a03acfa5bb66cf1ea
Author: Noel Power <noel.power at suse.com>
Date:   Wed Jan 25 17:03:07 2023 +0000

    s3/lib: Prevent use after free of messaging_ctdb_fde_ev structs
    
    In a cluster setup samba-bgqd async callback
    cups_pcap_load_async can access messaging_ctdb_fde_ev associated
    with already destructed global_ctdb_ctx_destructor
    
    ==26053== Invalid read of size 8
    ==26053==    at 0x71692E1: messaging_ctdb_fde_ev_destructor (messages_ctdb.c:181)
    ==26053==    by 0x40B2309: _tc_free_internal (talloc.c:1158)
    ==26053==    by 0x40B3539: _tc_free_children_internal (talloc.c:1669)
    ==26053==    by 0x40B24C4: _tc_free_internal (talloc.c:1184)
    ==26053==    by 0x40B3539: _tc_free_children_internal (talloc.c:1669)
    ==26053==    by 0x40B24C4: _tc_free_internal (talloc.c:1184)
    ==26053==    by 0x40B2685: _talloc_free_internal (talloc.c:1248)
    ==26053==    by 0x40B3963: _talloc_free (talloc.c:1792)
    ==26053==    by 0x4056BCA: tevent_req_received (tevent_req.c:301)
    ==26053==    by 0x405673D: tevent_req_destructor (tevent_req.c:135)
    ==26053==    by 0x40B2309: _tc_free_internal (talloc.c:1158)
    ==26053==    by 0x40B3539: _tc_free_children_internal (talloc.c:1669)
    ==26053==    by 0x40B24C4: _tc_free_internal (talloc.c:1184)
    ==26053==    by 0x40B2685: _talloc_free_internal (talloc.c:1248)
    ==26053==    by 0x40B3963: _talloc_free (talloc.c:1792)
    ==26053==    by 0x1384EF: cups_pcap_load_async (print_cups.c:507)
    ==26053==    by 0x13894B: cups_cache_reload (print_cups.c:602)
    ==26053==    by 0x1373AE: pcap_cache_reload (pcap.c:140)
    ==26053==    by 0x1369D2: register_printing_bq_handlers (queue_process.c:323)
    ==26053==    by 0x122AD6: main (samba-bgqd.c:316)
    ==26053==  Address 0xed64d48 is 120 bytes inside a block of size 128 free'd
    ==26053==    at 0x4C370EB: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==26053==    by 0x40B25E1: _tc_free_internal (talloc.c:1222)
    ==26053==    by 0x40B2685: _talloc_free_internal (talloc.c:1248)
    ==26053==    by 0x40B3963: _talloc_free (talloc.c:1792)
    ==26053==    by 0x71691F6: messaging_ctdb_destroy (messages_ctdb.c:141)
    ==26053==    by 0x7169C21: msg_ctdb_ref_destructor (messages_ctdb_ref.c:142)
    ==26053==    by 0x40B2309: _tc_free_internal (talloc.c:1158)
    ==26053==    by 0x40B3539: _tc_free_children_internal (talloc.c:1669)
    ==26053==    by 0x40B24C4: _tc_free_internal (talloc.c:1184)
    ==26053==    by 0x40B2685: _talloc_free_internal (talloc.c:1248)
    ==26053==    by 0x40B3963: _talloc_free (talloc.c:1792)
    ==26053==    by 0x4157380: messaging_reinit (messages.c:646)
    ==26053==    by 0x416C01E: reinit_after_fork (util.c:488)
    ==26053==    by 0x13844C: cups_pcap_load_async (print_cups.c:498)
    ==26053==    by 0x13894B: cups_cache_reload (print_cups.c:602)
    ==26053==    by 0x1373AE: pcap_cache_reload (pcap.c:140)
    ==26053==    by 0x1369D2: register_printing_bq_handlers (queue_process.c:323)
    ==26053==    by 0x122AD6: main (samba-bgqd.c:316)
    ==26053==  Block was alloc'd at
    ==26053==    at 0x4C346A4: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==26053==    by 0x40B1989: __talloc_with_prefix (talloc.c:783)
    ==26053==    by 0x40B1B23: __talloc (talloc.c:825)
    ==26053==    by 0x40B1ECC: _talloc_named_const (talloc.c:982)
    ==26053==    by 0x40B49C3: _talloc_zero (talloc.c:2421)
    ==26053==    by 0x7168E68: messaging_ctdb_init (messages_ctdb.c:93)
    ==26053==    by 0x716979D: messaging_ctdb_ref (messages_ctdb_ref.c:75)
    ==26053==    by 0x415702A: messaging_init_internal (messages.c:563)
    ==26053==    by 0x41572FD: messaging_init (messages.c:622)
    ==26053==    by 0x4163ED3: global_messaging_context (global_contexts.c:62)
    ==26053==    by 0x12273B: main (samba-bgqd.c:271)
    ==26053==
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=15293
    
    Signed-off-by: Noel Power <npower at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    (cherry picked from commit 7a880ef52dfc85ed2f674250b5baf5109f8d4691)
    
    Autobuild-User(v4-17-test): Jule Anger <janger at samba.org>
    Autobuild-Date(v4-17-test): Fri Jan 27 09:45:10 UTC 2023 on sn-devel-184

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

Summary of changes:
 source3/lib/messages_ctdb.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)


Changeset truncated at 500 lines:

diff --git a/source3/lib/messages_ctdb.c b/source3/lib/messages_ctdb.c
index 3e784bf7237..d55b53bf601 100644
--- a/source3/lib/messages_ctdb.c
+++ b/source3/lib/messages_ctdb.c
@@ -76,6 +76,21 @@ static int messaging_ctdb_recv(
 
 struct messaging_ctdb_context *global_ctdb_context;
 
+static int global_ctdb_ctx_destructor(struct messaging_ctdb_context *ctx)
+{
+	if (ctx != NULL) {
+		struct messaging_ctdb_fde_ev *fde_ev = NULL;
+		for (fde_ev = ctx->fde_evs;
+		     fde_ev != NULL;
+		     fde_ev = fde_ev->next) {
+			if (fde_ev->ctx == ctx) {
+				fde_ev->ctx = NULL;
+			}
+		}
+	}
+	return 0;
+}
+
 int messaging_ctdb_init(const char *sockname, int timeout, uint64_t unique_id,
 			void (*recv_cb)(struct tevent_context *ev,
 					const uint8_t *msg, size_t msg_len,
@@ -94,6 +109,10 @@ int messaging_ctdb_init(const char *sockname, int timeout, uint64_t unique_id,
 	if (ctx == NULL) {
 		return ENOMEM;
 	}
+
+	talloc_set_destructor(ctx,
+			      global_ctdb_ctx_destructor);
+
 	ctx->recv_cb = recv_cb;
 	ctx->recv_cb_private_data = private_data;
 


-- 
Samba Shared Repository



More information about the samba-cvs mailing list