pgsql: Disallow execution of SPI functions during plperl function compi

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Disallow execution of SPI functions during plperl function compi
Дата
Msg-id E1nNjGp-000N2r-Ac@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Disallow execution of SPI functions during plperl function compilation.

Perl can be convinced to execute user-defined code during compilation
of a plperl function (or at least a plperlu function).  That's not
such a big problem as long as the activity is confined within the
Perl interpreter, and it's not clear we could do anything about that
anyway.  However, if such code tries to use plperl's SPI functions,
we have a bigger problem.  In the first place, those functions are
likely to crash because current_call_data->prodesc isn't set up yet.
In the second place, because it isn't set up, we lack critical info
such as whether the function is supposed to be read-only.  And in
the third place, this path allows code execution during function
validation, which is strongly discouraged because of the potential
for security exploits.  Hence, reject execution of the SPI functions
until compilation is finished.

While here, add check_spi_usage_allowed() calls to various functions
that hadn't gotten the memo about checking that.  I think that perhaps
plperl_sv_to_literal may have been intentionally omitted on the grounds
that it was safe at the time; but if so, the addition of transforms
functionality changed that.  The others are more recently added and
seem to be flat-out oversights.

Per report from Mark Murawski.  Back-patch to all supported branches.

Discussion: https://postgr.es/m/9acdf918-7fff-4f40-f750-2ffa84f083d2@intellasoft.net

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/4936747c477270e133e622bf6d7a12fa246cf3a7

Modified Files
--------------
src/pl/plperl/plperl.c | 29 +++++++++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)


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

Предыдущее
От: Andres Freund
Дата:
Сообщение: pgsql: pg_waldump: Fix error message for WAL files smaller than XLOG_BL
Следующее
От: Andres Freund
Дата:
Сообщение: pgsql: Add further debug info to help debug 019_replslot_limit.pl failu