From 3f5d481ef5725494f8737db6f300a2c42afa915d Mon Sep 17 00:00:00 2001 From: Jeff Davis Date: Thu, 14 Oct 2021 12:25:30 -0700 Subject: [PATCH] Check criticalSharedRelcachesBuilt in GetSharedSecurityLabel(). An extension may want to call GetSecurityLabel() on a shared object before the shared relcaches are fully initialized. For instance, a ClientAuthentication_hook might want to retrieve the security label on a role. Discussion: https://postgr.es/m/ecb7af0b26e3be1d96d291c8453a86f1f82d9061.camel@j-davis.com Backpatch-through: 9.6 --- src/backend/commands/seclabel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/commands/seclabel.c b/src/backend/commands/seclabel.c index 5ee46905d8..1ce62b1e2c 100644 --- a/src/backend/commands/seclabel.c +++ b/src/backend/commands/seclabel.c @@ -169,8 +169,8 @@ GetSharedSecurityLabel(const ObjectAddress *object, const char *provider) pg_shseclabel = heap_open(SharedSecLabelRelationId, AccessShareLock); - scan = systable_beginscan(pg_shseclabel, SharedSecLabelObjectIndexId, true, - NULL, 3, keys); + scan = systable_beginscan(pg_shseclabel, SharedSecLabelObjectIndexId, + criticalSharedRelcachesBuilt, NULL, 3, keys); tuple = systable_getnext(scan); if (HeapTupleIsValid(tuple))