Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iMOKT-0005n5-To for pgsql-bugs@arkaria.postgresql.org; Mon, 21 Oct 2019 03:25:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iMOKS-0000XU-IQ for pgsql-bugs@arkaria.postgresql.org; Mon, 21 Oct 2019 03:25:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iMOKS-0000XN-As for pgsql-bugs@lists.postgresql.org; Mon, 21 Oct 2019 03:25:56 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iMOKK-0000Oc-RL for pgsql-bugs@lists.postgresql.org; Mon, 21 Oct 2019 03:25:55 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 8C7B43B3; Sun, 20 Oct 2019 23:25:44 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Sun, 20 Oct 2019 23:25:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=TSuaDzLnGfXGfiNc8tsG0myjG1q SWPzQZhgul5Y80xs=; b=cHqxbWTt49p8z1JQMkDmUThr2W85qLdwkfWfUj5UIBF Jwt6OW1j1Pn3qo0RhSkrkIW8+03fNDpUa4+UbZ97zni3ZXhJ0vMZ2t+fy0NqJEij X0VCGFN+bCh3WL5qkUPk9nJpDnB1z0p3b4Ez8+WgI1+oj7iTWs9+C37+EskestTc rK1TKsOKQhzcjxExRbcucIAJccyxfLe0LgF3qtPhEGVCFs0aIQCfLHi+JbUYuIvO QLW7IqoMcd9NPN3uds9G8qvZIUgqpivh+7RPiwOUNbjWTr+2uiZTAIX8fzaIwmZu nIAHljPkqzd6X12MXSpnHeCHhC0rzxzDFps9sLrRNtQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=TSuaDz LnGfXGfiNc8tsG0myjG1qSWPzQZhgul5Y80xs=; b=eJVXYD+I74nVVnzZynPiat j7mZBgUPfSzAeI208Lf/KK39TYtZR/mhLy5ppVVEGJ9M6LBNlAkD1o+fhQLxumvM IchsYZAu5cNmkcGYnkCMpsyQSRn+f2zfNl8jSmT+7x0exkZbdqzX43yQM4K2GoFA WZjjQa9oER+/mQDaBqWc2hNjIgd99Wa1K6MnnfEL4DxP87eEuunKviMAX0xeU4CK TKGZ2IJEfIlwbChxN+xDASs84vaP//39gZhXfbSO0B/VPbDiZt6i6HMZBQ80TTd/ q//PlBRwsALMIwgthfWeDXLeFKQTIoQNBaC6KRX6qah4JiWz4QW/K1wj3lP74vrQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrkeeggdejtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecufghrlhcuvffnffculdefhedmnecujfgurhepfffhvf fukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhi vghruceomhhitghhrggvlhesphgrqhhuihgvrhdrgiihiieqnecuffhomhgrihhnpehoph gvnhhsshhlrdhorhhgpdhpohhsthhgrhgvshhqlhdrohhrghenucfkphepuddukedrvdeg uddrvdehtddrkeeinecurfgrrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprg hquhhivghrrdighiiinecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from paquier.xyz (mp76f1fa56.ap.nuro.jp [118.241.250.86]) by mail.messagingengine.com (Postfix) with ESMTPA id D83C680059; Sun, 20 Oct 2019 23:25:40 -0400 (EDT) Date: Mon, 21 Oct 2019 12:25:37 +0900 From: Michael Paquier To: Tom Lane Cc: wurongxin@xmu.edu.cn, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16070: A double-free bug in interfaces/libpq/fe-secure-openssl.c Message-ID: <20191021032537.GG1542@paquier.xyz> References: <16070-ffac944519a43c3f@postgresql.org> <13213.1571581031@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="TmwHKJoIRFM7Mu/A" Content-Disposition: inline In-Reply-To: <13213.1571581031@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --TmwHKJoIRFM7Mu/A Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sun, Oct 20, 2019 at 10:17:11AM -0400, Tom Lane wrote: > I don't really believe this; if there were a double-free problem here, > we'd surely have noticed it long since. Yeah. > Taking a look at the OpenSSL source code, it looks like engine_free_util > decrements a reference count and doesn't actually delete anything until > that's gone to zero. So maybe the refcount is 2 at the beginning of > this sequence? The docs of OpenSSL mention the use of both successively, where ENGINE_free() does the cleanup after ENGINE_by_id(), and ENGINE_finish() cleans up after ENGINE_init(): https://www.openssl.org/docs/man1.1.0/man3/ENGINE_finish.html And an actual issue is that we have no coverage for it: https://coverage.postgresql.org/src/interfaces/libpq/fe-secure-openssl.c.gcov.html -- Michael --TmwHKJoIRFM7Mu/A Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAl2tJTEACgkQnvQgOdby QH0o0A/+OeQfa2ewpo9JjIAYDHjCEENRonQjOHVblqDNQc1Q4V/u3CFbaBJhDJL3 FGwDqjRA8PM95Q2Oh23P+BQM+OK7bPjApMfEQYEmVQvwVT5RbQCKVqcSGq9aXJyp UUwX6a0NGn5DVuONA7c/FZYLel6ipCuFl5Xhp076LUhnOVR+SjJ5GbcFTULCJPwt 6B+HiR5xzn49okqQR3SxGWGGmQQXd9ajoyHvrBLU4oQasa+eFt3nOlsZZCcppFYx NDxfgxmpV4czde5DnFpArj83SZ0I7z3zMH58wkP/G5hS3SMILZsr3o2aIQfZEGIl GPIBFLCpICo2s1Lxz/7Jd5eEKsdUkyGOCCdjqROOfxWnguIubbvicbqET2V/ynXc F++zUeGKAuNC6GEmh68mMeZZ66Qfxp2PtbaOQpO8FW2rzAZ3YvmmjuJPU5bangXd FYq3t1ZwksnQuSGMUwyyX1WRD1KlpnA+R6Au5kfHjIKW3zck7Mh1QayamKb1XS6i wnrBL3UAiGf6NKIHfZ7oqC2F9vQxbMmdTnWLS4OJ82dhQ5H0QfzzWNXgurEC0TX3 Rtp4W9RcCpXbkqRXA3z8vbHjA2MDonRz3WFZHvoSeJl25/20+oFvI73s7i96zhlc xuYH2Y94V9VShAzsL+FARm61yzktvKoRiqPpE3E+Bt4ic/OzzyA= =ZF/s -----END PGP SIGNATURE----- --TmwHKJoIRFM7Mu/A--