Re: get_controlfile() can leak fds in the backend

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Joe Conway <mail(at)joeconway(dot)com>
Cc: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: get_controlfile() can leak fds in the backend
Date: 2019-03-01 01:00:42
Message-ID: 20190301010042.GB1348@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Feb 28, 2019 at 04:09:32PM -0500, Joe Conway wrote:
> Committed and push that way.

Thanks for committing a fix.

> By the way, while looking at this, I noted at least a couple of places
> where OpenTransientFile() is being passed O_RDWR when the usage is
> pretty clearly intended to be read-only. For example at least two
> instances in slru.c -- SlruPhysicalReadPage() and
> SimpleLruDoesPhysicalPageExist(). Is it worth while searching for and
> fixing those instances?

There are roughly 40~42 callers of OpenTransientFile(). Looking at
them I can see that RestoreSlotFromDisk() could also switch to RDONLY
instead of RDWR. I am also a bit tired of the lack error handling
around CloseTransientFile(). While in some code paths the file
descriptors are closed for an error, in some others we should report
something. I am going to send a patch after a lookup. Let's see all
that on a separate thread.
--
Michael

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2019-03-01 01:11:53 Re: get_controlfile() can leak fds in the backend
Previous Message Andres Freund 2019-03-01 00:49:47 Re: jsonpath