pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Defend against stack overrun in a few more places.
Date: Wed, 24 Aug 2022 17:02:43 +0000
Message-ID: <E1oQtm6-0011Jw-5S@gemulon.postgresql.org> (raw)

Defend against stack overrun in a few more places.

SplitToVariants() in the ispell code, lseg_inside_poly() in geo_ops.c,
and regex_selectivity_sub() in selectivity estimation could recurse
until stack overflow; fix by adding check_stack_depth() calls.
So could next() in the regex compiler, but that case is better fixed by
converting its tail recursion to a loop.  (We probably get better code
that way too, since next() can now be inlined into its sole caller.)

There remains a reachable stack overrun in the Turkish stemmer, but
we'll need some advice from the Snowball people about how to fix that.

Per report from Egor Chindyaskin and Alexander Lakhin.  These mistakes
are old, so back-patch to all supported branches.

Richard Guo and Tom Lane

Discussion: https://postgr.es/m/1661334672.728714027@f473.i.mail.ru

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/f5157a9acc9d0c2b3d4a95b2967eae97451b671d

Modified Files
--------------
src/backend/regex/regc_lex.c     | 5 +++--
src/backend/tsearch/spell.c      | 4 ++++
src/backend/utils/adt/geo_ops.c  | 3 +++
src/backend/utils/adt/selfuncs.c | 3 +++
4 files changed, 13 insertions(+), 2 deletions(-)



view thread (7+ messages)  latest in thread

Message-ID: <E1oQtm6-0011Jw-5S@gemulon.postgresql.org>
Permalink:  ../E1oQtm6-0011Jw-5S@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1oQtm6-0011Jw-5S@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Defend against stack overrun in a few more places.
  In-Reply-To: <E1oQtm6-0011Jw-5S@gemulon.postgresql.org>
  References: <E1oQtm6-0011Jw-5S@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 DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox