pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix two NULL pointer dereferences when reading custom pgstats fr
Date: Thu, 05 Sep 2024 05:37:23 +0000
Message-ID: <E1sm5BK-000Cbz-UL@gemulon.postgresql.org> (raw)

Fix two NULL pointer dereferences when reading custom pgstats from file

There were two spots in pgstat_read_statsfile() where is was possible to
finish with a null-pointer-dereference crash for custom pgstats kinds:
- When reading stats for a fixed-numbered stats entry.
- When reading a variable stats entry with name serialization.
For both cases, these issues were reachable by starting a server after
changing shared_preload_libraries so as the stats written previously
could not be loaded.

The code is changed so as the stats are ignored in this case, like the
other code paths doing similar sanity checks.  Two WARNINGs are added to
be able to debug these issues.  A test is added for the case of
fixed-numbered stats with the module injection_points.

Oversights in 7949d9594582, spotted while looking at a different report.

Discussion: https://postgr.es/m/Ztj0Jftsn4xXuXtl@paquier.xyz

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/341e9a05e7b4c4fb2a1e539a5073dfd0e5b46735

Modified Files
--------------
src/backend/utils/activity/pgstat.c              | 12 ++++++++++++
src/test/modules/injection_points/t/001_stats.pl |  6 ++++++
2 files changed, 18 insertions(+)



Message-ID: <E1sm5BK-000Cbz-UL@gemulon.postgresql.org>
Permalink:  ../E1sm5BK-000Cbz-UL@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1sm5BK-000Cbz-UL@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: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix two NULL pointer dereferences when reading custom pgstats fr
  In-Reply-To: <E1sm5BK-000Cbz-UL@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