agora inbox for pgsql-committers@postgresql.org
help / color / mirror / Atom feedFrom: Noah Misch <noah@leadboat.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Guard against overflow in "left" fields of query_int and ltxtque
Date: Mon, 11 May 2026 12:19:38 +0000
Message-ID: <E1wMPbm-0002XB-0v@gemulon.postgresql.org> (raw)
Guard against overflow in "left" fields of query_int and ltxtquery.
contrib/intarray's query_int type uses an int16 field to hold the
offset from a binary operator node to its left operand. However, it
allows the number of nodes to be as much as will fit in MaxAllocSize,
so there is a risk of overflowing int16 depending on the precise shape
of the tree. Simple right-associative cases like "a | b | c | ..."
work fine, so we should not solve this by restricting the overall
number of nodes. Instead add a direct test of whether each individual
offset is too large.
contrib/ltree's ltxtquery type uses essentially the same logic and
has the same 16-bit restriction.
(The core backend's tsquery.c has a variant of this logic too, but
in that case the target field is 32 bits, so it is okay so long
as varlena datums are restricted to 1GB.)
In v16 and up, these types support soft error reporting, so we have
to complicate the recursive findoprnd function's API a bit to allow
the complaint to be reported softly. v14/v15 don't need that.
Undocumented and overcomplicated code like this makes my head hurt,
so add some comments and simplify while at it.
Reported-by: Xint Code
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Backpatch-through: 14
Security: CVE-2026-6473
Branch
------
REL_17_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/c4d04cc4810303427d2f6fcf914bb856af32cc52
Author: Tom Lane <tgl@sss.pgh.pa.us>
Modified Files
--------------
contrib/intarray/_int_bool.c | 82 +++++++++++++++++++++++++++++---------
contrib/intarray/expected/_int.out | 3 ++
contrib/intarray/sql/_int.sql | 2 +
contrib/ltree/expected/ltree.out | 3 ++
contrib/ltree/ltxtquery_io.c | 75 ++++++++++++++++++++++++++--------
contrib/ltree/sql/ltree.sql | 3 ++
6 files changed, 133 insertions(+), 35 deletions(-)
view thread (6+ messages) latest in thread
Message-ID: <E1wMPbm-0002XB-0v@gemulon.postgresql.org>
Permalink: ../E1wMPbm-0002XB-0v@gemulon.postgresql.org/
Also on: postgresql.org/message-id/E1wMPbm-0002XB-0v@gemulon.postgresql.org
reply
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-committers@postgresql.org
Cc: noah@leadboat.com, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Guard against overflow in "left" fields of query_int and ltxtque
In-Reply-To: <E1wMPbm-0002XB-0v@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox