pgsql: Fix race conditions with drop of reused pgstats entries

2024-11-14 Thread Michael Paquier
Fix race conditions with drop of reused pgstats entries This fixes a set of race conditions with cumulative statistics where a shared stats entry could be dropped while it should still be valid in the event when it is reused: an entry may refer to a different object but requires the same hash key.

pgsql: Fix race conditions with drop of reused pgstats entries

2024-11-14 Thread Michael Paquier
Fix race conditions with drop of reused pgstats entries This fixes a set of race conditions with cumulative statistics where a shared stats entry could be dropped while it should still be valid in the event when it is reused: an entry may refer to a different object but requires the same hash key.

pgsql: Fix race conditions with drop of reused pgstats entries

2024-11-14 Thread Michael Paquier
Fix race conditions with drop of reused pgstats entries This fixes a set of race conditions with cumulative statistics where a shared stats entry could be dropped while it should still be valid in the event when it is reused: an entry may refer to a different object but requires the same hash key.

pgsql: Fix race conditions with drop of reused pgstats entries

2024-11-14 Thread Michael Paquier
Fix race conditions with drop of reused pgstats entries This fixes a set of race conditions with cumulative statistics where a shared stats entry could be dropped while it should still be valid in the event when it is reused: an entry may refer to a different object but requires the same hash key.

pgsql: Replace postmaster.c's own backend type codes with BackendType

2024-11-14 Thread Heikki Linnakangas
Replace postmaster.c's own backend type codes with BackendType Introduce a separate BackendType for dead-end children, so that we don't need a separate dead_end flag. Reviewed-by: Andres Freund Discussion: https://www.postgresql.org/message-id/a102f15f-eac4-4ff2-af02-f9ff209ec...@iki.fi Branch

pgsql: Block environment variable mutations from trusted PL/Perl.

2024-11-14 Thread Noah Misch
Block environment variable mutations from trusted PL/Perl. Many process environment variables (e.g. PATH), bypass the containment expected of a trusted PL. Hence, trusted PLs must not offer features that achieve setenv(). Otherwise, an attacker having USAGE privilege on the language often can ac

pgsql: Fix improper interactions between session_authorization and role

2024-11-14 Thread Tom Lane
Fix improper interactions between session_authorization and role. The SQL spec mandates that SET SESSION AUTHORIZATION implies SET ROLE NONE. We tried to implement that within the lowest-level functions that manipulate these settings, but that was a bad idea. In particular, guc.c assumes that it

pgsql: Pass MyPMChildSlot as an explicit argument to child process

2024-11-14 Thread Heikki Linnakangas
Pass MyPMChildSlot as an explicit argument to child process All the other global variables passed from postmaster to child have the same value in all the processes, while MyPMChildSlot is more like a parameter to each child process. Reviewed-by: Andres Freund Discussion: https://www.postgresql.

pgsql: Last-minute updates for release notes.

2024-11-14 Thread Tom Lane
Last-minute updates for release notes. Security: CVE-2024-10976, CVE-2024-10977, CVE-2024-10978, CVE-2024-10979 Branch -- REL_13_STABLE Details --- https://git.postgresql.org/pg/commitdiff/b3db5fdb05b6ca499f75d0ecf290dbd057bfb075 Modified Files -- doc/src/sgml/release-13.sgm

pgsql: Kill dead-end children when there's nothing else left

2024-11-14 Thread Heikki Linnakangas
Kill dead-end children when there's nothing else left Previously, the postmaster would never try to kill dead-end child processes, even if there were no other processes left. A dead-end backend will eventually exit, when authentication_timeout expires, but if a dead-end backend is the only thing t

pgsql: Ensure cached plans are correctly marked as dependent on role.

2024-11-14 Thread Nathan Bossart
Ensure cached plans are correctly marked as dependent on role. If a CTE, subquery, sublink, security invoker view, or coercion projection references a table with row-level security policies, we neglected to mark the plan as potentially dependent on which role is executing it. This could lead to l

