Blame SOURCES/CVE-2020-10730.patch

65e099
From 3bdc110e167d7e0f20022dea48ec51b1f46369cb Mon Sep 17 00:00:00 2001
65e099
From: Gary Lockyer <gary@catalyst.net.nz>
65e099
Date: Wed, 13 May 2020 10:56:56 +1200
65e099
Subject: [PATCH 10/11] CVE-2020-10730: lib ldb: Check if
65e099
 ldb_lock_backend_callback called twice
65e099
65e099
Prevent use after free issues if ldb_lock_backend_callback is called
65e099
twice, usually due to ldb_module_done being called twice. This can happen if a
65e099
module ignores the return value from function a function that calls
65e099
ldb_module_done as part of it's error handling.
65e099
65e099
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14364
65e099
65e099
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
65e099
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
65e099
---
65e099
 lib/ldb/common/ldb.c | 9 ++++++++-
65e099
 1 file changed, 8 insertions(+), 1 deletion(-)
65e099
65e099
diff --git a/lib/ldb/common/ldb.c b/lib/ldb/common/ldb.c
65e099
index 44a487ba987..090d41dde69 100644
65e099
--- a/lib/ldb/common/ldb.c
65e099
+++ b/lib/ldb/common/ldb.c
65e099
@@ -1009,6 +1009,13 @@ static int ldb_lock_backend_callback(struct ldb_request *req,
65e099
 	struct ldb_db_lock_context *lock_context;
65e099
 	int ret;
65e099
 
65e099
+	if (req->context == NULL) {
65e099
+		/*
65e099
+		 * The usual way to get here is to ignore the return codes
65e099
+		 * and continuing processing after an error.
65e099
+		 */
65e099
+		abort();
65e099
+	}
65e099
 	lock_context = talloc_get_type(req->context,
65e099
 				       struct ldb_db_lock_context);
65e099
 
65e099
@@ -1023,7 +1030,7 @@ static int ldb_lock_backend_callback(struct ldb_request *req,
65e099
 		 * If this is a LDB_REPLY_DONE or an error, unlock the
65e099
 		 * DB by calling the destructor on this context
65e099
 		 */
65e099
-		talloc_free(lock_context);
65e099
+		TALLOC_FREE(req->context);
65e099
 		return ret;
65e099
 	}
65e099
 
65e099
-- 
65e099
2.17.1