Misplaced superuser check in pg_log_backend_memory_contexts() - Mailing list pgsql-hackers

From Michael Paquier
Subject Misplaced superuser check in pg_log_backend_memory_contexts()
Date
Msg-id YLxw1uVGIAP5uMPl@paquier.xyz
Whole thread Raw
Responses Re: Misplaced superuser check in pg_log_backend_memory_contexts()  (Julien Rouhaud <rjuju123@gmail.com>)
Re: Misplaced superuser check in pg_log_backend_memory_contexts()  (Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>)
List pgsql-hackers
Hi all,

While reading the code of pg_log_backend_memory_contexts(), I have
been surprised to see that the code would attempt to look at a PROC
entry based on the given input PID *before* checking if the function
has been called by a superuser.  This does not strike me as a good
idea as this allows any users to call this function and to take
ProcArrayLock in shared mode, freely.

It seems to me that we had better check for a superuser at the
beginning of the function, like in the attached.

Thanks,
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Julien Rouhaud
Date:
Subject: Re: Hook for extensible parsing.
Next
From: Julien Rouhaud
Date:
Subject: Re: Misplaced superuser check in pg_log_backend_memory_contexts()