summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Landau <hlandau@openssl.org>2023-02-21 10:18:58 +0000
committerHugo Landau <hlandau@openssl.org>2023-03-30 11:14:07 +0100
commitd7b1faddab2817c6b73f18f84f8ad6cc9d2f563a (patch)
tree5cbb9abf0cdf963c5cbcbb87fb176a6e7b891b44
parentfb2245c44b58b41a378eb47422221edd49ba9091 (diff)
Annotate functions needing locking
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/20348)
-rw-r--r--include/internal/quic_channel.h4
-rw-r--r--ssl/quic/quic_impl.c15
-rw-r--r--ssl/quic/quic_rx_depack.c1
3 files changed, 20 insertions, 0 deletions
diff --git a/include/internal/quic_channel.h b/include/internal/quic_channel.h
index 13cd83bff1..93cdfd6919 100644
--- a/include/internal/quic_channel.h
+++ b/include/internal/quic_channel.h
@@ -59,6 +59,10 @@
* information. This is an unchecked precondition.
*/
+# define QUIC_NEEDS_LOCK
+# define QUIC_TAKES_LOCK
+# define QUIC_TODO_LOCK
+
# define QUIC_CHANNEL_STATE_IDLE 0
# define QUIC_CHANNEL_STATE_ACTIVE 1
# define QUIC_CHANNEL_STATE_TERMINATING_CLOSING 2
diff --git a/ssl/quic/quic_impl.c b/ssl/quic/quic_impl.c
index ac99a930e2..73501cd286 100644
--- a/ssl/quic/quic_impl.c
+++ b/ssl/quic/quic_impl.c
@@ -29,7 +29,9 @@ static int ensure_channel(QUIC_CONNECTION *qc);
* Block until a predicate is met.
*
* Precondition: Must have a channel.
+ * Precondition: Must hold channel lock (unchecked).
*/
+QUIC_NEEDS_LOCK
static int block_until_pred(QUIC_CONNECTION *qc,
int (*pred)(void *arg), void *pred_arg,
uint32_t flags)
@@ -150,6 +152,7 @@ err:
}
/* SSL_free */
+QUIC_TODO_LOCK
void ossl_quic_free(SSL *s)
{
QUIC_CONNECTION *qc = QUIC_CONNECTION_FROM_SSL(s);
@@ -404,6 +407,7 @@ static int blocking_mode(const QUIC_CONNECTION *qc)
}
/* SSL_tick; ticks the reactor. */
+QUIC_TODO_LOCK
int ossl_quic_tick(QUIC_CONNECTION *qc)
{
if (qc->ch == NULL)
@@ -419,6 +423,7 @@ int ossl_quic_tick(QUIC_CONNECTION *qc)
* the object should be ticked immediately and tv->tv_sec is set to -1 if no
* timeout is currently active.
*/
+QUIC_TODO_LOCK
int ossl_quic_get_tick_timeout(QUIC_CONNECTION *qc, struct timeval *tv)
{
OSSL_TIME deadline = ossl_time_infinite();
@@ -456,6 +461,7 @@ int ossl_quic_get_wpoll_descriptor(QUIC_CONNECTION *qc, BIO_POLL_DESCRIPTOR *des
}
/* SSL_net_read_desired */
+QUIC_TODO_LOCK
int ossl_quic_get_net_read_desired(QUIC_CONNECTION *qc)
{
if (qc->ch == NULL)
@@ -465,6 +471,7 @@ int ossl_quic_get_net_read_desired(QUIC_CONNECTION *qc)
}
/* SSL_net_write_desired */
+QUIC_TODO_LOCK
int ossl_quic_get_net_write_desired(QUIC_CONNECTION *qc)
{
if (qc->ch == NULL)
@@ -495,6 +502,7 @@ static int quic_shutdown_wait(void *arg)
return qc->ch == NULL || ossl_quic_channel_is_terminated(qc->ch);
}
+QUIC_TODO_LOCK
int ossl_quic_conn_shutdown(QUIC_CONNECTION *qc, uint64_t flags,
const SSL_SHUTDOWN_EX_ARGS *args,
size_t args_len)
@@ -593,6 +601,7 @@ static int configure_channel(QUIC_CONNECTION *qc)
return 1;
}
+QUIC_TODO_LOCK
static int ensure_channel(QUIC_CONNECTION *qc)
{
QUIC_CHANNEL_ARGS args = {0};
@@ -617,6 +626,7 @@ static int ensure_channel(QUIC_CONNECTION *qc)
* via calls made to us from the application prior to starting a handshake
* attempt.
*/
+QUIC_TODO_LOCK
static int ensure_channel_and_start(QUIC_CONNECTION *qc)
{
if (!ensure_channel(qc))
@@ -640,6 +650,7 @@ static int ensure_channel_and_start(QUIC_CONNECTION *qc)
return 1;
}
+QUIC_TODO_LOCK
int ossl_quic_do_handshake(QUIC_CONNECTION *qc)
{
int ret;
@@ -1004,6 +1015,7 @@ static int quic_write_nonblocking_epw(QUIC_CONNECTION *qc, const void *buf, size
return 1;
}
+QUIC_TODO_LOCK
int ossl_quic_write(SSL *s, const void *buf, size_t len, size_t *written)
{
QUIC_CONNECTION *qc = QUIC_CONNECTION_FROM_SSL(s);
@@ -1124,6 +1136,7 @@ static int quic_read_again(void *arg)
return 0; /* did not read anything, keep trying */
}
+QUIC_TODO_LOCK
static int quic_read(SSL *s, void *buf, size_t len, size_t *bytes_read, int peek)
{
int res;
@@ -1195,6 +1208,7 @@ int ossl_quic_peek(SSL *s, void *buf, size_t len, size_t *bytes_read)
* SSL_pending
* -----------
*/
+QUIC_TODO_LOCK
static size_t ossl_quic_pending_int(const QUIC_CONNECTION *qc)
{
size_t avail = 0;
@@ -1229,6 +1243,7 @@ int ossl_quic_has_pending(const QUIC_CONNECTION *qc)
* SSL_stream_conclude
* -------------------
*/
+QUIC_TODO_LOCK
int ossl_quic_conn_stream_conclude(QUIC_CONNECTION *qc)
{
QUIC_STREAM *qs = qc->stream0;
diff --git a/ssl/quic/quic_rx_depack.c b/ssl/quic/quic_rx_depack.c
index df44a79c90..7af86c8841 100644
--- a/ssl/quic/quic_rx_depack.c
+++ b/ssl/quic/quic_rx_depack.c
@@ -902,6 +902,7 @@ static int depack_process_frames(QUIC_CHANNEL *ch, PACKET *pkt,
return 1;
}
+QUIC_NEEDS_LOCK
int ossl_quic_handle_frames(QUIC_CHANNEL *ch, OSSL_QRX_PKT *qpacket)
{
PACKET pkt;