postgresql/src
Tom Lane 638300fef5 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
2022-02-25 17:40:43 -05:00
..
backend vacuumlazy.c: Remove obsolete num_tuples field. 2022-02-24 19:01:54 -08:00
bin pg_waldump: Fix error message for WAL files smaller than XLOG_BLCKSZ. 2022-02-25 10:30:05 -08:00
common Use bitwise rotate functions in more places 2022-02-20 13:22:08 +07:00
fe_utils Reject trailing junk after numeric literals 2022-02-16 10:37:31 +01:00
include Remove unnecessary heap_tuple_needs_freeze argument. 2022-02-24 18:31:07 -08:00
interfaces Reset conn->errorReported when PQrequestCancel sets errorMessage. 2022-02-20 15:02:41 -05:00
makefiles
pl Disallow execution of SPI functions during plperl function compilation. 2022-02-25 17:40:43 -05:00
port Simplify coding around path_contains_parent_reference(). 2022-01-31 13:53:38 -05:00
template
test Guard against reallocation failure in pg_regress 2022-02-24 20:58:18 +01:00
timezone Update copyright for 2022 2022-01-07 19:04:57 -05:00
tools Allow specifying row filters for logical replication of tables. 2022-02-22 08:11:50 +05:30
tutorial Update copyright for 2022 2022-01-07 19:04:57 -05:00
.gitignore
DEVELOPERS
Makefile
Makefile.global.in Add support for building with ZSTD. 2022-02-18 13:40:31 -05:00
Makefile.shlib AIX: Fix missing libpq symbols by respecting SHLIB_EXPORTS. 2021-09-06 11:27:59 -07:00
nls-global.mk