pgsql: Ensure cached plans are correctly marked as dependent on role.

2024-11-14 Thread Nathan Bossart
Ensure cached plans are correctly marked as dependent on role. If a CTE, subquery, sublink, security invoker view, or coercion projection references a table with row-level security policies, we neglected to mark the plan as potentially dependent on which role is executing it. This could lead to l

pgsql: Ensure cached plans are correctly marked as dependent on role.

2024-11-14 Thread Nathan Bossart
Ensure cached plans are correctly marked as dependent on role. If a CTE, subquery, sublink, security invoker view, or coercion projection references a table with row-level security policies, we neglected to mark the plan as potentially dependent on which role is executing it. This could lead to l

pgsql: Block environment variable mutations from trusted PL/Perl.

2024-11-14 Thread Noah Misch
Block environment variable mutations from trusted PL/Perl. Many process environment variables (e.g. PATH), bypass the containment expected of a trusted PL. Hence, trusted PLs must not offer features that achieve setenv(). Otherwise, an attacker having USAGE privilege on the language often can ac

pgsql: Block environment variable mutations from trusted PL/Perl.

2024-11-14 Thread Noah Misch
Block environment variable mutations from trusted PL/Perl. Many process environment variables (e.g. PATH), bypass the containment expected of a trusted PL. Hence, trusted PLs must not offer features that achieve setenv(). Otherwise, an attacker having USAGE privilege on the language often can ac

pgsql: Last-minute updates for release notes.

2024-11-14 Thread Tom Lane
Last-minute updates for release notes. Security: CVE-2024-10976, CVE-2024-10977, CVE-2024-10978, CVE-2024-10979 Branch -- REL_17_STABLE Details --- https://git.postgresql.org/pg/commitdiff/052aa02971f2dd476c14689033727a0b8563d5d2 Modified Files -- doc/src/sgml/release-17.sgm

pgsql: Block environment variable mutations from trusted PL/Perl.

2024-11-14 Thread Noah Misch
Block environment variable mutations from trusted PL/Perl. Many process environment variables (e.g. PATH), bypass the containment expected of a trusted PL. Hence, trusted PLs must not offer features that achieve setenv(). Otherwise, an attacker having USAGE privilege on the language often can ac

pgsql: Last-minute updates for release notes.

2024-11-14 Thread Tom Lane
Last-minute updates for release notes. Security: CVE-2024-10976, CVE-2024-10977, CVE-2024-10978, CVE-2024-10979 Branch -- REL_15_STABLE Details --- https://git.postgresql.org/pg/commitdiff/b83b358b1bac61ca46af995a3da83cc515a434c6 Modified Files -- doc/src/sgml/release-15.sgm

pgsql: Parallel workers use AuthenticatedUserId for connection privileg

2024-11-14 Thread Tom Lane
Parallel workers use AuthenticatedUserId for connection privilege checks. Commit 5a2fed911 had an unexpected side-effect: the parallel worker launched for the new test case would fail if it couldn't use a superuser-reserved connection slot. The reason that test failed while all our pre-existing o

pgsql: Last-minute updates for release notes.

2024-11-14 Thread Tom Lane
Last-minute updates for release notes. Security: CVE-2024-10976, CVE-2024-10977, CVE-2024-10978, CVE-2024-10979 Branch -- REL_12_STABLE Details --- https://git.postgresql.org/pg/commitdiff/aee114bf1c84368db9e50ba4e7340ce632f89e19 Modified Files -- doc/src/sgml/release-12.sgm

pgsql: Parallel workers use AuthenticatedUserId for connection privileg

2024-11-14 Thread Tom Lane
Parallel workers use AuthenticatedUserId for connection privilege checks. Commit 5a2fed911 had an unexpected side-effect: the parallel worker launched for the new test case would fail if it couldn't use a superuser-reserved connection slot. The reason that test failed while all our pre-existing o

