From: Michael Paquier <michael@paquier.xyz>
To: Alexander Lakhin <exclusion@gmail.com>
Cc: Richard Guo <guofenglinux@gmail.com>
Cc: Ankit Kumar Pandey <itsankitkp@gmail.com>
Cc: David Rowley <dgrowleyml@gmail.com>
Cc: Teodor Sigaev <teodor@sigaev.ru>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17888: Incorrect memory access in gist__int_ops for an input array with many elements
Date: Wed, 14 Jun 2023 13:21:40 +0900
Message-ID: <ZIlAVBmmAhVaVGHR@paquier.xyz> (raw)
In-Reply-To: <f7ab52bb-e0ee-4acd-9bb1-ac28d22e39f5@gmail.com>
References: <17888-f72930e6b5ce8c14@postgresql.org>
<CAMbWs48s6Uhv9wngJVtv=7DGEyN9a-SzwBKsfz2hY7yS6z7ZQw@mail.gmail.com>
<f7ab52bb-e0ee-4acd-9bb1-ac28d22e39f5@gmail.com>
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
Attachments:
signature.asc (application/pgp-signature, 832B) download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: michael@paquier.xyz, exclusion@gmail.com, guofenglinux@gmail.com, itsankitkp@gmail.com, dgrowleyml@gmail.com, teodor@sigaev.ru, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17888: Incorrect memory access in gist__int_ops for an input array with many elements
In-Reply-To: <ZIlAVBmmAhVaVGHR@paquier.xyz>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox