Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q9I18-0001Gk-6G for pgsql-bugs@arkaria.postgresql.org; Wed, 14 Jun 2023 04:21:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q9I16-0005f2-Vw for pgsql-bugs@arkaria.postgresql.org; Wed, 14 Jun 2023 04:21:56 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q9I15-0005Zn-Dt for pgsql-bugs@lists.postgresql.org; Wed, 14 Jun 2023 04:21:56 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q9I12-0025hq-5E for pgsql-bugs@lists.postgresql.org; Wed, 14 Jun 2023 04:21:54 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id B33DD3200657; Wed, 14 Jun 2023 00:21:49 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 14 Jun 2023 00:21:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1686716509; x=1686802909; bh=jY SqkAcXcD6htNiTEduSDDbPoRpDaeCX/Mp5uOJDz1k=; b=LCrX5yGj0DcuzdHlf4 b04a9pltuHia8kOHkXAPKRgMm8k9NaE1Ls2ofI9RaNBY63IgpGjK8tL9FlHd2dDi jYrzuALmXcYFy2uLa4L4bsB6qe4ht6eS1riMaL+LhdZ1Dnjtejl3txGNFg0x3FxG tkrr/TCZuST9Z/+VMH0XkTuaz5ermHzp8hTzYHec9WIwFZP7pqCuKDLvy9JAiaI5 oLCa/SR5JWFzT1gCMs782HgJW0kT3Tyay1CbA19HKGR5k5vxSajutPX2bFatVKoy RqVC65HT7cO4MMFdc3vJ/eURkv9Pu+TlvGvXlYTDNbw902ZWujzq/VmuELuXP8h7 5QPg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1686716509; x=1686802909; bh=jYSqkAcXcD6ht NiTEduSDDbPoRpDaeCX/Mp5uOJDz1k=; b=hbxrqyltHvTSCruANne5UZ1V6Gxz4 Ja6+ZS2zCUQPJqSQUz666Or65mIYg94/REG5hDOMJPyHHiehKLpubnnmFHSmz+Ey Lqor7H0Kw610oQbIIRxRn2EL30+oDcQPIcoftXbHXSUOI2Z5B4dI1OfLemKFgwGh TMcvFtoHx1L7OH//0BxsasAIgssvJE+PWRC6Z7MbSy/Y8Wq13GKPi9sI8IScmRM8 x/K2wd5mmmVHlbELqNpGfnJ1Y9hayLLen0dEJ0iQkrlIPLtRG9017v8eaurvr3OA r5J4Ez+yevjM6rYdGwZy2KI1Say+vhhb9Ap/kEHJ1SPjXb4cVhwuauGuA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrgeduledggedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvvefukfhfgggtuggjsehgtdorredt tddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesph grqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepffduleehgefhkeefgfeftdfh kedutddvhfdukeeggeehieekffelhfelkeehteefnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiih ii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 14 Jun 2023 00:21:45 -0400 (EDT) Date: Wed, 14 Jun 2023 13:21:40 +0900 From: Michael Paquier To: Alexander Lakhin Cc: Richard Guo , Ankit Kumar Pandey , David Rowley , Teodor Sigaev , pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17888: Incorrect memory access in gist__int_ops for an input array with many elements Message-ID: References: <17888-f72930e6b5ce8c14@postgresql.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="3HBXALYs/JrijTK8" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --3HBXALYs/JrijTK8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, May 31, 2023 at 09:00:00AM +0300, Alexander Lakhin wrote: > The NOTICE appeared there in commit 08ee64ebf5 (from year 2005) in an > attempt to get rid of flags (ISLEAFKEY(in)) [1] and probably expressed > an intention to play gently (don't break compatibility?). Good question. This commit or its related thread don't tell much. FWIW, these are two things that don't make much sense to me: 1) to allow the compression to work with that many elements with its code unable to handle that, while storing incorrect data. 2) the decompression fails entirely to cope with that. > The patch proposed at [2] looks correct to me. Thank you, Ankit! > Though I would add a simple case to the intarray regression test and also > add errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED) to other two places in > _int_gist.c for the sake of consistency. The error is different in ~9.6 and 10~, where we would not get a crash before that. But We do get a lot of write past chunk end WARNINGs instead. Saying that, being able to corrupt the server at will with a gist operator that can be installed is no good either, so your suggestion of made of the two patches is OK by me. Based on my read of the code, this prevents the compression to store data it would not be able to handle on decompression. Now, I have to admit that I am not the most verse with this area. Likely that's something we'd better backpatch, to avoid people playing with that too much in the back-branches. Thoughts or objections? -- Michael --3HBXALYs/JrijTK8 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmSJQFQACgkQnvQgOdby QH18Rg/9E4ePwg3lnrflswbid0vMxwi2dVYUFDqh1AKwYzImI/M4zTeS8b1X8P1I /+IdXkFdTsaub/WdKfsPX4zo2w9vA/y4KJdnPWcm3R6GwjCYJay6Du4Mr2Nj+ti+ 0yQ7gKk1aYEOMI1PZFMRoJQu4oe/XF0EgnqvMLAfO9IP0ios3eOX/dW/YjeCCtOP rW455ldMgr+lyB9ZYx/hsbgOL5SmM25YJhSeFKi103JDlRGJh6bN+CB8XN4aPot+ WNh6aNGd5c/LDK/z/wj0fk5cDv/MSeuGB3obOW4lygOfSGprGukXxCxYSVAVaXCg XDo4evM//NQA7UxX0Ovzj4qr+/5Ayrw/pR41k2XWX3TPjDUazN1CQYp6632cqNtJ gnatoGIMha8qlhz1y8K8Iv/GfD7cxh001RuEFo7CkM1YG3CqQ8Co1mmdz3XEnVh2 pUs/BEC5yyRP6kLu4jUQbf0GnlsibNOwIuRSuvXrw+D0GyA32VW4MEioyrG+BULR 7AyStVvrF8oga3m1NafjyUGQNfr85vEubNZxi2+y0z+9MFx8j7Fd2eOrf1nsI2TY tIfQpwyxHGsE8ZQvxEiFuom841ZFUckcnnIvioPC1w5K7HBkuySnTJeHzXlwQsN0 1o7bMv4fLXbfVXFgHulXhT/QJ/K7UZtA32nixJ78VDt4DbZMdjM= =RVzl -----END PGP SIGNATURE----- --3HBXALYs/JrijTK8--