pgsql: Parallel workers use AuthenticatedUserId for connection privileg

2024-11-14 Thread Tom Lane
Parallel workers use AuthenticatedUserId for connection privilege checks. Commit 5a2fed911 had an unexpected side-effect: the parallel worker launched for the new test case would fail if it couldn't use a superuser-reserved connection slot. The reason that test failed while all our pre-existing o

pgsql: Last-minute updates for release notes.

2024-11-14 Thread Tom Lane
Last-minute updates for release notes. Security: CVE-2024-10976, CVE-2024-10977, CVE-2024-10978, CVE-2024-10979 Branch -- REL_16_STABLE Details --- https://git.postgresql.org/pg/commitdiff/03dc78ff644ca0c090cb4cdbf8fba64230e54238 Modified Files -- doc/src/sgml/release-16.sgm

pgsql: Last-minute updates for release notes.

2024-11-14 Thread Tom Lane
Last-minute updates for release notes. Security: CVE-2024-10976, CVE-2024-10977, CVE-2024-10978, CVE-2024-10979 Branch -- REL_14_STABLE Details --- https://git.postgresql.org/pg/commitdiff/575d673fe78f76e396ea7eb8160c30d96ccfea0f Modified Files -- doc/src/sgml/release-14.sgm

pgsql: Parallel workers use AuthenticatedUserId for connection privileg

2024-11-14 Thread Tom Lane
Parallel workers use AuthenticatedUserId for connection privilege checks. Commit 5a2fed911 had an unexpected side-effect: the parallel worker launched for the new test case would fail if it couldn't use a superuser-reserved connection slot. The reason that test failed while all our pre-existing o

pgsql: Parallel workers use AuthenticatedUserId for connection privileg

2024-11-14 Thread Tom Lane
Parallel workers use AuthenticatedUserId for connection privilege checks. Commit 5a2fed911 had an unexpected side-effect: the parallel worker launched for the new test case would fail if it couldn't use a superuser-reserved connection slot. The reason that test failed while all our pre-existing o

pgsql: Parallel workers use AuthenticatedUserId for connection privileg

2024-11-14 Thread Tom Lane
Parallel workers use AuthenticatedUserId for connection privilege checks. Commit 5a2fed911 had an unexpected side-effect: the parallel worker launched for the new test case would fail if it couldn't use a superuser-reserved connection slot. The reason that test failed while all our pre-existing o

pgsql: Add needed .gitignore files in back branches.

2024-11-14 Thread Tom Lane
Add needed .gitignore files in back branches. v14 and earlier use generated test files, which require being .gitignore'd to avoid git complaints when testing in-tree. Security: CVE-2024-10979 Branch -- REL_14_STABLE Details --- https://git.postgresql.org/pg/commitdiff/f89bd92c963c3be30a

pgsql: Parallel workers use AuthenticatedUserId for connection privileg

2024-11-14 Thread Tom Lane
Parallel workers use AuthenticatedUserId for connection privilege checks. Commit 5a2fed911 had an unexpected side-effect: the parallel worker launched for the new test case would fail if it couldn't use a superuser-reserved connection slot. The reason that test failed while all our pre-existing o

pgsql: Fix cross-version upgrade tests.

2024-11-14 Thread Tom Lane
Fix cross-version upgrade tests. TestUpgradeXversion knows how to make the main regression database's references to pg_regress.so be version-independent. But it doesn't do that for plperl's database, so that the C function added by commit b7e3a52a8 is causing cross-version upgrade test failures.

pgsql: Avoid bizarre meson behavior with backslashes in command argumen

2024-11-14 Thread Tom Lane
Avoid bizarre meson behavior with backslashes in command arguments. Ooops, missed that v16 has another text2macro call in the MSVC scripts. Security: CVE-2024-10979 Branch -- REL_16_STABLE Details --- https://git.postgresql.org/pg/commitdiff/168579e23bdbeda1a140440c0272b335d53ad061 Mod

