Blame SOURCES/0108-NSS-nss_clear_netgroup_hash_table-do-not-free-data.patch

ab1ddb
From d92cb9cb3860d7ff1b3ab64b459edf6051f69291 Mon Sep 17 00:00:00 2001
ab1ddb
From: Sumit Bose <sbose@redhat.com>
ab1ddb
Date: Fri, 4 May 2018 17:00:55 +0200
ab1ddb
Subject: [PATCH] NSS: nss_clear_netgroup_hash_table() do not free data
ab1ddb
MIME-Version: 1.0
ab1ddb
Content-Type: text/plain; charset=UTF-8
ab1ddb
Content-Transfer-Encoding: 8bit
ab1ddb
ab1ddb
nss_clear_netgroup_hash_table() is called during the clearEnumCache SBUS
ab1ddb
request, which is e.g. used during 'sss_cache -E', to remove netgroup
ab1ddb
data cached in the memory of the NSS responder.
ab1ddb
ab1ddb
Currently nss_clear_netgroup_hash_table() calls
ab1ddb
'sss_ptr_hash_delete_all(nss_ctx->netgrent, true);' which not only
ab1ddb
removes all entries in the 'netgerent' hash table but frees them as
ab1ddb
well.
ab1ddb
ab1ddb
The second step is not needed because nss_setnetgrent_set_timeout()
ab1ddb
takes care that the data is freed after a timeout. Additionally freeing
ab1ddb
the data in nss_clear_netgroup_hash_table() can even do harm when the
ab1ddb
request is received by the NSS responder while waiting for the backend
ab1ddb
to acquire the netgroup data. Because if the backend is done the NSS
ab1ddb
responder tries do use enum_ctx which might have been freed in the
ab1ddb
meantime.
ab1ddb
ab1ddb
Because of this nss_clear_netgroup_hash_table() should only remove the
ab1ddb
data from the hash table but not free it.
ab1ddb
ab1ddb
Related to https://pagure.io/SSSD/sssd/issue/3731
ab1ddb
ab1ddb
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
ab1ddb
(cherry picked from commit b13cc2d1413a0d5bbe36e06e5ffd87dbf5c0cb9f)
ab1ddb
---
ab1ddb
 src/responder/nss/nsssrv.c | 2 +-
ab1ddb
 1 file changed, 1 insertion(+), 1 deletion(-)
ab1ddb
ab1ddb
diff --git a/src/responder/nss/nsssrv.c b/src/responder/nss/nsssrv.c
ab1ddb
index 11d19fd30c86283d537623db12e52caa6cc4dcd3..123a2d73ce93a025c789524fa90b41d9a0afb58b 100644
ab1ddb
--- a/src/responder/nss/nsssrv.c
ab1ddb
+++ b/src/responder/nss/nsssrv.c
ab1ddb
@@ -142,7 +142,7 @@ static int nss_clear_netgroup_hash_table(struct sbus_request *dbus_req, void *da
ab1ddb
 
ab1ddb
     DEBUG(SSSDBG_TRACE_FUNC, "Invalidating netgroup hash table\n");
ab1ddb
 
ab1ddb
-    sss_ptr_hash_delete_all(nss_ctx->netgrent, true);
ab1ddb
+    sss_ptr_hash_delete_all(nss_ctx->netgrent, false);
ab1ddb
 
ab1ddb
     return sbus_request_return_and_finish(dbus_req, DBUS_TYPE_INVALID);
ab1ddb
 }
ab1ddb
-- 
ab1ddb
2.17.0
ab1ddb