pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix potential buffer overrun in ts_rank_cd().
7+ messages / 1 participants
[nested] [flat]

* pgsql: Fix potential buffer overrun in tsvector_delete().
@ 2026-11-09 14:21 Noah Misch <noah@leadboat.com>
  0 siblings, 0 replies; 7+ messages in thread

From: Noah Misch @ 2026-11-09 14:21 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix potential buffer overrun in tsvector_delete().

tsvector_delete_by_indices() sized its output as VARSIZE(input) on the
assumption that the result can never be larger, but that only holds
when the input's lexeme data area is laid out in WordEntry order, like
the output's will be.  With a different ordering, additional pad bytes
could be needed for alignment of position data.  ts_type.h explicitly
says that a different lexeme data ordering is legal, and
tsvectorrecv() for one can produce other orderings.  To fix, use the
same solution as tsvector_concat(): allocate one extra byte per
output lexeme.  That's probably considerably more than enough, but
it's not worth working harder.

Reported-by: Anthropic OSS program
Author: Anthropic OSS program
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Backpatch-through: 14
Security: CVE-2026-116315

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/27dfe0e341c30cdc156a849034268f5dc38c1d29
Author: Tom Lane <tgl@sss.pgh.pa.us>

Modified Files
--------------
src/backend/utils/adt/tsvector_op.c | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix potential buffer overrun in ts_rank_cd().
@ 2026-11-09 14:21 Noah Misch <noah@leadboat.com>
  0 siblings, 0 replies; 7+ messages in thread

From: Noah Misch @ 2026-11-09 14:21 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix potential buffer overrun in ts_rank_cd().

