dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

Blame SOURCES/0012-sudo-always-use-srv_opts-from-id-context.patch

ced1f5
From 7738a74e6878536e155d9d589e7ec727c135f5a0 Mon Sep 17 00:00:00 2001
976a3f
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
976a3f
Date: Thu, 19 Oct 2017 10:39:21 +0200
ced1f5
Subject: [PATCH 12/21] sudo: always use srv_opts from id context
976a3f
976a3f
Prior this patch, we remember id_ctx->srv_opts in sudo request to switch
976a3f
the latest usn values. This works fine most of the time but it may cause
976a3f
a crash.
976a3f
976a3f
If we have two concurrent sudo refresh and one of these fails, it causes
976a3f
failover to try the next server and possibly replacing the old srv_opts
976a3f
with new one and it causes an access after free in the other refresh.
976a3f
976a3f
Resolves:
976a3f
https://pagure.io/SSSD/sssd/issue/3562
976a3f
976a3f
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
976a3f
(cherry picked from commit 2ee201dcf6bbe52abbbed3c2fc4c35ca2e0c8a43)
976a3f
---
976a3f
 src/providers/ldap/sdap_async_sudo.c | 7 +------
976a3f
 1 file changed, 1 insertion(+), 6 deletions(-)
976a3f
976a3f
diff --git a/src/providers/ldap/sdap_async_sudo.c b/src/providers/ldap/sdap_async_sudo.c
976a3f
index 3c69837fda313b2645c3a8497252670312f600ea..88a387422d5c9ae86cea583bb38dadf90cba37f3 100644
976a3f
--- a/src/providers/ldap/sdap_async_sudo.c
976a3f
+++ b/src/providers/ldap/sdap_async_sudo.c
976a3f
@@ -279,7 +279,6 @@ done:
976a3f
 struct sdap_sudo_refresh_state {
976a3f
     struct sdap_sudo_ctx *sudo_ctx;
976a3f
     struct tevent_context *ev;
976a3f
-    struct sdap_server_opts *srv_opts;
976a3f
     struct sdap_options *opts;
976a3f
     struct sdap_id_op *sdap_op;
976a3f
     struct sysdb_ctx *sysdb;
976a3f
@@ -405,9 +404,6 @@ static void sdap_sudo_refresh_connect_done(struct tevent_req *subreq)
976a3f
 
976a3f
     DEBUG(SSSDBG_TRACE_FUNC, "SUDO LDAP connection successful\n");
976a3f
 
976a3f
-    /* Obtain srv_opts here in case of first connection. */
976a3f
-    state->srv_opts = state->sudo_ctx->id_ctx->srv_opts;
976a3f
-
976a3f
     /* Renew host information if needed. */
976a3f
     if (state->sudo_ctx->run_hostinfo) {
976a3f
         subreq = sdap_sudo_get_hostinfo_send(state, state->opts,
976a3f
@@ -586,7 +582,6 @@ static void sdap_sudo_refresh_done(struct tevent_req *subreq)
976a3f
         goto done;
976a3f
     }
976a3f
 
976a3f
-
976a3f
     /* start transaction */
976a3f
     ret = sysdb_transaction_start(state->sysdb);
976a3f
     if (ret != EOK) {
976a3f
@@ -621,7 +616,7 @@ static void sdap_sudo_refresh_done(struct tevent_req *subreq)
976a3f
     /* remember new usn */
976a3f
     ret = sysdb_get_highest_usn(state, rules, rules_count, &usn;;
976a3f
     if (ret == EOK) {
976a3f
-        sdap_sudo_set_usn(state->srv_opts, usn);
976a3f
+        sdap_sudo_set_usn(state->sudo_ctx->id_ctx->srv_opts, usn);
976a3f
     } else {
976a3f
         DEBUG(SSSDBG_MINOR_FAILURE, "Unable to get highest USN [%d]: %s\n",
976a3f
               ret, sss_strerror(ret));
976a3f
-- 
ced1f5
2.13.5
976a3f