Blame SOURCES/0091-RESPONDER-don-t-execute-sss_dp_callback_destructor-i.patch

5ddef6
From ecbc3329788de254346d7ea84770e09cc22dbc9c Mon Sep 17 00:00:00 2001
5ddef6
From: Alexey Tikhonov <atikhono@redhat.com>
5ddef6
Date: Mon, 18 Jul 2022 21:59:03 +0200
5ddef6
Subject: [PATCH] RESPONDER: don't execute sss_dp_callback_destructor() if
5ddef6
 responder is being shut down.
5ddef6
MIME-Version: 1.0
5ddef6
Content-Type: text/plain; charset=UTF-8
5ddef6
Content-Transfer-Encoding: 8bit
5ddef6
5ddef6
Resolves: https://github.com/SSSD/sssd/issues/6270
5ddef6
5ddef6
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
5ddef6
Reviewed-by: Tomáš Halman <thalman@redhat.com>
5ddef6
---
5ddef6
 src/responder/common/responder_dp.c | 9 ++++++++-
5ddef6
 1 file changed, 8 insertions(+), 1 deletion(-)
5ddef6
5ddef6
diff --git a/src/responder/common/responder_dp.c b/src/responder/common/responder_dp.c
5ddef6
index a49b31528..0cc5c5424 100644
5ddef6
--- a/src/responder/common/responder_dp.c
5ddef6
+++ b/src/responder/common/responder_dp.c
5ddef6
@@ -35,6 +35,7 @@ struct sss_dp_callback {
5ddef6
     struct sss_dp_callback *prev;
5ddef6
     struct sss_dp_callback *next;
5ddef6
 
5ddef6
+    struct resp_ctx *rctx;
5ddef6
     struct tevent_req *req;
5ddef6
     struct sss_dp_req *sdp_req;
5ddef6
 };
5ddef6
@@ -58,9 +59,14 @@ static int sss_dp_callback_destructor(void *ptr)
5ddef6
     struct sss_dp_callback *cb =
5ddef6
             talloc_get_type(ptr, struct sss_dp_callback);
5ddef6
 
5ddef6
+    /* `sdp_req` might be already freed if responder is being shut down */
5ddef6
+    if (cb->rctx->shutting_down) {
5ddef6
+        return 0;
5ddef6
+    }
5ddef6
+
5ddef6
     DLIST_REMOVE(cb->sdp_req->cb_list, cb);
5ddef6
 
5ddef6
-    return EOK;
5ddef6
+    return 0;
5ddef6
 }
5ddef6
 
5ddef6
 static int sss_dp_req_destructor(void *ptr)
5ddef6
@@ -396,6 +402,7 @@ sss_dp_issue_request(TALLOC_CTX *mem_ctx, struct resp_ctx *rctx,
5ddef6
         goto fail;
5ddef6
     }
5ddef6
 
5ddef6
+    cb->rctx = rctx;
5ddef6
     cb->req = nreq;
5ddef6
     cb->sdp_req = sdp_req;
5ddef6
 
5ddef6
-- 
5ddef6
2.37.3
5ddef6