Skip to content

MOD-18192 - (LEAK) free ssl in case of redisInitiateSSL error - #124

Merged
TalBarYakar merged 3 commits into
masterfrom
tal.ba/bug/leak_ssl_in_cluster_err
Sep 6, 2026
Merged

TalBarYakar merged 3 commits into
masterfrom
tal.ba/bug/leak_ssl_in_cluster_err

Conversation

@TalBarYakar

@TalBarYakar TalBarYakar commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Note

Low Risk
Small resource-cleanup fix on a TLS failure path plus CI Redis install sequencing; no change to successful TLS or cluster messaging behavior.

Overview
Fixes an OpenSSL leak on inter-shard TLS setup: when redisInitiateSSL fails in MR_OnConnectCallback, the code now calls SSL_free(ssl) before scheduling async disconnect/retry. Previously the SSL created with SSL_new was left allocated after the context was already freed.

CI install redis steps on Linux and macOS are split into a normal TLS build (make valgrind / make -j8) and a separate sudo make install ... SKIP_BUILD=1, instead of a single combined build+install target.

Reviewed by Cursor Bugbot for commit cf5196e. Bugbot is set up for automated code reviews on this repo. Configure here.

AvivDavid23
AvivDavid23 previously approved these changes Sep 6, 2026

@gabsow gabsow left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. SSL_free(ssl) correctly plugs the leak on the redisInitiateSSL failure path — SSL_CTX_free on the context doesn't free the SSL object created via SSL_new, and it was never attached to redisContext since redisInitiateSSL failed, so it was previously leaked on every failed inter-shard TLS handshake. CI split (build without sudo, then sudo make install ... SKIP_BUILD=1) makes sense to keep BUILD_TLS=yes honored consistently, and all matrix legs are green.

@TalBarYakar
TalBarYakar merged commit 121d477 into master Sep 6, 2026
8 checks passed
git checkout ${{ matrix.redis_version }}
BUILD_TLS=yes make valgrind install
BUILD_TLS=yes make valgrind
sudo make install BUILD_TLS=yes SKIP_BUILD=1

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this weird combo (BUILD_TLS=yes SKIP_BUILD=1) do?

git clone https://github.com/redis/redis
cd redis
git checkout ${{ matrix.redis_version }}
BUILD_TLS=yes make -j8

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the hardcoded -j8? We have no idea what machine will build in ci so cannot assume anything about its number of cores.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants