postgresql/src/include
Tom Lane 76123ded6e 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 doesn't matter in what order
it applies GUC variable updates, but that was not the case for these
two variables.  This problem, compounded by some hackish attempts to
work around it, led to some security-grade issues:

* Rolling back a transaction that had done SET SESSION AUTHORIZATION
would revert to SET ROLE NONE, even if that had not been the previous
state, so that the effective user ID might now be different from what
it had been.

* The same for SET SESSION AUTHORIZATION in a function SET clause.

* If a parallel worker inspected current_setting('role'), it saw
"none" even when it should see something else.

Also, although the parallel worker startup code intended to cope
with the current role's pg_authid row having disappeared, its
implementation of that was incomplete so it would still fail.

Fix by fully separating the miscinit.c functions that assign
session_authorization from those that assign role.  To implement the
spec's requirement, teach set_config_option itself to perform "SET
ROLE NONE" when it sets session_authorization.  (This is undoubtedly
ugly, but the alternatives seem worse.  In particular, there's no way
to do it within assign_session_authorization without incompatible
changes in the API for GUC assign hooks.)  Also, improve
ParallelWorkerMain to directly set all the relevant user-ID variables
instead of relying on some of them to get set indirectly.  That
allows us to survive not finding the pg_authid row during worker
startup.

In v16 and earlier, this includes back-patching 9987a7bf3 which
fixed a violation of GUC coding rules: SetSessionAuthorization
is not an appropriate place to be throwing errors from.

Security: CVE-2024-10978
2024-11-11 10:29:54 -05:00
..
access Unpin buffer before inplace update waits for an XID to end. 2024-10-29 09:40:00 -07:00
bootstrap Update copyrights for 2020 2020-01-01 12:21:45 -05:00
catalog Cope with inplace update making catcache stale during TOAST fetch. 2024-06-27 19:21:13 -07:00
commands doc: Add better description for rewrite functions in event triggers 2024-10-29 15:35:22 +09:00
common Fix corner-case 64-bit integer subtraction bug on some platforms. 2023-11-09 09:56:31 +00:00
datatype Update copyrights for 2020 2020-01-01 12:21:45 -05:00
executor Fix confusion about the return rowtype of SQL-language procedures. 2024-03-12 18:16:10 -04:00
fe_utils Move connect.h from fe_utils to src/include/common. 2020-08-10 09:22:58 -07:00
foreign Update copyrights for 2020 2020-01-01 12:21:45 -05:00
jit Monkey-patch LLVM code to fix ARM relocation bug. 2024-11-06 23:10:05 +13:00
lib simplehash: Free collisions array in SH_STAT 2024-04-07 19:09:07 -07:00
libpq Fix handling of SCRAM-SHA-256's channel binding with RSA-PSS certificates 2023-02-15 10:12:36 +09:00
mb Fix incautious handling of possibly-miscoded strings in client code. 2021-06-07 14:15:25 -04:00
nodes Ensure we allocate NAMEDATALEN bytes for names in Index Only Scans 2024-05-01 13:23:05 +12:00
optimizer Account for optimized MinMax aggregates during SS_finalize_plan. 2024-05-18 14:31:35 -04:00
parser Avoid unnecessary plancache revalidation of utility statements. 2023-08-24 12:02:40 -04:00
partitioning Fix hash partition pruning with asymmetric partition sets. 2021-01-28 13:41:55 -05:00
port Provide lstat() for Windows. 2024-11-08 09:45:58 +10:30
portability Update copyrights for 2020 2020-01-01 12:21:45 -05:00
postmaster Fix race condition between shutdown and unstarted background workers. 2020-12-24 17:00:43 -05:00
regex Cope with <regex.h> name clashes. 2024-07-06 10:39:10 +12:00
replication Fix possibility of logical decoding partial transaction changes. 2024-07-11 22:48:10 +09:00
rewrite Fix calculation of which GENERATED columns need to be updated. 2023-01-05 14:12:17 -05:00
snowball Update copyrights for 2020 2020-01-01 12:21:45 -05:00
statistics Initial pgindent and pgperltidy run for v13. 2020-05-14 13:06:50 -04:00
storage At end of recovery, reset all sinval-managed caches. 2024-10-25 06:51:08 -07:00
tcop Restrict accesses to non-system views and foreign tables during pg_dump. 2024-08-05 06:05:20 -07:00
tsearch Add comments and a missing CHECK_FOR_INTERRUPTS in ts_headline. 2022-11-21 17:07:07 -05:00
utils Revert "For inplace update, send nontransactional invalidations." 2024-11-02 09:05:07 -07:00
.gitignore Refactor dlopen() support 2018-09-06 11:33:04 +02:00
c.h Fix -Wcast-function-type warnings 2024-11-08 09:42:21 +10:30
fmgr.h Fix -Wcast-function-type warnings 2024-11-08 09:42:21 +10:30
funcapi.h Avoid holding a directory FD open across assorted SRF calls. 2020-03-16 21:05:52 -04:00
getaddrinfo.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
getopt_long.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
Makefile Get rid of jsonpath_gram.h and jsonpath_scanner.h 2019-03-20 11:13:34 +03:00
miscadmin.h Fix improper interactions between session_authorization and role. 2024-11-11 10:29:54 -05:00
pg_config.h.in Fix macro placement in pg_config.h.in 2024-07-26 14:16:40 +02:00
pg_config_ext.h.in Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_manual.h Fix concurrency issues with WAL segment recycling on Windows 2021-03-22 14:02:36 +09:00
pg_getopt.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_trace.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pgstat.h Fix waiting in RegisterSyncRequest(). 2022-03-16 15:37:15 +13:00
pgtar.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pgtime.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
port.h Check for STATUS_DELETE_PENDING on Windows. 2024-11-08 09:44:46 +10:30
postgres.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
postgres_ext.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
postgres_fe.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
rusagestub.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
windowapi.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00