postgresql/src/backend
Tom Lane 4203842a1c Use pg_strong_random() to select each server process's random seed.
Previously we just set the seed based on process ID and start timestamp.
Both those values are directly available within the session, and can
be found out or guessed by other users too, making the session's series
of random(3) values fairly predictable.  Up to now, our backend-internal
uses of random(3) haven't seemed security-critical, but commit 88bdbd3f7
added one that potentially is: when using log_statement_sample_rate, a
user might be able to predict which of his SQL statements will get logged.

To improve this situation, upgrade the per-process seed initialization
method to use pg_strong_random() if available, greatly reducing the
predictability of the initial seed value.  This adds a few tens of
microseconds to process start time, but since backend startup time is
at least a couple of milliseconds, that seems an acceptable price.

This means that pg_strong_random() needs to be able to run without
reliance on any backend infrastructure, since it will be invoked
before any of that is up.  It was safe for that already, but adjust
comments and #include commands to make it clearer.

Discussion: https://postgr.es/m/3859.1545849900@sss.pgh.pa.us
2018-12-29 17:56:06 -05:00
..
access Remove obsolete IndexIs* macros 2018-12-27 10:07:46 +01:00
bootstrap Make type "name" collation-aware. 2018-12-19 17:46:25 -05:00
catalog Remove obsolete IndexIs* macros 2018-12-27 10:07:46 +01:00
commands Remove obsolete IndexIs* macros 2018-12-27 10:07:46 +01:00
executor Fix thinko in previous commit 2018-12-28 15:18:00 -03:00
foreign Introduce new extended routines for FDW and foreign server lookups 2018-12-14 08:59:35 +09:00
jit Fix jit compilation bug on wide tables. 2018-11-27 10:07:03 -08:00
lib Rename rbtree.c functions to use "rbt" prefix not "rb" prefix. 2018-11-06 13:25:24 -05:00
libpq Fix typo 2018-12-04 11:04:54 -05:00
main Update copyright for 2018 2018-01-02 23:30:12 -05:00
nodes Add WRITE_*_ARRAY macros 2018-12-22 07:45:13 +01:00
optimizer Remove obsolete IndexIs* macros 2018-12-27 10:07:46 +01:00
parser Remove obsolete IndexIs* macros 2018-12-27 10:07:46 +01:00
partitioning Reduce unnecessary list construction in RelationBuildPartitionDesc. 2018-11-19 12:10:41 -05:00
po Translation updates 2018-06-25 12:37:18 +02:00
port Fix spelling errors and typos in comments 2018-11-02 13:56:52 +01:00
postmaster Use pg_strong_random() to select each server process's random seed. 2018-12-29 17:56:06 -05:00
regex Clean up warnings from -Wimplicit-fallthrough. 2018-05-01 19:35:08 -04:00
replication Add timestamp of last received message from standby to pg_stat_replication 2018-12-09 16:35:06 +09:00
rewrite Remove WITH OIDS support, change oid catalog column visibility. 2018-11-20 16:00:17 -08:00
snowball Sync our Snowball stemmer dictionaries with current upstream. 2018-09-24 17:29:38 -04:00
statistics Make pg_statistic and related code account more honestly for collations. 2018-12-14 12:52:49 -05:00
storage Have BufFileSize() ereport() on FileSize() failure. 2018-11-28 14:42:54 -08:00
tcop Silence compiler warning 2018-11-30 10:20:49 -03:00
tsearch Make pg_statistic and related code account more honestly for collations. 2018-12-14 12:52:49 -05:00
utils Use a separate random seed for SQL random()/setseed() functions. 2018-12-29 17:33:27 -05:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
Makefile Integrate recovery.conf into postgresql.conf 2018-11-25 16:33:40 +01:00
nls.mk Translation updates 2018-06-25 12:37:18 +02:00