From 19ffc20a151103ea553699b23233bba82517d243 Mon Sep 17 00:00:00 2001 From: Bret Ambrose Date: Tue, 27 Jun 2023 13:42:06 -0700 Subject: [PATCH 1/7] Cleanup aws-lc thread locals in event loop threads --- source/linux/epoll_event_loop.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source/linux/epoll_event_loop.c b/source/linux/epoll_event_loop.c index af1ed765d..c347310f1 100644 --- a/source/linux/epoll_event_loop.c +++ b/source/linux/epoll_event_loop.c @@ -562,6 +562,14 @@ static int aws_event_loop_listen_for_io_events(int epoll_fd, struct epoll_event return epoll_wait(epoll_fd, events, MAX_EVENTS, timeout); } +static void s_aws_cleanup_aws_lc_thread_local_state(void *user_data) { + (void)user_data; + +#if defined(OPENSSL_IS_AWSLC) + AWSLC_thread_local_clear(); +#endif +} + static void aws_event_loop_thread(void *args) { struct aws_event_loop *event_loop = args; AWS_LOGF_INFO(AWS_LS_IO_EVENT_LOOP, "id=%p: main loop started", (void *)event_loop); @@ -576,6 +584,8 @@ static void aws_event_loop_thread(void *args) { return; } + aws_thread_current_at_exit(s_aws_cleanup_aws_lc_thread_local_state, NULL); + int timeout = DEFAULT_TIMEOUT; struct epoll_event events[MAX_EVENTS]; From f3b0cdf0afcde105a1b972ea5ccba43f02736e91 Mon Sep 17 00:00:00 2001 From: Bret Ambrose Date: Wed, 28 Jun 2023 16:03:32 -0700 Subject: [PATCH 2/7] Cleanup aws-lc on BSD as well --- source/bsd/kqueue_event_loop.c | 11 +++++++++++ source/linux/epoll_event_loop.c | 6 ++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/source/bsd/kqueue_event_loop.c b/source/bsd/kqueue_event_loop.c index 43130fa49..668d0ac50 100644 --- a/source/bsd/kqueue_event_loop.c +++ b/source/bsd/kqueue_event_loop.c @@ -15,6 +15,7 @@ #if defined(__FreeBSD__) || defined(__NetBSD__) # define __BSD_VISIBLE 1 +# include # include #endif @@ -821,6 +822,14 @@ static int aws_event_loop_listen_for_io_events(int kq_fd, struct kevent kevents[ return kevent(kq_fd, NULL /*changelist*/, 0 /*nchanges*/, kevents /*eventlist*/, MAX_EVENTS /*nevents*/, timeout); } +static void s_aws_kqueue_cleanup_aws_lc_thread_local_state(void *user_data) { + (void)user_data; + +#if defined(OPENSSL_IS_AWSLC) + AWSLC_thread_local_clear(); +#endif +} + static void aws_event_loop_thread(void *user_data) { struct aws_event_loop *event_loop = user_data; AWS_LOGF_INFO(AWS_LS_IO_EVENT_LOOP, "id=%p: main loop started", (void *)event_loop); @@ -852,6 +861,8 @@ static void aws_event_loop_thread(void *user_data) { DEFAULT_TIMEOUT_SEC, MAX_EVENTS); + aws_thread_current_at_exit(s_aws_kqueue_cleanup_aws_lc_thread_local_state, NULL); + while (impl->thread_data.state == EVENT_THREAD_STATE_RUNNING) { int num_io_handle_events = 0; bool should_process_cross_thread_data = false; diff --git a/source/linux/epoll_event_loop.c b/source/linux/epoll_event_loop.c index c347310f1..0857aa596 100644 --- a/source/linux/epoll_event_loop.c +++ b/source/linux/epoll_event_loop.c @@ -15,6 +15,8 @@ #include +#include + #include #include #include @@ -562,7 +564,7 @@ static int aws_event_loop_listen_for_io_events(int epoll_fd, struct epoll_event return epoll_wait(epoll_fd, events, MAX_EVENTS, timeout); } -static void s_aws_cleanup_aws_lc_thread_local_state(void *user_data) { +static void s_aws_epoll_cleanup_aws_lc_thread_local_state(void *user_data) { (void)user_data; #if defined(OPENSSL_IS_AWSLC) @@ -584,7 +586,7 @@ static void aws_event_loop_thread(void *args) { return; } - aws_thread_current_at_exit(s_aws_cleanup_aws_lc_thread_local_state, NULL); + aws_thread_current_at_exit(s_aws_epoll_cleanup_aws_lc_thread_local_state, NULL); int timeout = DEFAULT_TIMEOUT; From 537431f336c57dee16dfe368806f107de3656dac Mon Sep 17 00:00:00 2001 From: Bret Ambrose Date: Wed, 28 Jun 2023 16:38:07 -0700 Subject: [PATCH 3/7] Use cal's new public API for thread local cleanup --- source/bsd/kqueue_event_loop.c | 6 ++---- source/linux/epoll_event_loop.c | 5 ++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/source/bsd/kqueue_event_loop.c b/source/bsd/kqueue_event_loop.c index 668d0ac50..33a517e7b 100644 --- a/source/bsd/kqueue_event_loop.c +++ b/source/bsd/kqueue_event_loop.c @@ -7,6 +7,7 @@ #include +#include #include #include #include @@ -15,7 +16,6 @@ #if defined(__FreeBSD__) || defined(__NetBSD__) # define __BSD_VISIBLE 1 -# include # include #endif @@ -825,9 +825,7 @@ static int aws_event_loop_listen_for_io_events(int kq_fd, struct kevent kevents[ static void s_aws_kqueue_cleanup_aws_lc_thread_local_state(void *user_data) { (void)user_data; -#if defined(OPENSSL_IS_AWSLC) - AWSLC_thread_local_clear(); -#endif + aws_cal_thread_clean_up(); } static void aws_event_loop_thread(void *user_data) { diff --git a/source/linux/epoll_event_loop.c b/source/linux/epoll_event_loop.c index 0857aa596..2a8fade6f 100644 --- a/source/linux/epoll_event_loop.c +++ b/source/linux/epoll_event_loop.c @@ -5,6 +5,7 @@ #include +#include #include #include #include @@ -567,9 +568,7 @@ static int aws_event_loop_listen_for_io_events(int epoll_fd, struct epoll_event static void s_aws_epoll_cleanup_aws_lc_thread_local_state(void *user_data) { (void)user_data; -#if defined(OPENSSL_IS_AWSLC) - AWSLC_thread_local_clear(); -#endif + aws_cal_thread_clean_up(); } static void aws_event_loop_thread(void *args) { From 872f6b67b8db7fc6ea8431b8905cf1d03e498191 Mon Sep 17 00:00:00 2001 From: Bret Ambrose Date: Wed, 28 Jun 2023 16:56:12 -0700 Subject: [PATCH 4/7] Remove bad include --- source/linux/epoll_event_loop.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/source/linux/epoll_event_loop.c b/source/linux/epoll_event_loop.c index 2a8fade6f..5eacac915 100644 --- a/source/linux/epoll_event_loop.c +++ b/source/linux/epoll_event_loop.c @@ -16,8 +16,6 @@ #include -#include - #include #include #include From 542f79d25f98ea4dc357e8c6a750d4005d97ab37 Mon Sep 17 00:00:00 2001 From: Bret Ambrose Date: Thu, 29 Jun 2023 07:14:33 -0700 Subject: [PATCH 5/7] BYO_CRYPTO guards --- source/bsd/kqueue_event_loop.c | 3 ++- source/linux/epoll_event_loop.c | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/source/bsd/kqueue_event_loop.c b/source/bsd/kqueue_event_loop.c index 33a517e7b..43c2d9977 100644 --- a/source/bsd/kqueue_event_loop.c +++ b/source/bsd/kqueue_event_loop.c @@ -824,8 +824,9 @@ static int aws_event_loop_listen_for_io_events(int kq_fd, struct kevent kevents[ static void s_aws_kqueue_cleanup_aws_lc_thread_local_state(void *user_data) { (void)user_data; - +#ifndef BYO_CRYPTO aws_cal_thread_clean_up(); +#endif } static void aws_event_loop_thread(void *user_data) { diff --git a/source/linux/epoll_event_loop.c b/source/linux/epoll_event_loop.c index 5eacac915..75ad8c467 100644 --- a/source/linux/epoll_event_loop.c +++ b/source/linux/epoll_event_loop.c @@ -566,7 +566,9 @@ static int aws_event_loop_listen_for_io_events(int epoll_fd, struct epoll_event static void s_aws_epoll_cleanup_aws_lc_thread_local_state(void *user_data) { (void)user_data; +#ifndef BYO_CRYPTO aws_cal_thread_clean_up(); +#endif } static void aws_event_loop_thread(void *args) { From 2d2402304e15ccd4a488f62abb15389b24af0981 Mon Sep 17 00:00:00 2001 From: Bret Ambrose Date: Thu, 29 Jun 2023 10:43:08 -0700 Subject: [PATCH 6/7] Refactor thread local cleanup --- source/bsd/kqueue_event_loop.c | 3 +-- source/linux/epoll_event_loop.c | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/source/bsd/kqueue_event_loop.c b/source/bsd/kqueue_event_loop.c index 43c2d9977..33a517e7b 100644 --- a/source/bsd/kqueue_event_loop.c +++ b/source/bsd/kqueue_event_loop.c @@ -824,9 +824,8 @@ static int aws_event_loop_listen_for_io_events(int kq_fd, struct kevent kevents[ static void s_aws_kqueue_cleanup_aws_lc_thread_local_state(void *user_data) { (void)user_data; -#ifndef BYO_CRYPTO + aws_cal_thread_clean_up(); -#endif } static void aws_event_loop_thread(void *user_data) { diff --git a/source/linux/epoll_event_loop.c b/source/linux/epoll_event_loop.c index 75ad8c467..5eacac915 100644 --- a/source/linux/epoll_event_loop.c +++ b/source/linux/epoll_event_loop.c @@ -566,9 +566,7 @@ static int aws_event_loop_listen_for_io_events(int epoll_fd, struct epoll_event static void s_aws_epoll_cleanup_aws_lc_thread_local_state(void *user_data) { (void)user_data; -#ifndef BYO_CRYPTO aws_cal_thread_clean_up(); -#endif } static void aws_event_loop_thread(void *args) { From 4f22c7512e9c0ddbea47d917dd0abff25d6e7600 Mon Sep 17 00:00:00 2001 From: Bret Ambrose Date: Fri, 30 Jun 2023 08:44:19 -0700 Subject: [PATCH 7/7] Update proof alarm checksum --- .github/workflows/proof-alarm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/proof-alarm.yml b/.github/workflows/proof-alarm.yml index f5367810a..d4b267f60 100644 --- a/.github/workflows/proof-alarm.yml +++ b/.github/workflows/proof-alarm.yml @@ -16,7 +16,7 @@ jobs: - name: Check run: | TMPFILE=$(mktemp) - echo "8391c38acd85cca2a2892d02ebfd4ceb source/linux/epoll_event_loop.c" > $TMPFILE + echo "59be2f2fbbd5ff4a374589cfe408609f source/linux/epoll_event_loop.c" > $TMPFILE md5sum --check $TMPFILE # No further steps if successful