From 20273a99a6bacb3807f178f8694f0925028b0743 Mon Sep 17 00:00:00 2001 From: jsing Date: Wed, 24 Jan 2024 14:05:10 +0000 Subject: [PATCH] Stop fiddling with hash table internals from lhash doall callers. It is now safe to call delete from an lhash doall callback - stop fiddling wit hash table internals from lhash doall callers that previously has to workaround this themselves. ok tb@ --- lib/libcrypto/conf/conf_api.c | 5 +---- lib/libcrypto/objects/obj_dat.c | 4 ++-- lib/libssl/ssl_sess.c | 9 +++------ 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/lib/libcrypto/conf/conf_api.c b/lib/libcrypto/conf/conf_api.c index 6fe071e12ca..464edcd4ffb 100644 --- a/lib/libcrypto/conf/conf_api.c +++ b/lib/libcrypto/conf/conf_api.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf_api.c,v 1.16 2023/07/08 08:26:26 beck Exp $ */ +/* $OpenBSD: conf_api.c,v 1.17 2024/01/24 14:05:10 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -205,9 +205,6 @@ _CONF_free_data(CONF *conf) if (conf == NULL || conf->data == NULL) return; - lh_CONF_VALUE_down_load(conf->data) = 0; /* evil thing to make - * sure the 'free()' works as - * expected */ lh_CONF_VALUE_doall_arg(conf->data, LHASH_DOALL_ARG_FN(value_free_hash), LHASH_OF(CONF_VALUE), conf->data); diff --git a/lib/libcrypto/objects/obj_dat.c b/lib/libcrypto/objects/obj_dat.c index acc4556d5be..170a6d58a38 100644 --- a/lib/libcrypto/objects/obj_dat.c +++ b/lib/libcrypto/objects/obj_dat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: obj_dat.c,v 1.84 2024/01/13 11:57:51 tb Exp $ */ +/* $OpenBSD: obj_dat.c,v 1.85 2024/01/24 14:05:10 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -188,7 +188,7 @@ OBJ_cleanup(void) { if (added == NULL) return; - lh_ADDED_OBJ_down_load(added) = 0; + lh_ADDED_OBJ_doall(added, LHASH_DOALL_FN(cleanup1)); /* zero counters */ lh_ADDED_OBJ_doall(added, LHASH_DOALL_FN(cleanup2)); /* set counters */ lh_ADDED_OBJ_doall(added, LHASH_DOALL_FN(cleanup3)); /* free objects */ diff --git a/lib/libssl/ssl_sess.c b/lib/libssl/ssl_sess.c index ae7532d1adc..355193c470c 100644 --- a/lib/libssl/ssl_sess.c +++ b/lib/libssl/ssl_sess.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_sess.c,v 1.123 2023/11/19 15:51:49 tb Exp $ */ +/* $OpenBSD: ssl_sess.c,v 1.124 2024/01/24 14:05:10 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -1159,7 +1159,6 @@ timeout_LHASH_DOALL_ARG(void *arg1, void *arg2) void SSL_CTX_flush_sessions(SSL_CTX *s, long t) { - unsigned long i; TIMEOUT_PARAM tp; tp.ctx = s; @@ -1167,12 +1166,10 @@ SSL_CTX_flush_sessions(SSL_CTX *s, long t) if (tp.cache == NULL) return; tp.time = t; + CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX); - i = CHECKED_LHASH_OF(SSL_SESSION, tp.cache)->down_load; - CHECKED_LHASH_OF(SSL_SESSION, tp.cache)->down_load = 0; lh_SSL_SESSION_doall_arg(tp.cache, timeout_LHASH_DOALL_ARG, - TIMEOUT_PARAM, &tp); - CHECKED_LHASH_OF(SSL_SESSION, tp.cache)->down_load = i; + TIMEOUT_PARAM, &tp); CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX); } LSSL_ALIAS(SSL_CTX_flush_sessions); -- 2.20.1