Re: [PATCH] Fix memory corruption in pg_shdepend.c

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Aleksander Alekseev <aleksander(at)timescale(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Sven Klemm <sven(at)timescale(dot)com>
Subject: Re: [PATCH] Fix memory corruption in pg_shdepend.c
Date: 2021-10-20 12:19:51
Message-ID: 202110201219.e7xgpipp4tve@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2021-Oct-20, Michael Paquier wrote:

> On Wed, Oct 20, 2021 at 01:01:31PM +0300, Aleksander Alekseev wrote:
> > I checked the rest of the PostgreSQL code and apparently, it should
> > have been tts_values[Anum_pg_shdepend_FOO - 1].
> >
> > The patch is attached. The problem was first reported offlist by Sven
> > Klemm. Investigated and fixed by me.
>
> Yes, that's indeed a one-off bug when copying shared dependencies of a
> template database to the new one. This is new as of e3931d0, so I'll
> take care of that and double-check the area while on.

Ouch ... this means that pg_shdepends contents are broken for databases
created with 14.0? hmm ... yes.

alvherre=# create role rol;
CREATE ROLE
alvherre=# create table blarg() ;
CREATE TABLE
alvherre=# alter table blarg owner to rol;
ALTER TABLE
alvherre=# create database bar template alvherre;
CREATE DATABASE
alvherre=# \c bar
Ahora está conectado a la base de datos «bar» con el usuario «alvherre».
bar=# select * from pg_shdepend;
dbid | classid | objid | objsubid | refclassid | refobjid | deptype
-------+---------+-------+----------+------------+----------+---------
0 | 0 | 0 | 0 | 1260 | 10 | p
0 | 0 | 0 | 0 | 1260 | 6171 | p
0 | 0 | 0 | 0 | 1260 | 6181 | p
0 | 0 | 0 | 0 | 1260 | 6182 | p
0 | 0 | 0 | 0 | 1260 | 3373 | p
0 | 0 | 0 | 0 | 1260 | 3374 | p
0 | 0 | 0 | 0 | 1260 | 3375 | p
0 | 0 | 0 | 0 | 1260 | 3377 | p
0 | 0 | 0 | 0 | 1260 | 4569 | p
0 | 0 | 0 | 0 | 1260 | 4570 | p
0 | 0 | 0 | 0 | 1260 | 4571 | p
0 | 0 | 0 | 0 | 1260 | 4200 | p
12975 | 1259 | 37686 | 0 | 1260 | 37685 | o
| 37689 | 1259 | 37686 | 0 | 1260 | 5
(14 filas)

bar=# select 37689::regclass;
regclass
----------
37689
(1 fila)

--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2021-10-20 12:24:08 Re: XTS cipher mode for cluster file encryption
Previous Message Daniel Gustafsson 2021-10-20 11:55:46 Re: [PATCH] Prefer getenv("HOME") to find the UNIX home directory