forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit4203842
committed
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 canbe found out or guessed by other users too, making the session's seriesof random(3) values fairly predictable. Up to now, our backend-internaluses of random(3) haven't seemed security-critical, but commit88bdbd3added one that potentially is: when using log_statement_sample_rate, auser might be able to predict which of his SQL statements will get logged.To improve this situation, upgrade the per-process seed initializationmethod to use pg_strong_random() if available, greatly reducing thepredictability of the initial seed value. This adds a few tens ofmicroseconds to process start time, but since backend startup time isat least a couple of milliseconds, that seems an acceptable price.This means that pg_strong_random() needs to be able to run withoutreliance on any backend infrastructure, since it will be invokedbefore any of that is up. It was safe for that already, but adjustcomments and #include commands to make it clearer.Discussion:https://postgr.es/m/3859.1545849900@sss.pgh.pa.us1 parent6645ad6 commit4203842
2 files changed
+31
-14
lines changedLines changed: 25 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2520 | 2520 |
| |
2521 | 2521 |
| |
2522 | 2522 |
| |
2523 |
| - | |
| 2523 | + | |
2524 | 2524 |
| |
2525 | 2525 |
| |
2526 | 2526 |
| |
2527 | 2527 |
| |
| 2528 | + | |
| 2529 | + | |
2528 | 2530 |
| |
2529 | 2531 |
| |
2530 | 2532 |
| |
| |||
2539 | 2541 |
| |
2540 | 2542 |
| |
2541 | 2543 |
| |
2542 |
| - | |
2543 |
| - | |
2544 |
| - | |
2545 |
| - | |
2546 |
| - | |
| 2544 | + | |
| 2545 | + | |
| 2546 | + | |
| 2547 | + | |
| 2548 | + | |
| 2549 | + | |
| 2550 | + | |
2547 | 2551 |
| |
2548 |
| - | |
| 2552 | + | |
| 2553 | + | |
| 2554 | + | |
| 2555 | + | |
| 2556 | + | |
| 2557 | + | |
| 2558 | + | |
| 2559 | + | |
| 2560 | + | |
| 2561 | + | |
| 2562 | + | |
| 2563 | + | |
2549 | 2564 |
| |
2550 |
| - | |
| 2565 | + | |
| 2566 | + | |
| 2567 | + | |
2551 | 2568 |
| |
2552 | 2569 |
| |
2553 | 2570 |
| |
|
Lines changed: 6 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
6 | 6 |
| |
7 | 7 |
| |
8 | 8 |
| |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
9 | 13 |
| |
10 | 14 |
| |
11 | 15 |
| |
| |||
14 | 18 |
| |
15 | 19 |
| |
16 | 20 |
| |
17 |
| - | |
18 |
| - | |
19 |
| - | |
20 |
| - | |
21 |
| - | |
| 21 | + | |
22 | 22 |
| |
23 | 23 |
| |
24 | 24 |
| |
| |||
44 | 44 |
| |
45 | 45 |
| |
46 | 46 |
| |
47 |
| - | |
| 47 | + | |
48 | 48 |
| |
49 | 49 |
| |
50 | 50 |
| |
|
0 commit comments
Comments
(0)