Re: Preventing non-superusers from altering session authorization - Mailing list pgsql-hackers

From Joseph Koshakow
Subject Re: Preventing non-superusers from altering session authorization
Date
Msg-id CAAvxfHeUKFE-=biJO15mMD5SNFSqDJy1zX2G-4=tDQkwfaBosg@mail.gmail.com
Whole thread Raw
In response to Re: Preventing non-superusers from altering session authorization  (Nathan Bossart <nathandbossart@gmail.com>)
Responses Re: Preventing non-superusers from altering session authorization
List pgsql-hackers


On Sat, Jul 8, 2023 at 6:09 PM Nathan Bossart <nathandbossart@gmail.com> wrote:

>> I think the issue here is that if a session loses the ability to set
>> their session authorization in the middle of a transaction, then
>> rolling back the transaction may fail and cause the server to panic.
>> That's probably what the deleted comment mean when it said:
>>
>>> * It's OK because the check does not require catalog access and can't
>>> * fail during an end-of-transaction GUC reversion
>
> Yeah.  IIUC the ERROR longjmps to a block that calls AbortTransaction(),
> which ERRORs again when resetting the session authorization, which causes
> us to call AbortTransaction() again, etc., etc.

Everything seems to work fine if the privilege check is moved to
check_session_authorization. Which is maybe what the comment meant
instead of assign_session_authorization.

I've attached a patch with this change.

Thanks,
Joe Koshakow
Attachment

pgsql-hackers by date:

Previous
From: Nathan Bossart
Date:
Subject: Re: Preventing non-superusers from altering session authorization
Next
From: Thomas Munro
Date:
Subject: Re: check_strxfrm_bug()