From: Arran Cudbard-Bell Date: Sun, 17 Jan 2021 23:52:34 +0000 (+0000) Subject: No longer need to do anything special with state when detaching X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=91a08285efd5922130fa01fca3a6399df2aba10a;p=thirdparty%2Ffreeradius-server.git No longer need to do anything special with state when detaching --- diff --git a/src/lib/server/request.c b/src/lib/server/request.c index 612c2b323b0..8fe152b65c1 100644 --- a/src/lib/server/request.c +++ b/src/lib/server/request.c @@ -518,15 +518,11 @@ request_t *_request_local_alloc(char const *file, int line, TALLOC_CTX *ctx, req * @note This should be used for requests in preparation for freeing them. * * @param[in] child request to unlink. - * @param[in] will_free Caller super pinky swears to free - * the request ASAP, and that it wont - * touch persistable request data, - * request->session_state_ctx or request->state. * @return * - 0 on success. * - -1 on failure. */ -int request_detach(request_t *child, bool will_free) +int request_detach(request_t *child) { request_t *request = child->parent; @@ -537,12 +533,6 @@ int request_detach(request_t *child, bool will_free) */ request_data_get(request, child, 0); - /* - * Fixup any sate or persistent - * request data. - */ - fr_state_detach(child, will_free); - child->parent = NULL; while (!request->backlog) { diff --git a/src/lib/server/request.h b/src/lib/server/request.h index a6276682ed5..00e26f9cc3a 100644 --- a/src/lib/server/request.h +++ b/src/lib/server/request.h @@ -275,7 +275,7 @@ request_t *_request_alloc(char const *file, int line, TALLOC_CTX *ctx, request_i #define request_local_alloc(_ctx, _args) _request_local_alloc(__FILE__, __LINE__, (_ctx), (_args)) request_t *_request_local_alloc(char const *file, int line, TALLOC_CTX *ctx, request_init_args_t const *args); -int request_detach(request_t *child, bool will_free); +int request_detach(request_t *child); int request_global_init(void); void request_global_free(void); diff --git a/src/lib/server/state.c b/src/lib/server/state.c index 6b4053f0ff1..24abe45f94f 100644 --- a/src/lib/server/state.c +++ b/src/lib/server/state.c @@ -835,49 +835,6 @@ void fr_state_restore_to_child(request_t *child, void const *unique_ptr, int uni talloc_free(child_entry); } -/** Move all request data and session-state VPs into a new state_ctx - * - * If we don't do this on detach, session-state VPs and persistable - * request data will be freed when the parent's state_ctx is freed. - * If the parent was freed before the child, we'd get all kinds of - * use after free nastiness. - * - * @param[in] request to detach. - * @param[in] will_free Caller super pinky swears to free - * the request ASAP, and that it wont - * touch persistable request data, - * request->session_state_ctx or request->state. - */ -void fr_state_detach(request_t *request, bool will_free) -{ - fr_pair_t *new_state_ctx; - - if (will_free) { - fr_pair_list_free(&request->session_state_pairs); - - /* - * The non-persistable stuff is - * prented directly by the request - */ - request_data_persistable_free(request); - return; - } - - /* - * Alloc a new pairlist to use as the - * state ctx and the head of the - * state list. - */ - MEM(new_state_ctx = fr_pair_afrom_da(NULL, request_attr_state)); - request_data_by_persistance_reparent(new_state_ctx, NULL, request, true); - request_data_by_persistance_reparent(new_state_ctx, NULL, request, false); - - (void) fr_pair_list_copy(new_state_ctx, &new_state_ctx->children, &request->session_state_pairs); - fr_pair_list_free(&request->session_state_pairs); - - request->session_state_ctx = new_state_ctx; -} - /** Return number of entries created * */ diff --git a/src/lib/server/state.h b/src/lib/server/state.h index bd72050ad21..ce79c74ab02 100644 --- a/src/lib/server/state.h +++ b/src/lib/server/state.h @@ -45,7 +45,6 @@ int fr_request_to_state(fr_state_tree_t *state, request_t *request); void fr_state_store_in_parent(request_t *request, void const *unique_ptr, int unique_int); void fr_state_restore_to_child(request_t *request, void const *unique_ptr, int unique_int); -void fr_state_detach(request_t *request, bool will_free); /* * Stats */ diff --git a/src/lib/unlang/subrequest.c b/src/lib/unlang/subrequest.c index 6f1f8a99371..392894d5e80 100644 --- a/src/lib/unlang/subrequest.c +++ b/src/lib/unlang/subrequest.c @@ -367,7 +367,7 @@ int unlang_detached_child_init(request_t *request) { fr_pair_t *vp; - if (request_detach(request, false) < 0) { + if (request_detach(request) < 0) { ERROR("Failed detaching child"); return -1; } @@ -485,7 +485,7 @@ static unlang_action_t unlang_detach(rlm_rcode_t *p_result, request_t *request) */ void unlang_subrequest_free(request_t **child) { - request_detach(*child, true); + request_detach(*child); talloc_free(*child); *child = NULL; } diff --git a/src/modules/rlm_eap/rlm_eap.c b/src/modules/rlm_eap/rlm_eap.c index 31d79a82883..681dbc069ca 100644 --- a/src/modules/rlm_eap/rlm_eap.c +++ b/src/modules/rlm_eap/rlm_eap.c @@ -351,7 +351,7 @@ static void mod_authenticate_cancel(UNUSED module_ctx_t const *mctx, request_t * eap_session = talloc_get_type_abort(rctx, eap_session_t); - (void)fr_cond_assert(request_detach(eap_session->subrequest, true) == 0); + (void)fr_cond_assert(request_detach(eap_session->subrequest) == 0); TALLOC_FREE(eap_session->subrequest); /* @@ -382,7 +382,7 @@ static unlang_action_t mod_authenticate_result(rlm_rcode_t *p_result, UNUSED mod /* * Cleanup the subrequest */ - (void)fr_cond_assert(request_detach(eap_session->subrequest, true) == 0); + (void)fr_cond_assert(request_detach(eap_session->subrequest) == 0); TALLOC_FREE(eap_session->subrequest); /*