diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2015-07-01 18:55:39 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2015-07-01 18:55:39 -0400 |
commit | 1e24cf645d24aab3ea39a9d259897fd0cae4e4b6 (patch) | |
tree | b8ec54a1fec2d47dce369ee473079eb799031e39 /src/backend/utils/init/postinit.c | |
parent | d7c19d68550eb6018e8581a73a351905f4cc435c (diff) | |
download | postgresql-1e24cf645d24aab3ea39a9d259897fd0cae4e4b6.tar.gz postgresql-1e24cf645d24aab3ea39a9d259897fd0cae4e4b6.zip |
Don't leave pg_hba and pg_ident data lying around in running backends.
Free the contexts holding this data after we're done using it, by the
expedient of attaching them to the PostmasterContext which we were
already taking care to delete (and where, indeed, this data used to live
before commits e5e2fc842c418432 and 7c45e3a3c682f855). This saves a
probably-usually-negligible amount of space per running backend. It also
avoids leaving potentially-security-sensitive data lying around in memory
in processes that don't need it. You'd have to be unusually paranoid to
think that that amounts to a live security bug, so I've not gone so far as
to forcibly zero the memory; but there surely isn't a good reason to keep
this data around.
Arguably this is a memory management bug in the aforementioned commits,
but it doesn't seem important enough to back-patch.
Diffstat (limited to 'src/backend/utils/init/postinit.c')
-rw-r--r-- | src/backend/utils/init/postinit.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c index 063b0653b49..0f04f281166 100644 --- a/src/backend/utils/init/postinit.c +++ b/src/backend/utils/init/postinit.c @@ -52,6 +52,7 @@ #include "utils/acl.h" #include "utils/fmgroids.h" #include "utils/guc.h" +#include "utils/memutils.h" #include "utils/pg_locale.h" #include "utils/portal.h" #include "utils/ps_status.h" @@ -190,6 +191,18 @@ PerformAuthentication(Port *port) * FIXME: [fork/exec] Ugh. Is there a way around this overhead? */ #ifdef EXEC_BACKEND + /* + * load_hba() and load_ident() want to work within the PostmasterContext, + * so create that if it doesn't exist (which it won't). We'll delete it + * again later, in PostgresMain. + */ + if (PostmasterContext == NULL) + PostmasterContext = AllocSetContextCreate(TopMemoryContext, + "Postmaster", + ALLOCSET_DEFAULT_MINSIZE, + ALLOCSET_DEFAULT_INITSIZE, + ALLOCSET_DEFAULT_MAXSIZE); + if (!load_hba()) { /* |