pgsql: Avoid bizarre meson behavior with backslashes in command argumen

2024-11-14 Thread Tom Lane
Avoid bizarre meson behavior with backslashes in command arguments. meson makes the backslashes in text2macro.pl's --strip argument into forward slashes, effectively disabling comment stripping. That hasn't caused us issues before, but it breaks the test case for b7e3a52a8. We don't really need t

pgsql: Fix cross-version upgrade tests.

2024-11-14 Thread Tom Lane
Fix cross-version upgrade tests. TestUpgradeXversion knows how to make the main regression database's references to pg_regress.so be version-independent. But it doesn't do that for plperl's database, so that the C function added by commit b7e3a52a8 is causing cross-version upgrade test failures.

pgsql: Fix improper interactions between session_authorization and role

2024-11-14 Thread Tom Lane
Fix improper interactions between session_authorization and role. The SQL spec mandates that SET SESSION AUTHORIZATION implies SET ROLE NONE. We tried to implement that within the lowest-level functions that manipulate these settings, but that was a bad idea. In particular, guc.c assumes that it

pgsql: Fix cross-version upgrade tests.

2024-11-14 Thread Tom Lane
Fix cross-version upgrade tests. TestUpgradeXversion knows how to make the main regression database's references to pg_regress.so be version-independent. But it doesn't do that for plperl's database, so that the C function added by commit b7e3a52a8 is causing cross-version upgrade test failures.

pgsql: Fix cross-version upgrade tests.

2024-11-14 Thread Tom Lane
Fix cross-version upgrade tests. TestUpgradeXversion knows how to make the main regression database's references to pg_regress.so be version-independent. But it doesn't do that for plperl's database, so that the C function added by commit b7e3a52a8 is causing cross-version upgrade test failures.

pgsql: Fix cross-version upgrade tests.

2024-11-14 Thread Tom Lane
Fix cross-version upgrade tests. TestUpgradeXversion knows how to make the main regression database's references to pg_regress.so be version-independent. But it doesn't do that for plperl's database, so that the C function added by commit b7e3a52a8 is causing cross-version upgrade test failures.

pgsql: Fix cross-version upgrade tests.

2024-11-14 Thread Tom Lane
Fix cross-version upgrade tests. TestUpgradeXversion knows how to make the main regression database's references to pg_regress.so be version-independent. But it doesn't do that for plperl's database, so that the C function added by commit b7e3a52a8 is causing cross-version upgrade test failures.

pgsql: Fix improper interactions between session_authorization and role

2024-11-14 Thread Tom Lane
Fix improper interactions between session_authorization and role. The SQL spec mandates that SET SESSION AUTHORIZATION implies SET ROLE NONE. We tried to implement that within the lowest-level functions that manipulate these settings, but that was a bad idea. In particular, guc.c assumes that it

pgsql: Fix cross-version upgrade tests.

2024-11-14 Thread Tom Lane
Fix cross-version upgrade tests. TestUpgradeXversion knows how to make the main regression database's references to pg_regress.so be version-independent. But it doesn't do that for plperl's database, so that the C function added by commit b7e3a52a8 is causing cross-version upgrade test failures.

pgsql: Add needed .gitignore files in back branches.

2024-11-14 Thread Tom Lane
Add needed .gitignore files in back branches. v14 and earlier use generated test files, which require being .gitignore'd to avoid git complaints when testing in-tree. Security: CVE-2024-10979 Branch -- REL_13_STABLE Details --- https://git.postgresql.org/pg/commitdiff/6bccd7b037d09b91ce

pgsql: Avoid bizarre meson behavior with backslashes in command argumen

2024-11-14 Thread Tom Lane
Avoid bizarre meson behavior with backslashes in command arguments. meson makes the backslashes in text2macro.pl's --strip argument into forward slashes, effectively disabling comment stripping. That hasn't caused us issues before, but it breaks the test case for b7e3a52a8. We don't really need t

pgsql: Fix improper interactions between session_authorization and role

2024-11-14 Thread Tom Lane
Fix improper interactions between session_authorization and role. The SQL spec mandates that SET SESSION AUTHORIZATION implies SET ROLE NONE. We tried to implement that within the lowest-level functions that manipulate these settings, but that was a bad idea. In particular, guc.c assumes that it

pgsql: Avoid bizarre meson behavior with backslashes in command argumen

2024-11-14 Thread Tom Lane
Avoid bizarre meson behavior with backslashes in command arguments. meson makes the backslashes in text2macro.pl's --strip argument into forward slashes, effectively disabling comment stripping. That hasn't caused us issues before, but it breaks the test case for b7e3a52a8. We don't really need t

pgsql: Fix improper interactions between session_authorization and role

2024-11-14 Thread Tom Lane
Fix improper interactions between session_authorization and role. The SQL spec mandates that SET SESSION AUTHORIZATION implies SET ROLE NONE. We tried to implement that within the lowest-level functions that manipulate these settings, but that was a bad idea. In particular, guc.c assumes that it

pgsql: Ensure cached plans are correctly marked as dependent on role.

2024-11-14 Thread Nathan Bossart
Ensure cached plans are correctly marked as dependent on role. If a CTE, subquery, sublink, security invoker view, or coercion projection references a table with row-level security policies, we neglected to mark the plan as potentially dependent on which role is executing it. This could lead to l

pgsql: Fix improper interactions between session_authorization and role

2024-11-14 Thread Tom Lane
Fix improper interactions between session_authorization and role. The SQL spec mandates that SET SESSION AUTHORIZATION implies SET ROLE NONE. We tried to implement that within the lowest-level functions that manipulate these settings, but that was a bad idea. In particular, guc.c assumes that it

pgsql: Add needed .gitignore files in back branches.

2024-11-14 Thread Tom Lane
Add needed .gitignore files in back branches. v14 and earlier use generated test files, which require being .gitignore'd to avoid git complaints when testing in-tree. Security: CVE-2024-10979 Branch -- REL_12_STABLE Details --- https://git.postgresql.org/pg/commitdiff/b1e58defb6a43fe355

pgsql: Block environment variable mutations from trusted PL/Perl.

2024-11-14 Thread Noah Misch
Block environment variable mutations from trusted PL/Perl. Many process environment variables (e.g. PATH), bypass the containment expected of a trusted PL. Hence, trusted PLs must not offer features that achieve setenv(). Otherwise, an attacker having USAGE privilege on the language often can ac

pgsql: Fix improper interactions between session_authorization and role

2024-11-14 Thread Tom Lane
Fix improper interactions between session_authorization and role. The SQL spec mandates that SET SESSION AUTHORIZATION implies SET ROLE NONE. We tried to implement that within the lowest-level functions that manipulate these settings, but that was a bad idea. In particular, guc.c assumes that it

pgsql: Ensure cached plans are correctly marked as dependent on role.

2024-11-14 Thread Nathan Bossart
Ensure cached plans are correctly marked as dependent on role. If a CTE, subquery, sublink, security invoker view, or coercion projection references a table with row-level security policies, we neglected to mark the plan as potentially dependent on which role is executing it. This could lead to l

pgsql: Ensure cached plans are correctly marked as dependent on role.

2024-11-14 Thread Nathan Bossart
Ensure cached plans are correctly marked as dependent on role. If a CTE, subquery, sublink, security invoker view, or coercion projection references a table with row-level security policies, we neglected to mark the plan as potentially dependent on which role is executing it. This could lead to l

pgsql: Ensure cached plans are correctly marked as dependent on role.

2024-11-14 Thread Nathan Bossart
Ensure cached plans are correctly marked as dependent on role. If a CTE, subquery, sublink, security invoker view, or coercion projection references a table with row-level security policies, we neglected to mark the plan as potentially dependent on which role is executing it. This could lead to l

pgsql: Block environment variable mutations from trusted PL/Perl.

2024-11-14 Thread Noah Misch
Block environment variable mutations from trusted PL/Perl. Many process environment variables (e.g. PATH), bypass the containment expected of a trusted PL. Hence, trusted PLs must not offer features that achieve setenv(). Otherwise, an attacker having USAGE privilege on the language often can ac

pgsql: Block environment variable mutations from trusted PL/Perl.

2024-11-14 Thread Noah Misch
Block environment variable mutations from trusted PL/Perl. Many process environment variables (e.g. PATH), bypass the containment expected of a trusted PL. Hence, trusted PLs must not offer features that achieve setenv(). Otherwise, an attacker having USAGE privilege on the language often can ac

pgsql: libpq: Bail out during SSL/GSS negotiation errors

2024-11-14 Thread Michael Paquier
libpq: Bail out during SSL/GSS negotiation errors This commit changes libpq so that errors reported by the backend during the protocol negotiation for SSL and GSS are discarded by the client, as these may include bytes that could be consumed by the client and write arbitrary bytes to a client's te

pgsql: libpq: Bail out during SSL/GSS negotiation errors

2024-11-14 Thread Michael Paquier
libpq: Bail out during SSL/GSS negotiation errors This commit changes libpq so that errors reported by the backend during the protocol negotiation for SSL and GSS are discarded by the client, as these may include bytes that could be consumed by the client and write arbitrary bytes to a client's te

pgsql: libpq: Bail out during SSL/GSS negotiation errors

2024-11-14 Thread Michael Paquier
libpq: Bail out during SSL/GSS negotiation errors This commit changes libpq so that errors reported by the backend during the protocol negotiation for SSL and GSS are discarded by the client, as these may include bytes that could be consumed by the client and write arbitrary bytes to a client's te

pgsql: libpq: Bail out during SSL/GSS negotiation errors

2024-11-14 Thread Michael Paquier
libpq: Bail out during SSL/GSS negotiation errors This commit changes libpq so that errors reported by the backend during the protocol negotiation for SSL and GSS are discarded by the client, as these may include bytes that could be consumed by the client and write arbitrary bytes to a client's te

pgsql: libpq: Bail out during SSL/GSS negotiation errors

2024-11-14 Thread Michael Paquier
libpq: Bail out during SSL/GSS negotiation errors This commit changes libpq so that errors reported by the backend during the protocol negotiation for SSL and GSS are discarded by the client, as these may include bytes that could be consumed by the client and write arbitrary bytes to a client's te

pgsql: libpq: Bail out during SSL/GSS negotiation errors

2024-11-14 Thread Michael Paquier
libpq: Bail out during SSL/GSS negotiation errors This commit changes libpq so that errors reported by the backend during the protocol negotiation for SSL and GSS are discarded by the client, as these may include bytes that could be consumed by the client and write arbitrary bytes to a client's te

pgsql: libpq: Bail out during SSL/GSS negotiation errors

2024-11-14 Thread Michael Paquier
libpq: Bail out during SSL/GSS negotiation errors This commit changes libpq so that errors reported by the backend during the protocol negotiation for SSL and GSS are discarded by the client, as these may include bytes that could be consumed by the client and write arbitrary bytes to a client's te

pgsql: Assign a child slot to every postmaster child process

2024-11-14 Thread Heikki Linnakangas
Assign a child slot to every postmaster child process Previously, only backends, autovacuum workers, and background workers had an entry in the PMChildFlags array. With this commit, all postmaster child processes, including all the aux processes, have an entry. Dead-end backends still don't get an

pgsql: Remove a useless cast to (void *) in hash_search() call

2024-11-14 Thread Peter Eisentraut
Remove a useless cast to (void *) in hash_search() call This pattern was previously cleaned up in 54a177a948b, but a new instance snuck in around the same time in 31966b151e6. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/a274bbb1b3655ae122bba792c8fb9ae8f0ac5b21