get_controlfile() can leak fds in the backend

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема get_controlfile() can leak fds in the backend
Дата
Msg-id 20190227074728.GA15710@paquier.xyz
обсуждение исходный текст
Ответы Re: get_controlfile() can leak fds in the backend  (Fabien COELHO <coelho@cri.ensmp.fr>)
Re: get_controlfile() can leak fds in the backend  (Joe Conway <mail@joeconway.com>)
Список pgsql-hackers
Hi all,
(CC-ing Joe as of dc7d70e)

I was just looking at the offline checksum patch, and noticed some
sloppy coding in controldata_utils.c.  The control file gets opened in
get_controlfile(), and if it generates an error then the file
descriptor remains open.  As basic code rule in the backend we should
only use BasicOpenFile() when opening files, so I think that the issue
should be fixed as attached, even if this requires including fd.h for
the backend compilation which is kind of ugly.

Another possibility would be to just close the file descriptor before
any error, saving appropriately errno before issuing any %m portion,
but that still does not respect the backend policy regarding open().

We also do not have a wait event for the read() call, maybe we should
have one, but knowing that this gets called only for the SQL-level
functions accessing the control file, I don't really think that's
worth it.

Thoughts?
--
Michael

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Laurenz Albe
Дата:
Сообщение: Re: Remove Deprecated Exclusive Backup Mode
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: psql show URL with help