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

Karolin Seeger kseeger at samba.org
Mon Mar 13 12:31:02 UTC 2017


The branch, v4-6-test has been updated
       via  1ad29ae lib/pthreadpool: fix a memory leak
       via  68d6aa8 torture3: Add test for smbd crash
       via  ff94f79 smbd: Do an early exit on negprot failure
       via  768acab idmap_autorid: allocate new domain range if the callers knows the sid is valid
      from  074aaeb VERSION: Bump version up to 4.6.1...

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


- Log -----------------------------------------------------------------
commit 1ad29ae69d3463eb92b39c41216bfdc35f232c09
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Mar 9 19:49:56 2017 +0100

    lib/pthreadpool: fix a memory leak
    
    When copying large files from the server to the client with aio enabled
    we noticed that smbd kept growing RSS and VSZ.
    
    valgrind was reporting:
    
    ==2503== 4,093,440 bytes in 6,560 blocks are possibly lost in loss record 460 of 460
    ==2503==    at 0x4C299CE: calloc (vg_replace_malloc.c:711)
    ==2503==    by 0x4011C24: _dl_allocate_tls (in /usr/lib64/ld-2.17.so)
    ==2503==    by 0x4E3C960: pthread_create@@GLIBC_2.2.5 (in /usr/lib64/libpthread-2.17.so)
    ==2503==    by 0x9B298AE: pthreadpool_add_job (in /usr/lib64/samba/libmessages-dgm-samba4.so)
    ==2503==    by 0x9B29FDC: pthreadpool_tevent_job_send (in /usr/lib64/samba/libmessages-dgm-samba4.so)
    ==2503==    by 0x56A78EF: ??? (in /usr/lib64/samba/libsmbd-base-samba4.so)
    ==2503==    by 0x55D86B7: smb_vfs_call_pread_send (in /usr/lib64/samba/libsmbd-base-samba4.so)
    ==2503==    by 0x55F7543: schedule_smb2_aio_read (in /usr/lib64/samba/libsmbd-base-samba4.so)
    ==2503==    by 0x5608F57: smbd_smb2_request_process_read (in /usr/lib64/samba/libsmbd-base-samba4.so)
    ==2503==    by 0x55FCB6C: smbd_smb2_request_dispatch (in /usr/lib64/samba/libsmbd-base-samba4.so)
    ==2503==    by 0x55FD7DC: ??? (in /usr/lib64/samba/libsmbd-base-samba4.so)
    ==2503==    by 0x641B977: ??? (in /usr/lib64/samba/libtevent.so.0.9.31)
    
    The problem seems to be caused by worked threads that are not properly
    started in detached state and thus their tls is not reclaimed upon
    thread termination.
    
    In pthreadpool.c we prepare a pthread attribute with
    PTHREAD_CREATE_DETACHED, but we don't pass it to pthread_create().
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=12624
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    
    Autobuild-User(master): Ralph Böhme <slow at samba.org>
    Autobuild-Date(master): Fri Mar 10 22:06:02 CET 2017 on sn-devel-144
    
    (cherry picked from commit c9a7a065bb5ec09286fef8b52b4fd23a966a94a8)
    
    Autobuild-User(v4-6-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-6-test): Mon Mar 13 13:30:49 CET 2017 on sn-devel-144

commit 68d6aa89e4c0d2abdb0a132d068eb0c71eb42612
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Feb 28 16:17:03 2017 +0100

    torture3: Add test for smbd crash
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12610
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Böhme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Fri Mar  3 06:20:50 CET 2017 on sn-devel-144
    
    (cherry picked from commit a52c7f4d52df6853f925e680eadefcdfdc7bea85)

commit ff94f7972cc3340be79c677768e8b3e5b5603527
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Feb 28 15:03:45 2017 +0000

    smbd: Do an early exit on negprot failure
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12610
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Böhme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit cf9acf9a3da932fca115967eb3d9d9ed48fcbbfc)