get_docrep() assumed there could be no more QueryItems per group
than there are lexemes in the input tsvector.  That's true with valid
tsvector input, which will never show duplicate positions for any
lexeme.  But with duplicate positions it's possible to overrun the
allocated space.  Guard against that by dropping items if there are
more than we expect (it doesn't seem worth working harder than that).

The submitted test case that reached this constructed an invalid
tsvector by dint of starting with one, namely a tsvector containing
a zero position, which tsvectorrecv() failed to prevent before
10cc5aa96.  It's not clear whether the problem is reachable without
that.

Reported-by: Anthropic OSS program
Author: Anthropic OSS program
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Backpatch-through: 14
Security: CVE-2026-116317

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/c8d128858d20f424d06472a69e28b99849ed1bb6
Author: Tom Lane <tgl@sss.pgh.pa.us>

Modified Files
--------------
src/backend/utils/adt/tsrank.c | 14 ++++++++++++--
src/include/tsearch/ts_type.h  |  2 +-
2 files changed, 13 insertions(+), 3 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix potential buffer overrun in tsvector_delete().
@ 2026-11-09 14:21 Noah Misch <noah@leadboat.com>
  0 siblings, 0 replies; 7+ messages in thread

From: Noah Misch @ 2026-11-09 14:21 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix potential buffer overrun in tsvector_delete().

tsvector_delete_by_indices() sized its output as VARSIZE(input) on the
assumption that the result can never be larger, but that only holds
when the input's lexeme data area is laid out in WordEntry order, like
the output's will be.  With a different ordering, additional pad bytes
could be needed for alignment of position data.  ts_type.h explicitly
says that a different lexeme data ordering is legal, and
tsvectorrecv() for one can produce other orderings.  To fix, use the
same solution as tsvector_concat(): allocate one extra byte per
output lexeme.  That's probably considerably more than enough, but
it's not worth working harder.

Reported-by: Anthropic OSS program
Author: Anthropic OSS program
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Backpatch-through: 14
Security: CVE-2026-116315

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/418f055bf6904819e152ca1333d73bc8be3f7a69
Author: Tom Lane <tgl@sss.pgh.pa.us>

Modified Files
--------------
src/backend/utils/adt/tsvector_op.c | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix potential buffer overrun in ts_rank_cd().
@ 2026-11-09 14:21 Noah Misch <noah@leadboat.com>
  0 siblings, 0 replies; 7+ messages in thread

From: Noah Misch @ 2026-11-09 14:21 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix potential buffer overrun in ts_rank_cd().

get_docrep() assumed there could be no more QueryItems per group
than there are lexemes in the input tsvector.  That's true with valid
tsvector input, which will never show duplicate positions for any
lexeme.  But with duplicate positions it's possible to overrun the
allocated space.  Guard against that by dropping items if there are
more than we expect (it doesn't seem worth working harder than that).

The submitted test case that reached this constructed an invalid
tsvector by dint of starting with one, namely a tsvector containing
a zero position, which tsvectorrecv() failed to prevent before
10cc5aa96.  It's not clear whether the problem is reachable without
that.

Reported-by: Anthropic OSS program
Author: Anthropic OSS program
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Backpatch-through: 14
Security: CVE-2026-116317

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/f920b3c30ec7b502ba521a952ce411af4a9f827d
Author: Tom Lane <tgl@sss.pgh.pa.us>

Modified Files
--------------
src/backend/utils/adt/tsrank.c | 14 ++++++++++++--
src/include/tsearch/ts_type.h  |  2 +-
2 files changed, 13 insertions(+), 3 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix potential buffer overrun in tsvector_delete().
@ 2026-11-09 14:21 Noah Misch <noah@leadboat.com>
  0 siblings, 0 replies; 7+ messages in thread

From: Noah Misch @ 2026-11-09 14:21 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix potential buffer overrun in tsvector_delete().

tsvector_delete_by_indices() sized its output as VARSIZE(input) on the
assumption that the result can never be larger, but that only holds
when the input's lexeme data area is laid out in WordEntry order, like
the output's will be.  With a different ordering, additional pad bytes
could be needed for alignment of position data.  ts_type.h explicitly
says that a different lexeme data ordering is legal, and
tsvectorrecv() for one can produce other orderings.  To fix, use the
same solution as tsvector_concat(): allocate one extra byte per
output lexeme.  That's probably considerably more than enough, but
it's not worth working harder.

Reported-by: Anthropic OSS program
Author: Anthropic OSS program
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Backpatch-through: 14
Security: CVE-2026-116315

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/9c2cadacd61562ba7835179209c2aa9482f61d48
Author: Tom Lane <tgl@sss.pgh.pa.us>

Modified Files
--------------
src/backend/utils/adt/tsvector_op.c | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix potential buffer overrun in ts_rank_cd().
@ 2026-11-09 14:21 Noah Misch <noah@leadboat.com>
  0 siblings, 0 replies; 7+ messages in thread

From: Noah Misch @ 2026-11-09 14:21 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix potential buffer overrun in ts_rank_cd().

get_docrep() assumed there could be no more QueryItems per group
than there are lexemes in the input tsvector.  That's true with valid
tsvector input, which will never show duplicate positions for any
lexeme.  But with duplicate positions it's possible to overrun the
allocated space.  Guard against that by dropping items if there are
more than we expect (it doesn't seem worth working harder than that).

The submitted test case that reached this constructed an invalid
tsvector by dint of starting with one, namely a tsvector containing
a zero position, which tsvectorrecv() failed to prevent before
10cc5aa96.  It's not clear whether the problem is reachable without
that.

Reported-by: Anthropic OSS program
Author: Anthropic OSS program
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Backpatch-through: 14
Security: CVE-2026-116317

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/3e97c9a1fa19fb995e57a1a093cb7cee3f6da605
Author: Tom Lane <tgl@sss.pgh.pa.us>

Modified Files
--------------
src/backend/utils/adt/tsrank.c | 14 ++++++++++++--
src/include/tsearch/ts_type.h  |  2 +-
2 files changed, 13 insertions(+), 3 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix potential buffer overrun in tsvector_delete().
@ 2026-11-09 14:22 Noah Misch <noah@leadboat.com>
  0 siblings, 0 replies; 7+ messages in thread

From: Noah Misch @ 2026-11-09 14:22 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix potential buffer overrun in tsvector_delete().

tsvector_delete_by_indices() sized its output as VARSIZE(input) on the
assumption that the result can never be larger, but that only holds
when the input's lexeme data area is laid out in WordEntry order, like
the output's will be.  With a different ordering, additional pad bytes
could be needed for alignment of position data.  ts_type.h explicitly
says that a different lexeme data ordering is legal, and
tsvectorrecv() for one can produce other orderings.  To fix, use the
same solution as tsvector_concat(): allocate one extra byte per
output lexeme.  That's probably considerably more than enough, but
it's not worth working harder.

Reported-by: Anthropic OSS program
Author: Anthropic OSS program
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Backpatch-through: 14
Security: CVE-2026-116315

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/cacc71935952b1e47d852a9e9be3a548fc5ac40e
Author: Tom Lane <tgl@sss.pgh.pa.us>

Modified Files
--------------
src/backend/utils/adt/tsvector_op.c | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2026-11-09 14:22 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-11-09 14:21 pgsql: Fix potential buffer overrun in tsvector_delete(). Noah Misch <noah@leadboat.com>
2026-11-09 14:21 pgsql: Fix potential buffer overrun in ts_rank_cd(). Noah Misch <noah@leadboat.com>
2026-11-09 14:21 pgsql: Fix potential buffer overrun in tsvector_delete(). Noah Misch <noah@leadboat.com>
2026-11-09 14:21 pgsql: Fix potential buffer overrun in ts_rank_cd(). Noah Misch <noah@leadboat.com>
2026-11-09 14:21 pgsql: Fix potential buffer overrun in tsvector_delete(). Noah Misch <noah@leadboat.com>
2026-11-09 14:21 pgsql: Fix potential buffer overrun in ts_rank_cd(). Noah Misch <noah@leadboat.com>
2026-11-09 14:22 pgsql: Fix potential buffer overrun in tsvector_delete(). Noah Misch <noah@leadboat.com>

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