pgsql: Fix segment_bins corruption in dsa.c.

From: Thomas Munro <tmunro(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix segment_bins corruption in dsa.c.
Date: 2018-09-20 04:32:28
Message-ID: E1g2qdg-0002c5-Ae@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix segment_bins corruption in dsa.c.

If a segment has been freed by dsa.c because it is entirely empty, other
backends must make sure to unmap it before following links to new
segments that might happen to have the same index number, or they could
finish up looking at a defunct segment and then corrupt the segment_bins
lists. The correct protocol requires checking freed_segment_counter
after acquiring the area lock and before resolving any index number to a
segment. Add the missing checks and an assertion.

Back-patch to 10, where dsa.c first arrived.

Author: Thomas Munro
Reported-by: Tomas Vondra
Discussion: https://postgr.es/m/CAEepm%3D0thg%2Bja5zGVa7jBy-uqyHrTqTm8HGhEOtMmigGrAqTbw%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/38763d67784c6563d08dbea5c9f913fa174779b8

Modified Files
--------------
src/backend/utils/mmgr/dsa.c | 50 +++++++++++++++++++++++++++++++++++++++-----
1 file changed, 45 insertions(+), 5 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Thomas Munro 2018-09-20 04:32:49 pgsql: Fix segment_bins corruption in dsa.c.
Previous Message Laurenz Albe 2018-09-20 03:51:20 Re: pgsql: Allow concurrent-safe open() and fopen() in frontend code for Wi