Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w8SFR-000YAw-1d for pgpool-hackers@arkaria.postgresql.org; Fri, 03 Apr 2026 00:18:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w8SFP-0092gz-0B for pgpool-hackers@arkaria.postgresql.org; Fri, 03 Apr 2026 00:18:51 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w8SFO-0092gs-2r for pgpool-hackers@lists.postgresql.org; Fri, 03 Apr 2026 00:18:51 +0000 Received: from meldrar.postgresql.org ([2a02:c0:301:0:ffff::31]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w8SFN-00000000Gmf-1GWK for pgpool-hackers@lists.postgresql.org; Fri, 03 Apr 2026 00:18:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Content-Transfer-Encoding:Content-Type: Mime-Version:From:Subject:To:Message-Id:Date:Sender:Reply-To:Cc:Content-ID: Content-Description:In-Reply-To:References; bh=GdI1TlrGanqPCh6qLGIkha785WC0L41mWHE1P16eQr8=; b=LGEfNkWPKUICaa7ECBBBewxEYR PAxM3/DgMs9Rvu6VbyS460yKAvx76fQBxtRySFB3mMS37bUb8rVFeL93UPg7qbB1mpa9CIp1ySlHW m0xyi/KJGzyJIlDQ7Vx7XDkzZzLcD2jgtTxwRnpKDzBzef6lLJDbuIsGIAaQ5bnntPofelYXWKKZA Dr9hC6nenbevipyzxqI/Wcb8oUwwGm1LDTGfwffTu7MaF4a/Y1MdublNglqoPqm7mcuolhQaC8Fq4 REJcDLwKo09kX7I+QXvr1zycHhGKOt+BCEav9aSwGtZ2MHG89x/qTPV83n0HgbSA7zW8pSwmTb4bD 6Hwvs8HA==; Received: from [2409:11:4120:300:bba:a076:86e7:5c41] (helo=localhost) by meldrar.postgresql.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w8SFJ-000cmR-2b for pgpool-hackers@lists.postgresql.org; Fri, 03 Apr 2026 00:18:48 +0000 Date: Fri, 03 Apr 2026 09:18:42 +0900 (JST) Message-Id: <20260403.091842.102589579921239540.ishii@postgresql.org> To: pgpool-hackers@lists.postgresql.org Subject: Memory leak in a SSL module From: Tatsuo Ishii X-Mailer: Mew version 6.8 on Emacs 29.3 Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Fri_Apr__3_09_18_42_2026_274)--" Content-Transfer-Encoding: 7bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 2409:11:4120:300:bba:a076:86e7:5c41 (failed) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ----Next_Part(Fri_Apr__3_09_18_42_2026_274)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit load_dh_file() leaks memory when supplied DH parameters are not valid. It should have freed the memory returned by PEM_read_DHparams() using DH_free(). The module was first imported from PostgreSQL (commit 573bd08b99e277026e87bb55ae69c489fab321b8 2018/1/19) on 2019/6/18 by commit 51bc494aaa7fd191e14038204d18effe2efb0ec8. PostgreSQL found the memory leak later on and fixed it by commit e835e89a0fd267871e7fbddc39ad00ee3d0cb55c on 2021/3/20. While I'm at it, the copyright notice in the same file is fixed. Since the code was copied from PostgreSQL, we should retain the original PostgreSQL copyright notice. Patch attached. -- Tatsuo Ishii SRA OSS K.K. English: http://www.sraoss.co.jp/index_en/ Japanese:http://www.sraoss.co.jp ----Next_Part(Fri_Apr__3_09_18_42_2026_274)-- Content-Type: Text/X-Patch; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="fix_ssl_memory_leak.patch" diff --git a/src/utils/pool_ssl.c b/src/utils/pool_ssl.c index dda5bd0fb..7a5af7ca4 100644 --- a/src/utils/pool_ssl.c +++ b/src/utils/pool_ssl.c @@ -5,7 +5,9 @@ * pgpool: a language independent connection pool server for PostgreSQL * written by Tatsuo Ishii * - * Copyright (c) 2003-2021 PgPool Global Development Group + * Portions Copyright (c) 2003-2026, PgPool Global Development Group + * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California * * Permission to use, copy, modify, and distribute this software and * its documentation for any purpose and without fee is hereby @@ -965,12 +967,14 @@ load_dh_file(char *filename) ereport(WARNING, (errmsg("invalid DH parameters: %s", SSLerrmessage(ERR_get_error())))); + DH_free(dh); return NULL; } if (codes & DH_CHECK_P_NOT_PRIME) { ereport(WARNING, (errmsg("invalid DH parameters: p is not prime"))); + DH_free(dh); return NULL; } if ((codes & DH_NOT_SUITABLE_GENERATOR) && @@ -978,6 +982,7 @@ load_dh_file(char *filename) { ereport(WARNING, (errmsg("invalid DH parameters: neither suitable generator or safe prime"))); + DH_free(dh); return NULL; } ----Next_Part(Fri_Apr__3_09_18_42_2026_274)----