Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit73c9f91

Browse files
committed
Parallel workers use AuthenticatedUserId for connection privilege checks.
Commit5a2fed9 had an unexpected side-effect: the parallel workerlaunched for the new test case would fail if it couldn't use asuperuser-reserved connection slot. The reason that test failedwhile all our pre-existing ones worked is that the connectionprivilege tests in InitPostgres had been based on the superusernessof the leader's AuthenticatedUserId, but after the rearrangementsof5a2fed9 we were testing the superuserness of CurrentUserId,which the new test case deliberately made to be a non-superuser.This all seems very accidental and probably not the behavior we reallywant, but a security patch is no time to be redesigning things.Pending some discussion about desirable semantics, hack it so thatInitPostgres continues to pay attention to the superuserness ofAuthenticatedUserId when starting a parallel worker.Nathan Bossart and Tom Lane, per buildfarm member sawshark.Security:CVE-2024-10978
1 parentc4252c9 commit73c9f91

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

‎src/backend/utils/init/postinit.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include"access/genam.h"
2323
#include"access/heapam.h"
2424
#include"access/htup_details.h"
25+
#include"access/parallel.h"
2526
#include"access/session.h"
2627
#include"access/tableam.h"
2728
#include"access/xact.h"
@@ -875,7 +876,23 @@ InitPostgres(const char *in_dbname, Oid dboid,
875876
{
876877
InitializeSessionUserId(username,useroid,
877878
(flags&INIT_PG_OVERRIDE_ROLE_LOGIN)!=0);
878-
am_superuser=superuser();
879+
880+
/*
881+
* In a parallel worker, set am_superuser based on the
882+
* authenticated user ID, not the current role. This is pretty
883+
* dubious but it matches our historical behavior. Note that this
884+
* value of am_superuser is used only for connection-privilege
885+
* checks here and in CheckMyDatabase (we won't reach
886+
* process_startup_options in a background worker).
887+
*
888+
* In other cases, there's been no opportunity for the current
889+
* role to diverge from the authenticated user ID yet, so we can
890+
* just rely on superuser() and avoid an extra catalog lookup.
891+
*/
892+
if (InitializingParallelWorker)
893+
am_superuser=superuser_arg(GetAuthenticatedUserId());
894+
else
895+
am_superuser=superuser();
879896
}
880897
}
881898
else

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp