pgsql: Do not let PostmasterContext survive into background workers. - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Do not let PostmasterContext survive into background workers.
Date
Msg-id E1bV1Dk-0006AZ-LM@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Do not let PostmasterContext survive into background workers.

We don't want postmaster child processes to contain a copy of the
postmaster's PostmasterContext.  That would be a waste of memory at least,
and at worst a security issue, since there are copies of the semi-sensitive
pg_hba and pg_ident data in there.  All other child process types delete
the PostmasterContext after forking, but the original coding of the
background worker patch (commit da07a1e85) did not do so.  It appears
that the only reason for that was to avoid copying the bgworker's
MyBgworkerEntry out of that context; but the couple of additional
statements needed to do so are hardly good justification for it.  Hence,
copy that data and then clear the context as other child processes do.

Because this patch changes the memory context in which a bgworker function
gains control, back-patching it would be a bit risky, so we won't fix this
in back branches.  The "security" complaint is pretty thin anyway for
generic bgworkers; only with the introduction of parallel query is there
any question of running untrusted code in a bgworker process.

Discussion: <14111.1470082717@sss.pgh.pa.us>

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/ef1b5af82339a49564037be656a3ff657fb2a246

Modified Files
--------------
src/backend/postmaster/postmaster.c | 17 ++++++++++++++---
src/backend/utils/mmgr/README       | 10 ++++++----
2 files changed, 20 insertions(+), 7 deletions(-)


pgsql-committers by date:

Previous
From: Peter Eisentraut
Date:
Subject: pgsql: Add missing casts in information schema
Next
From: Tom Lane
Date:
Subject: Re: pgsql: Add missing casts in information schema