dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

Blame SOURCES/0111-Do-not-keep-allocating-external-groups-on-a-long-liv.patch

ab1ddb
From d2e17974c6bcb3ae2fc8a2cde696d387385c7d61 Mon Sep 17 00:00:00 2001
ab1ddb
From: Jakub Hrozek <jhrozek@redhat.com>
ab1ddb
Date: Tue, 3 Apr 2018 21:48:37 +0200
ab1ddb
Subject: [PATCH] Do not keep allocating external groups on a long-lived
ab1ddb
 context
ab1ddb
MIME-Version: 1.0
ab1ddb
Content-Type: text/plain; charset=UTF-8
ab1ddb
Content-Transfer-Encoding: 8bit
ab1ddb
ab1ddb
The hash table with the external groups was never freed, so the
ab1ddb
server_mode->ext_groups context was growing over time.
ab1ddb
ab1ddb
This patch keeps the new hash on the state if something failed, then
ab1ddb
frees the previous hash and finally steals the new hash onto the server
ab1ddb
mode.
ab1ddb
ab1ddb
Resolves:
ab1ddb
https://pagure.io/SSSD/sssd/issue/3719
ab1ddb
ab1ddb
Signed-off-by: Sumit Bose <sbose@redhat.com>
ab1ddb
Reviewed-by: Fabiano FidĂȘncio <fidencio@redhat.com>
ab1ddb
(cherry picked from commit 10213efaf1f9f587b47a82778a252d79863f665e)
ab1ddb
ab1ddb
DOWNSTREAM:
ab1ddb
Resolves: rhbz#1583746 - The SSSD IPA provider allocates information about external groups on a long lived memory context, causing memory growth of the sssd_be process [rhel-7.5.z]
ab1ddb
---
ab1ddb
 src/providers/ipa/ipa_subdomains_ext_groups.c | 11 ++++++++---
ab1ddb
 1 file changed, 8 insertions(+), 3 deletions(-)
ab1ddb
ab1ddb
diff --git a/src/providers/ipa/ipa_subdomains_ext_groups.c b/src/providers/ipa/ipa_subdomains_ext_groups.c
ab1ddb
index 9e1d6c3a9bdeda56b421a2dc9198dff0b84c54ce..63ff7c7d7373a4e6a18fc914eff7ca00d477bca6 100644
ab1ddb
--- a/src/providers/ipa/ipa_subdomains_ext_groups.c
ab1ddb
+++ b/src/providers/ipa/ipa_subdomains_ext_groups.c
ab1ddb
@@ -583,14 +583,19 @@ static void ipa_get_ext_groups_done(struct tevent_req *subreq)
ab1ddb
     DEBUG(SSSDBG_TRACE_FUNC, "[%zu] external groups found.\n",
ab1ddb
                               state->reply_count);
ab1ddb
 
ab1ddb
-    ret = process_ext_groups(state->server_mode->ext_groups,
ab1ddb
-                             state->reply_count, state->reply, &ext_group_hash);
ab1ddb
+    ret = process_ext_groups(state,
ab1ddb
+                             state->reply_count,
ab1ddb
+                             state->reply,
ab1ddb
+                             &ext_group_hash);
ab1ddb
     if (ret != EOK) {
ab1ddb
         DEBUG(SSSDBG_OP_FAILURE, "process_ext_groups failed.\n");
ab1ddb
         goto fail;
ab1ddb
     }
ab1ddb
 
ab1ddb
-    state->server_mode->ext_groups->ext_groups = ext_group_hash;
ab1ddb
+    talloc_free(state->server_mode->ext_groups->ext_groups);
ab1ddb
+    state->server_mode->ext_groups->ext_groups = talloc_steal(
ab1ddb
+            state->server_mode->ext_groups,
ab1ddb
+            ext_group_hash);
ab1ddb
     /* Do we have to make the update timeout configurable? */
ab1ddb
     state->server_mode->ext_groups->next_update = time(NULL) + 10;
ab1ddb
 
ab1ddb
-- 
ab1ddb
2.17.0
ab1ddb