commit 768acabb29d47a4eed97b36a0cb552722833cfff
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Mar 6 11:53:09 2017 +0000

    idmap_autorid: allocate new domain range if the callers knows the sid is valid
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12613
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Wed Mar  8 04:06:59 CET 2017 on sn-devel-144
    
    (cherry picked from commit e015748657e9ee755b04f55f088c78bd025378cc)

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

Summary of changes:
 source3/lib/pthreadpool/pthreadpool.c |  2 +-
 source3/smbd/negprot.c                | 21 +++++++---
 source3/torture/torture.c             | 76 +++++++++++++++++++++++++++++++++++
 source3/winbindd/idmap_autorid.c      | 13 ++++++
 4 files changed, 105 insertions(+), 7 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/lib/pthreadpool/pthreadpool.c b/source3/lib/pthreadpool/pthreadpool.c
index eaddd44..f97cdcc 100644
--- a/source3/lib/pthreadpool/pthreadpool.c
+++ b/source3/lib/pthreadpool/pthreadpool.c
@@ -534,7 +534,7 @@ int pthreadpool_add_job(struct pthreadpool *pool, int job_id,
 		return res;
 	}
 
-	res = pthread_create(&thread_id, NULL, pthreadpool_server,
+	res = pthread_create(&thread_id, &thread_attr, pthreadpool_server,
 			     (void *)pool);
 	if (res == 0) {
 		pool->num_threads += 1;
diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c
index cdde334..838ff45 100644
--- a/source3/smbd/negprot.c
+++ b/source3/smbd/negprot.c
@@ -723,17 +723,26 @@ void reply_negprot(struct smb_request *req)
 			break;
 	}
 
-	if(choice != -1) {
-		fstrcpy(remote_proto,supported_protocols[protocol].short_name);
-		reload_services(sconn, conn_snum_used, true);
-		supported_protocols[protocol].proto_reply_fn(req, choice);
-		DEBUG(3,("Selected protocol %s\n",supported_protocols[protocol].proto_name));
-	} else {
+	if (choice == -1) {
+		bool ok;
+
 		DBG_NOTICE("No protocol supported !\n");
 		reply_outbuf(req, 1, 0);
 		SSVAL(req->outbuf, smb_vwv0, choice);
+
+		ok = srv_send_smb(xconn, (char *)req->outbuf,
+				  false, 0, false, NULL);
+		if (!ok) {
+			DBG_NOTICE("srv_send_smb failed\n");
+		}
+		exit_server_cleanly("no protocol supported\n");
 	}
 
+	fstrcpy(remote_proto,supported_protocols[protocol].short_name);
+	reload_services(sconn, conn_snum_used, true);
+	supported_protocols[protocol].proto_reply_fn(req, choice);
+	DEBUG(3,("Selected protocol %s\n",supported_protocols[protocol].proto_name));
+
 	DEBUG( 5, ( "negprot index=%d\n", choice ) );
 
 	/* We always have xconn->smb1.signing_state also for >= SMB2_02 */
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 393d343..754e3b6 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -11017,6 +11017,81 @@ static bool run_local_canonicalize_path(int dummy)
 	return true;
 }
 
+static bool run_ign_bad_negprot(int dummy)
+{
+	struct tevent_context *ev;
+	struct tevent_req *req;
+	struct smbXcli_conn *conn;
+	struct sockaddr_storage ss;
+	NTSTATUS status;
+	int fd;
+	bool ok;
+
+	printf("starting ignore bad negprot\n");
+
+	ok = resolve_name(host, &ss, 0x20, true);
+	if (!ok) {
+		d_fprintf(stderr, "Could not resolve name %s\n", host);
+		return false;
+	}
+
+	status = open_socket_out(&ss, 445, 10000, &fd);
+	if (!NT_STATUS_IS_OK(status)) {
+		d_fprintf(stderr, "open_socket_out failed: %s\n",
+			  nt_errstr(status));
+		return false;
+	}
+
+	conn = smbXcli_conn_create(talloc_tos(), fd, host, SMB_SIGNING_OFF, 0,
+				   NULL, 0);
+	if (conn == NULL) {
+		d_fprintf(stderr, "smbXcli_conn_create failed\n");
+		return false;
+	}
+
+	status = smbXcli_negprot(conn, 0, PROTOCOL_CORE, PROTOCOL_CORE);
+	if (NT_STATUS_IS_OK(status)) {
+		d_fprintf(stderr, "smbXcli_negprot succeeded!\n");
+		return false;
+	}
+
+	ev = samba_tevent_context_init(talloc_tos());
+	if (ev == NULL) {
+		d_fprintf(stderr, "samba_tevent_context_init failed\n");
+		return false;
+	}
+
+	req = smb1cli_session_setup_nt1_send(
+		ev, ev, conn, 0, getpid(), NULL, 65503, 2, 1, 0, "", "",
+		data_blob_null, data_blob_null, 0x40,
+		"Windows 2000 2195", "Windows 2000 5.0");
+	if (req == NULL) {
+		d_fprintf(stderr, "smb1cli_session_setup_nt1_send failed\n");
+		return false;
+	}
+
+	ok = tevent_req_poll_ntstatus(req, ev, &status);
+	if (!ok) {
+		d_fprintf(stderr, "tevent_req_poll failed\n");
+		return false;
+	}
+
+	status = smb1cli_session_setup_nt1_recv(req, NULL, NULL, NULL, NULL,
+						NULL, NULL);
+	if (!NT_STATUS_EQUAL(status, NT_STATUS_CONNECTION_RESET)) {
+		d_fprintf(stderr, "smb1cli_session_setup_nt1_recv returned "
+			  "%s, expected NT_STATUS_CONNECTION_RESET\n",
+			  nt_errstr(status));
+		return false;
+	}
+
+	TALLOC_FREE(conn);
+
+	printf("starting ignore bad negprot\n");
+
+	return true;
+}
+
 static double create_procs(bool (*fn)(int), bool *result)
 {
 	int i, status;
@@ -11206,6 +11281,7 @@ static struct {
 	{ "NOTIFY-BENCH2", run_notify_bench2 },
 	{ "NOTIFY-BENCH3", run_notify_bench3 },
 	{ "BAD-NBT-SESSION", run_bad_nbt_session },
+	{ "IGN-BAD-NEGPROT", run_ign_bad_negprot },
 	{ "SMB-ANY-CONNECT", run_smb_any_connect },
 	{ "NOTIFY-ONLINE", run_notify_online },
 	{ "SMB2-BASIC", run_smb2_basic },
diff --git a/source3/winbindd/idmap_autorid.c b/source3/winbindd/idmap_autorid.c
index 786f839..ab89d35 100644
--- a/source3/winbindd/idmap_autorid.c
+++ b/source3/winbindd/idmap_autorid.c
@@ -636,6 +636,19 @@ static NTSTATUS idmap_autorid_sid_to_id(struct idmap_tdb_common_context *common,
 	}
 
 	/*
+	 * If the caller already did a lookup sid and made sure the
+	 * domain sid is valid, we can allocate a new range.
+	 *
+	 * Currently the winbindd parent already does a lookup sids
+	 * first, but hopefully changes in future. If the
+	 * caller knows the domain sid, ID_TYPE_BOTH should be
+	 * passed instead of ID_TYPE_NOT_SPECIFIED.
+	 */
+	if (map->xid.type != ID_TYPE_NOT_SPECIFIED) {
+		goto allocate;
+	}
+
+	/*
 	 * Check of last resort: A domain is valid if a user from that
 	 * domain has recently logged in. The samlogon_cache these
 	 * days also stores the domain sid.


-- 
Samba Shared Repository



More information about the samba-cvs mailing list