2024-01-12 23:39:56 +08:00
|
|
|
/*
|
2024-03-20 20:07:54 +08:00
|
|
|
* Copyright 2023-2024 The OpenSSL Project Authors. All Rights Reserved.
|
2024-01-12 23:39:56 +08:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
|
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
|
|
* in the file LICENSE in the source distribution or at
|
|
|
|
* https://www.openssl.org/source/license.html
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef OPENSSL_RCU_H
|
|
|
|
# define OPENSSL_RCU_H
|
|
|
|
# pragma once
|
|
|
|
|
2024-04-16 04:56:29 +08:00
|
|
|
#include "crypto/context.h"
|
|
|
|
|
2024-01-12 23:39:56 +08:00
|
|
|
typedef void (*rcu_cb_fn)(void *data);
|
|
|
|
|
|
|
|
typedef struct rcu_lock_st CRYPTO_RCU_LOCK;
|
|
|
|
|
2024-04-16 04:56:29 +08:00
|
|
|
CRYPTO_RCU_LOCK *ossl_rcu_lock_new(int num_writers, OSSL_LIB_CTX *ctx);
|
2024-01-12 23:39:56 +08:00
|
|
|
void ossl_rcu_lock_free(CRYPTO_RCU_LOCK *lock);
|
Fix failure checking on rcu_read_lock
during memfail testing:
https://github.com/openssl/openssl/actions/runs/16794088536/job/47561223902
We get lots of test failures in ossl_rcu_read_lock. This occurs
because we have a few cases in the read lock path that attempt mallocs,
which, if they fail, trigger an assert or a silent failure, which isn't
really appropriate. We should instead fail gracefully, by informing the
caller that the lock failed, like we do for CRYPTO_THREAD_read_lock.
Fortunately, these are all internal apis, so we can convert
ossl_rcu_read_lock to return an int indicating success/failure, and fail
gracefully during the test, rather than hitting an assert abort.
Fixes openssl/project#1315
Reviewed-by: Paul Yang <paulyang.inf@gmail.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/28195)
2025-08-07 21:50:58 +08:00
|
|
|
int ossl_rcu_read_lock(CRYPTO_RCU_LOCK *lock);
|
2024-01-12 23:39:56 +08:00
|
|
|
void ossl_rcu_write_lock(CRYPTO_RCU_LOCK *lock);
|
|
|
|
void ossl_rcu_write_unlock(CRYPTO_RCU_LOCK *lock);
|
|
|
|
void ossl_rcu_read_unlock(CRYPTO_RCU_LOCK *lock);
|
|
|
|
void ossl_synchronize_rcu(CRYPTO_RCU_LOCK *lock);
|
|
|
|
int ossl_rcu_call(CRYPTO_RCU_LOCK *lock, rcu_cb_fn cb, void *data);
|
|
|
|
void *ossl_rcu_uptr_deref(void **p);
|
|
|
|
void ossl_rcu_assign_uptr(void **p, void **v);
|
|
|
|
#define ossl_rcu_deref(p) ossl_rcu_uptr_deref((void **)p)
|
|
|
|
#define ossl_rcu_assign_ptr(p,v) ossl_rcu_assign_uptr((void **)p, (void **)v)
|
|
|
|
|
|
|
|
#endif
|