From a8a7edcd52677966b851fad3ba7e7d18224a343d Mon Sep 17 00:00:00 2001 From: Konrad Sztyber Date: Mon, 5 Sep 2022 04:25:45 +0200 Subject: [PATCH] sock/ssl: don't free SSL_CTX on accept() failure SSL_CTX isn't created in accept(), but when a socket on which accept() is called is created, so it shouldn't be freed when accept() fails, as this makes the socket unusable (any subsequent operations using SSL_CTX would be using freed memory). This caused the segfaults reported in issue #2681, where the second connection would crash the application. Signed-off-by: Konrad Sztyber Change-Id: I1a01a748c5a34ce3dd0fd3c557b860c0ff314b85 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14355 Reviewed-by: Aleksey Marchuk Reviewed-by: Shuhei Matsumoto Reviewed-by: Dong Yi Reviewed-by: Tomasz Zawadzki Reviewed-by: Jim Harris Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot --- module/sock/posix/posix.c | 1 - 1 file changed, 1 deletion(-) diff --git a/module/sock/posix/posix.c b/module/sock/posix/posix.c index e431beae1..87e670ec8 100644 --- a/module/sock/posix/posix.c +++ b/module/sock/posix/posix.c @@ -1050,7 +1050,6 @@ posix_sock_accept(struct spdk_sock *_sock) if (!ssl) { SPDK_ERRLOG("ssl_sock_accept_loop() failed, errno = %d\n", errno); close(fd); - SSL_CTX_free(sock->ctx); return NULL; } }