pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Replace PostmasterRandom() with a stronger way of generating ran
21+ messages / 9 participants
[nested] [flat]

* pgsql: Replace PostmasterRandom() with a stronger way of generating ran
@ 2016-10-17 08:53  Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 1 reply; 21+ messages in thread

From: Heikki Linnakangas @ 2016-10-17 08:53 UTC (permalink / raw)
  To: pgsql-committers

Replace PostmasterRandom() with a stronger way of generating randomness.

This adds a new routine, pg_strong_random() for generating random bytes,
for use in both frontend and backend. At the moment, it's only used in
the backend, but the upcoming SCRAM authentication patches need strong
random numbers in libpq as well.

pg_strong_random() is based on, and replaces, the existing implementation
in pgcrypto. It can acquire strong random numbers from a number of sources,
depending on what's available:
- OpenSSL RAND_bytes(), if built with OpenSSL
- On Windows, the native cryptographic functions are used
- /dev/urandom
- /dev/random

Original patch by Magnus Hagander, with further work by Michael Paquier
and me.

Discussion: <CAB7nPqRy3krN8quR9XujMVVHYtXJ0_60nqgVc6oUk8ygyVkZsA@mail.gmail.com>

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/9e083fd4683294f41544e6d0d72f6e258ff3a77c

Modified Files
--------------
contrib/pgcrypto/Makefile           |   2 +-
contrib/pgcrypto/internal.c         |  40 +++---
contrib/pgcrypto/random.c           | 247 ------------------------------------
src/backend/libpq/auth.c            |  27 +++-
src/backend/postmaster/postmaster.c | 153 ++++++----------------
src/include/port.h                  |   3 +
src/port/Makefile                   |   2 +-
src/port/pg_strong_random.c         | 148 +++++++++++++++++++++
src/tools/msvc/Mkvcbuild.pm         |   6 +-
9 files changed, 244 insertions(+), 384 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 21+ messages in thread

* Re: [COMMITTERS] pgsql: Replace PostmasterRandom() with a stronger way of generating ran
@ 2016-10-17 14:50  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 2 replies; 21+ messages in thread

From: Tom Lane @ 2016-10-17 14:50 UTC (permalink / raw)
  To: Heikki Linnakangas <heikki.linnakangas@iki.fi>; +Cc: pgsql-hackers@postgresql.org

Heikki Linnakangas <heikki.linnakangas@iki.fi> writes:
> Replace PostmasterRandom() with a stronger way of generating randomness.

This patch broke padmeleon:

016-10-17 09:57:17.782 EDT [5804d8bd.57c2:1] LOG:  database system was shut down at 2016-10-17 09:57:17 EDT
2016-10-17 09:57:17.790 EDT [5804d8bd.57c2:2] LOG:  MultiXact member wraparound protections are now enabled
2016-10-17 09:57:17.807 EDT [5804d8bd.57c6:1] LOG:  autovacuum launcher started
2016-10-17 09:57:17.820 EDT [5804d8bd.57bf:1] LOG:  database system is ready to accept connections
2016-10-17 09:57:18.516 EDT [5804d8bd.57bf:2] LOG:  could not generate random query cancel key
2016-10-17 09:57:19.544 EDT [5804d8bd.57bf:3] LOG:  could not generate random query cancel key
2016-10-17 09:57:20.563 EDT [5804d8bd.57bf:4] LOG:  could not generate random query cancel key
2016-10-17 09:57:21.584 EDT [5804d8bd.57bf:5] LOG:  could not generate random query cancel key
2016-10-17 09:57:22.604 EDT [5804d8bd.57bf:6] LOG:  could not generate random query cancel key

It's failing because this machine lacks /dev/random and /dev/urandom.
It does have a non-kernel entropy daemon (prngd), which OpenSSL knows how
to read from but the hard-wired code in pg_strong_random() does not.

I'm not sure whether it's worth trying to make pg_strong_random() aware
of prngd.  The real issue here is whether we are willing to say that
Postgres simply does not work anymore on machines without standard entropy
sources.  Doesn't matter whether the user cares about the strength of
cancel keys, we're just blowing them off.  That seems a bit extreme
from here.  I think we should be willing to fall back to the old code
if we can't find a real entropy source.

			regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 21+ messages in thread

* Re: [COMMITTERS] pgsql: Replace PostmasterRandom() with a stronger way of generating ran
@ 2016-10-17 15:02  Robert Haas <robertmhaas@gmail.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 21+ messages in thread

From: Robert Haas @ 2016-10-17 15:02 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Heikki Linnakangas <heikki.linnakangas@iki.fi>; pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>

On Mon, Oct 17, 2016 at 10:50 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> The real issue here is whether we are willing to say that
> Postgres simply does not work anymore on machines without standard entropy
> sources.  Doesn't matter whether the user cares about the strength of
> cancel keys, we're just blowing them off.  That seems a bit extreme
> from here.  I think we should be willing to fall back to the old code
> if we can't find a real entropy source.

+1.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 21+ messages in thread

* Re: [COMMITTERS] pgsql: Replace PostmasterRandom() with a stronger way of generating ran
@ 2016-10-17 15:09  Heikki Linnakangas <hlinnaka@iki.fi>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 2 replies; 21+ messages in thread

From: Heikki Linnakangas @ 2016-10-17 15:09 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; Heikki Linnakangas <heikki.linnakangas@iki.fi>; +Cc: pgsql-hackers@postgresql.org

On 10/17/2016 05:50 PM, Tom Lane wrote:
> Heikki Linnakangas <heikki.linnakangas@iki.fi> writes:
>> Replace PostmasterRandom() with a stronger way of generating randomness.
>
> This patch broke padmeleon:
>
> 016-10-17 09:57:17.782 EDT [5804d8bd.57c2:1] LOG:  database system was shut down at 2016-10-17 09:57:17 EDT
> 2016-10-17 09:57:17.790 EDT [5804d8bd.57c2:2] LOG:  MultiXact member wraparound protections are now enabled
> 2016-10-17 09:57:17.807 EDT [5804d8bd.57c6:1] LOG:  autovacuum launcher started
> 2016-10-17 09:57:17.820 EDT [5804d8bd.57bf:1] LOG:  database system is ready to accept connections
> 2016-10-17 09:57:18.516 EDT [5804d8bd.57bf:2] LOG:  could not generate random query cancel key
> 2016-10-17 09:57:19.544 EDT [5804d8bd.57bf:3] LOG:  could not generate random query cancel key
> 2016-10-17 09:57:20.563 EDT [5804d8bd.57bf:4] LOG:  could not generate random query cancel key
> 2016-10-17 09:57:21.584 EDT [5804d8bd.57bf:5] LOG:  could not generate random query cancel key
> 2016-10-17 09:57:22.604 EDT [5804d8bd.57bf:6] LOG:  could not generate random query cancel key
>
> It's failing because this machine lacks /dev/random and /dev/urandom.
> It does have a non-kernel entropy daemon (prngd), which OpenSSL knows how
> to read from but the hard-wired code in pg_strong_random() does not.
>
> I'm not sure whether it's worth trying to make pg_strong_random() aware
> of prngd.

Seems simple enough..

>  The real issue here is whether we are willing to say that
> Postgres simply does not work anymore on machines without standard entropy
> sources.  Doesn't matter whether the user cares about the strength of
> cancel keys, we're just blowing them off.  That seems a bit extreme
> from here.  I think we should be willing to fall back to the old code
> if we can't find a real entropy source.

I'm scared of having pg_strong_random() that is willing to fall back to 
not-so-strong values. We can rename it, of course, but it seems 
dangerous to use a weak random-number generator for authentication 
purposes (query cancel, MD5 salts, SCRAM nonces).

I think both for the MD5 salt and SCRAM, it doesn't have to be 
unpredictable to attackers, as long the attacker cannot influence it so 
that a particular value is chosen. For query cancel, it needs to be 
unpredictable, but the query cancel key is quite short anyway, and we 
haven't worried about it so far anyway, because an attacker can't do 
very much damage by just canceling queries.

One option would be to disable query-canceling and MD5 (and SCRAM) 
authentication, if we don't have an entropy source.

- Heikki



-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 21+ messages in thread

* Re: Re: [COMMITTERS] pgsql: Replace PostmasterRandom() with a stronger way of generating ran
@ 2016-10-17 15:18  Stephen Frost <sfrost@snowman.net>
  parent: Heikki Linnakangas <hlinnaka@iki.fi>
  1 sibling, 0 replies; 21+ messages in thread

From: Stephen Frost @ 2016-10-17 15:18 UTC (permalink / raw)
  To: Heikki Linnakangas <hlinnaka@iki.fi>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Heikki Linnakangas <heikki.linnakangas@iki.fi>; pgsql-hackers@postgresql.org

* Heikki Linnakangas (hlinnaka@iki.fi) wrote:
> On 10/17/2016 05:50 PM, Tom Lane wrote:
> >Heikki Linnakangas <heikki.linnakangas@iki.fi> writes:
> >>Replace PostmasterRandom() with a stronger way of generating randomness.
> >
> >This patch broke padmeleon:
> >
> >016-10-17 09:57:17.782 EDT [5804d8bd.57c2:1] LOG:  database system was shut down at 2016-10-17 09:57:17 EDT
> >2016-10-17 09:57:17.790 EDT [5804d8bd.57c2:2] LOG:  MultiXact member wraparound protections are now enabled
> >2016-10-17 09:57:17.807 EDT [5804d8bd.57c6:1] LOG:  autovacuum launcher started
> >2016-10-17 09:57:17.820 EDT [5804d8bd.57bf:1] LOG:  database system is ready to accept connections
> >2016-10-17 09:57:18.516 EDT [5804d8bd.57bf:2] LOG:  could not generate random query cancel key
> >2016-10-17 09:57:19.544 EDT [5804d8bd.57bf:3] LOG:  could not generate random query cancel key
> >2016-10-17 09:57:20.563 EDT [5804d8bd.57bf:4] LOG:  could not generate random query cancel key
> >2016-10-17 09:57:21.584 EDT [5804d8bd.57bf:5] LOG:  could not generate random query cancel key
> >2016-10-17 09:57:22.604 EDT [5804d8bd.57bf:6] LOG:  could not generate random query cancel key
> >
> >It's failing because this machine lacks /dev/random and /dev/urandom.
> >It does have a non-kernel entropy daemon (prngd), which OpenSSL knows how
> >to read from but the hard-wired code in pg_strong_random() does not.
> >
> >I'm not sure whether it's worth trying to make pg_strong_random() aware
> >of prngd.
> 
> Seems simple enough..

If it is, then that's certainly tempting, especially if that's the only
platform we support where we don't have a better option, and we wish to
continue supporting it.

> > The real issue here is whether we are willing to say that
> >Postgres simply does not work anymore on machines without standard entropy
> >sources.  Doesn't matter whether the user cares about the strength of
> >cancel keys, we're just blowing them off.  That seems a bit extreme
> >from here.  I think we should be willing to fall back to the old code
> >if we can't find a real entropy source.
> 
> I'm scared of having pg_strong_random() that is willing to fall back
> to not-so-strong values. We can rename it, of course, but it seems
> dangerous to use a weak random-number generator for authentication
> purposes (query cancel, MD5 salts, SCRAM nonces).
> 
> I think both for the MD5 salt and SCRAM, it doesn't have to be
> unpredictable to attackers, as long the attacker cannot influence it
> so that a particular value is chosen. For query cancel, it needs to
> be unpredictable, but the query cancel key is quite short anyway,
> and we haven't worried about it so far anyway, because an attacker
> can't do very much damage by just canceling queries.
> 
> One option would be to disable query-canceling and MD5 (and SCRAM)
> authentication, if we don't have an entropy source.

Wouldn't it be possible to make this a build-time question..?  I don't
particularly like the idea of pg_strong_random() falling back to
not-strong values, but maybe we could have a '--use-weak-random'
configure switch for platforms that don't provide a strong source.

Then again, if we wish to support this platform, then perhaps we should
put in the effort to support prngd.

Thanks!

Stephen

Attachments:

  signature.asc (application/pgp-signature, 818B) download

^ permalink  raw  reply  [nested|flat] 21+ messages in thread

* Re: [COMMITTERS] pgsql: Replace PostmasterRandom() with a stronger way of generating ran
@ 2016-10-17 15:21  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Heikki Linnakangas <hlinnaka@iki.fi>
  1 sibling, 2 replies; 21+ messages in thread

From: Tom Lane @ 2016-10-17 15:21 UTC (permalink / raw)
  To: Heikki Linnakangas <hlinnaka@iki.fi>; +Cc: pgsql-hackers@postgresql.org

Heikki Linnakangas <hlinnaka@iki.fi> writes:
> On 10/17/2016 05:50 PM, Tom Lane wrote:
>> The real issue here is whether we are willing to say that
>> Postgres simply does not work anymore on machines without standard entropy
>> sources.  Doesn't matter whether the user cares about the strength of
>> cancel keys, we're just blowing them off.  That seems a bit extreme
>> from here.  I think we should be willing to fall back to the old code
>> if we can't find a real entropy source.

> I'm scared of having pg_strong_random() that is willing to fall back to 
> not-so-strong values. We can rename it, of course, but it seems 
> dangerous to use a weak random-number generator for authentication 
> purposes (query cancel, MD5 salts, SCRAM nonces).

I think that it's probably moot on all modern platforms, and even on
platforms as old as pademelon, the answer for people who care about
strong security is "--with-openssl".  What I'm on about here is whether
we should make people who don't care about that jump through hoops.
Not caring is a perfectly reasonable stance for non-exposed postmasters;
otherwise we wouldn't have the "trust" auth method.

I would be satisfied with making it a non-default build option, eg
add this to pg_strong_random:

	if (random_from_file("/dev/random", buf, len))
		return true;

+#ifdef ALLOW_WEAK_SECURITY
+	... old PostmasterRandom method here ...
+#endif
+
	/* None of the sources were available. */
	return false;

			regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 21+ messages in thread

* Re: [COMMITTERS] pgsql: Replace PostmasterRandom() with a stronger way of generating ran
@ 2016-10-17 15:33  Magnus Hagander <magnus@hagander.net>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 21+ messages in thread

From: Magnus Hagander @ 2016-10-17 15:33 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Heikki Linnakangas <hlinnaka@iki.fi>; PostgreSQL-development <pgsql-hackers@postgresql.org>

On Mon, Oct 17, 2016 at 8:21 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

> Heikki Linnakangas <hlinnaka@iki.fi> writes:
> > On 10/17/2016 05:50 PM, Tom Lane wrote:
> >> The real issue here is whether we are willing to say that
> >> Postgres simply does not work anymore on machines without standard
> entropy
> >> sources.  Doesn't matter whether the user cares about the strength of
> >> cancel keys, we're just blowing them off.  That seems a bit extreme
> >> from here.  I think we should be willing to fall back to the old code
> >> if we can't find a real entropy source.
>
> > I'm scared of having pg_strong_random() that is willing to fall back to
> > not-so-strong values. We can rename it, of course, but it seems
> > dangerous to use a weak random-number generator for authentication
> > purposes (query cancel, MD5 salts, SCRAM nonces).
>
> I think that it's probably moot on all modern platforms, and even on
> platforms as old as pademelon, the answer for people who care about
> strong security is "--with-openssl".  What I'm on about here is whether
> we should make people who don't care about that jump through hoops.
> Not caring is a perfectly reasonable stance for non-exposed postmasters;
> otherwise we wouldn't have the "trust" auth method.
>
> I would be satisfied with making it a non-default build option, eg
> add this to pg_strong_random:
>

+1 for that approach. I really wouldn't want to see it fall back completely
transparently in case something stops working. But if it's a non-default
build option, that's not a problem, and it should make it possible to make
it work on older platforms.

-- 
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/

^ permalink  raw  reply  [nested|flat] 21+ messages in thread

* Re: [COMMITTERS] pgsql: Replace PostmasterRandom() with a stronger way of generating ran
@ 2016-10-17 17:48  Heikki Linnakangas <hlinnaka@iki.fi>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 2 replies; 21+ messages in thread

From: Heikki Linnakangas @ 2016-10-17 17:48 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-hackers@postgresql.org

On 10/17/2016 06:21 PM, Tom Lane wrote:
> Heikki Linnakangas <hlinnaka@iki.fi> writes:
>> On 10/17/2016 05:50 PM, Tom Lane wrote:
>>> The real issue here is whether we are willing to say that
>>> Postgres simply does not work anymore on machines without standard entropy
>>> sources.  Doesn't matter whether the user cares about the strength of
>>> cancel keys, we're just blowing them off.  That seems a bit extreme
>>> from here.  I think we should be willing to fall back to the old code
>>> if we can't find a real entropy source.
>
>> I'm scared of having pg_strong_random() that is willing to fall back to
>> not-so-strong values. We can rename it, of course, but it seems
>> dangerous to use a weak random-number generator for authentication
>> purposes (query cancel, MD5 salts, SCRAM nonces).
>
> I think that it's probably moot on all modern platforms, and even on
> platforms as old as pademelon, the answer for people who care about
> strong security is "--with-openssl".  What I'm on about here is whether
> we should make people who don't care about that jump through hoops.
> Not caring is a perfectly reasonable stance for non-exposed postmasters;
> otherwise we wouldn't have the "trust" auth method.
>
> I would be satisfied with making it a non-default build option, eg
> add this to pg_strong_random:
>
> 	if (random_from_file("/dev/random", buf, len))
> 		return true;
>
> +#ifdef ALLOW_WEAK_SECURITY
> +	... old PostmasterRandom method here ...
> +#endif
> +
> 	/* None of the sources were available. */
> 	return false;

I also changed pgcrypto to use pg_strong_random(). Using a strong random 
number generator is even more important for pgcrypto, since it might be 
used for generating encryption keys. Would we allow a weak generator for 
pgcrypto too, with ALLOW_WEAK_SECURITY? If we don't, then pgcrypto test 
cases will still fail on pademelon. If we consider the option to be just 
for testing, never for production use, then we could allow it, but it 
feels a bit dangerous, and I'm not sure what's the point of testing a 
configuration that you should never use in production.

I'm going to try implementing prngd support. It seems easy enough, and 
prngd can be run on modern systems too, which is important for testing it.

In addition to that, I'm going to see if we can make postmaster to work 
sensibly without query cancel keys, if pg_strong_random() fails. That 
way, you could still run on platforms that don't have /dev/[u]random or 
prngd, just without support for query cancels, MD5 authentication, and 
pgcrypto key generation functions. I'd consider that similar to 
--disable-spinlocks; it would be a helpful step when porting to a new 
platform, but you wouldn't want to use it in production.

One more thing: in hindsight I think would be better to not fall back to 
/dev/ random, if compiled with OpenSSL support. It really shouldn't 
fail, and if it does, it seems better to complain loudly.

- Heikki



-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 21+ messages in thread

* Re: Re: [COMMITTERS] pgsql: Replace PostmasterRandom() with a stronger way of generating ran
@ 2016-10-17 18:14  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Heikki Linnakangas <hlinnaka@iki.fi>
  1 sibling, 1 reply; 21+ messages in thread

From: Tom Lane @ 2016-10-17 18:14 UTC (permalink / raw)
  To: Heikki Linnakangas <hlinnaka@iki.fi>; +Cc: pgsql-hackers@postgresql.org

Heikki Linnakangas <hlinnaka@iki.fi> writes:
> I'm going to try implementing prngd support. It seems easy enough, and 
> prngd can be run on modern systems too, which is important for testing it.

OK, if you feel like doing the work.  However:

> In addition to that, I'm going to see if we can make postmaster to work 
> sensibly without query cancel keys, if pg_strong_random() fails.

This seems like a lot of work, with the "reward" that we'd start getting
hard-to-debug reports about query cancel not working.  Anytime anyone
ever says "cancel didn't seem to work" we'd have to wonder whether there
had been a transient failure of pg_strong_random.  I think if we're
going to refuse to generate weak cancel keys, we should just fail,
not silently fall into a functionally degraded state.

But in general, I think that being this picky about cancel keys on systems
that are too old to have /dev/random is not really helpful to anybody.
I don't recall any reports of anyone ever having a DOS situation from
weak cancel keys.  It's fine to upgrade our practice where it's convenient
to do that, but taking away functionality on systems where it's not
convenient isn't improving anyone's life.

pg_crypto has a different set of tradeoffs and I don't necessarily make
the same argument there.  I don't feel that cancel keys have to act the
same as pg_crypto keys.

			regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 21+ messages in thread

* Re: Re: [COMMITTERS] pgsql: Replace PostmasterRandom() with a stronger way of generating ran
@ 2016-10-17 20:03  Robert Haas <robertmhaas@gmail.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 21+ messages in thread

From: Robert Haas @ 2016-10-17 20:03 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Heikki Linnakangas <hlinnaka@iki.fi>; pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>

On Mon, Oct 17, 2016 at 2:14 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> But in general, I think that being this picky about cancel keys on systems
> that are too old to have /dev/random is not really helpful to anybody.
> I don't recall any reports of anyone ever having a DOS situation from
> weak cancel keys.  It's fine to upgrade our practice where it's convenient
> to do that, but taking away functionality on systems where it's not
> convenient isn't improving anyone's life.

Right.  I strongly agree with that.  If somebody's running on a
platform where they don't have a good source of entropy, they are
clearly going to still want query cancel to work.  They are not going
to want ^C to start doing nothing, and they are *definitely* not going
to want PostgreSQL to fail to compile and/or start.  pgcrypto is a
different situation, but I think it's just crazy to say that the
problems with cancel keys are so bad that we should just refuse to run
at all.  Anyone who is in this situation has this problem not just
with PostgreSQL but with everything on their system that wishes it had
cryptographically strong random numbers, which is probably quite a bit
of stuff.  We shouldn't take the position that a machine without a
good PRNG is a brick.  They just have to accept that random number
generation will be weaker not only for PostgreSQL but for any software
whatever that they run on that machine.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 21+ messages in thread

* Re: Re: [COMMITTERS] pgsql: Replace PostmasterRandom() with a stronger way of generating ran
@ 2016-10-17 20:09  Robert Haas <robertmhaas@gmail.com>
  parent: Heikki Linnakangas <hlinnaka@iki.fi>
  1 sibling, 1 reply; 21+ messages in thread

From: Robert Haas @ 2016-10-17 20:09 UTC (permalink / raw)
  To: Heikki Linnakangas <hlinnaka@iki.fi>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>

On Mon, Oct 17, 2016 at 1:48 PM, Heikki Linnakangas <hlinnaka@iki.fi> wrote:
> I'm going to try implementing prngd support. It seems easy enough, and prngd
> can be run on modern systems too, which is important for testing it.

TBH, if pandemolon is the only system in the BF that doesn't have any
other source of entropy, I think that's going 100% in the wrong
direction.  Even with prngd support, this carries a significant risk
of effectively desupporting a large number of obscure UNIX platforms,
which I think is a bad decision.  It's fine (IMHO) to have
optimizations in the code here and there that cater to Windows and
Linux because those are the most widely-used platfoms, but we've been
pretty diligent about trying to be portable to a wide variety of
UNIX-like platforms.  I think that's a good decision, and reversing it
over the strength of cancel keys seems like letting the tail wag the
dog.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 21+ messages in thread

* Re: Re: [COMMITTERS] pgsql: Replace PostmasterRandom() with a stronger way of generating ran
@ 2016-10-17 20:35  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Robert Haas <robertmhaas@gmail.com>
  0 siblings, 1 reply; 21+ messages in thread

From: Tom Lane @ 2016-10-17 20:35 UTC (permalink / raw)
  To: Robert Haas <robertmhaas@gmail.com>; +Cc: Heikki Linnakangas <hlinnaka@iki.fi>; pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>

Robert Haas <robertmhaas@gmail.com> writes:
> On Mon, Oct 17, 2016 at 1:48 PM, Heikki Linnakangas <hlinnaka@iki.fi> wrote:
>> I'm going to try implementing prngd support. It seems easy enough, and prngd
>> can be run on modern systems too, which is important for testing it.

> TBH, if pandemolon is the only system in the BF that doesn't have any
> other source of entropy, I think that's going 100% in the wrong
> direction.  Even with prngd support, this carries a significant risk
> of effectively desupporting a large number of obscure UNIX platforms,
> which I think is a bad decision.  It's fine (IMHO) to have
> optimizations in the code here and there that cater to Windows and
> Linux because those are the most widely-used platfoms, but we've been
> pretty diligent about trying to be portable to a wide variety of
> UNIX-like platforms.  I think that's a good decision, and reversing it
> over the strength of cancel keys seems like letting the tail wag the
> dog.

This is largely my position as well.  A relevant point here is that prngd
did not come with that platform --- I had to install it after the fact.
(If memory serves, which it may not because this was years ago, I did so
because some new version of openssl started whining about lack of an
entropy source.)  Strong cancel keys are simply not important enough to
desupport a bunch of old platforms over.

I'm not convinced either way about pgcrypto.  It's certainly a reasonable
position that you want that to generate sound keys or else fail entirely.
But if nothing else on the platform is generating sound keys, do we want
to insist on being the first?

If we want it to fail, and don't want to retire pademelon, there are
multiple ways we could get to that goal:

* Enable --with-openssl in pademelon's build (don't really want to do
this, since I believe almost all the rest of the buildfarm tests with
openssl)

* Add variant expected-files (probably bad, it'd hide real failures)

* Add a configure option to suppress building/testing pgcrypto (maybe
just make it contingent on --with-openssl, which would allow deletion
of a bunch of code that duplicates openssl functionality...)

* Support reading entropy from prngd (but this means we have no buildfarm
coverage for entropy-daemon-less platforms)

None of these are perfect, but I'd say the last one is not so obviously
the best that we shouldn't consider alternatives.

			regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 21+ messages in thread

* Re: Re: [COMMITTERS] pgsql: Replace PostmasterRandom() with a stronger way of generating ran
@ 2016-10-18 01:50  Michael Paquier <michael.paquier@gmail.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 21+ messages in thread

From: Michael Paquier @ 2016-10-18 01:50 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Robert Haas <robertmhaas@gmail.com>; Heikki Linnakangas <hlinnaka@iki.fi>; pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>

On Tue, Oct 18, 2016 at 5:35 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> If we want it to fail, and don't want to retire pademelon, there are
> multiple ways we could get to that goal:
>
> * Enable --with-openssl in pademelon's build (don't really want to do
> this, since I believe almost all the rest of the buildfarm tests with
> openssl)

Yes, I don't think that's a good thing to make openssl installation
mandatory for this animal.

> * Add variant expected-files (probably bad, it'd hide real failures)
>
> * Add a configure option to suppress building/testing pgcrypto (maybe
> just make it contingent on --with-openssl, which would allow deletion
> of a bunch of code that duplicates openssl functionality...)
>
> * Support reading entropy from prngd (but this means we have no buildfarm
> coverage for entropy-daemon-less platforms)
>
> None of these are perfect, but I'd say the last one is not so obviously
> the best that we shouldn't consider alternatives.

In light of this discussion, it seems to me that we still want at the
end the --allow-weak-keys anyway as an extreme fallback, and this even
if there is additional support for prngd. An essential part is to
document the weakness of this option properly, like not using pgcrypto
with that if there is no other entropy source on an OS. By reading
this thread, the point is that we should not complicate the support
for obscure nix platforms, and it would be user-unfriendly to require
users to install prngd to get more entropy from the system.

And actually, enabling prngd would need to be controlled by a
configure switch as well disabled by default, no?
-- 
Michael


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 21+ messages in thread

* Re: Re: [COMMITTERS] pgsql: Replace PostmasterRandom() with a stronger way of generating ran
@ 2016-10-18 03:34  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Michael Paquier <michael.paquier@gmail.com>
  0 siblings, 1 reply; 21+ messages in thread

From: Tom Lane @ 2016-10-18 03:34 UTC (permalink / raw)
  To: Michael Paquier <michael.paquier@gmail.com>; +Cc: Robert Haas <robertmhaas@gmail.com>; Heikki Linnakangas <hlinnaka@iki.fi>; pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>

Michael Paquier <michael.paquier@gmail.com> writes:
> And actually, enabling prngd would need to be controlled by a
> configure switch as well disabled by default, no?

AFAICT, openssl has no configuration options related to prngd; they
seem to be able to use it automatically when /dev/[u]random isn't there.
This surprises me a bit because the location of prngd's random-data socket
is evidently variable.  I've not dug into exactly how openssl figures that
out, but I'm sure a little quality time with the openssl sources would
explain it.

			regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 21+ messages in thread

* Re: Re: [COMMITTERS] pgsql: Replace PostmasterRandom() with a stronger way of generating ran
@ 2016-10-18 12:53  Michael Paquier <michael.paquier@gmail.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 21+ messages in thread

From: Michael Paquier @ 2016-10-18 12:53 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Robert Haas <robertmhaas@gmail.com>; Heikki Linnakangas <hlinnaka@iki.fi>; pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>

On Tue, Oct 18, 2016 at 12:34 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Michael Paquier <michael.paquier@gmail.com> writes:
>> And actually, enabling prngd would need to be controlled by a
>> configure switch as well disabled by default, no?
>
> AFAICT, openssl has no configuration options related to prngd; they
> seem to be able to use it automatically when /dev/[u]random isn't there.
> This surprises me a bit because the location of prngd's random-data socket
> is evidently variable.  I've not dug into exactly how openssl figures that
> out, but I'm sure a little quality time with the openssl sources would
> explain it.

I dug a bit into the code around RAND_egd and how it gets into
fetching a method to get random bytes but got tired of the game for
now. The man page means visibly that OpenSSL connects directly to the
daemon:
https://www.openssl.org/docs/manmaster/crypto/RAND_egd.html

By the way, after a short chat with Heikki, we can up with an extra
idea: resurrect unix_std from pgcrypto in pg_strong_random as the last
fallback method and instead of using sha1, use sha2 as SCRAM is going
to need those functions in src/common/ as well. Having a configure
switch to enable it may be a good idea.
-- 
Michael


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 21+ messages in thread

* pgsql: Replace PostmasterRandom() with a stronger source, second attemp
@ 2016-12-05 11:44  Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 2 replies; 21+ messages in thread

From: Heikki Linnakangas @ 2016-12-05 11:44 UTC (permalink / raw)
  To: pgsql-committers

Replace PostmasterRandom() with a stronger source, second attempt.

This adds a new routine, pg_strong_random() for generating random bytes,
for use in both frontend and backend. At the moment, it's only used in
the backend, but the upcoming SCRAM authentication patches need strong
random numbers in libpq as well.

pg_strong_random() is based on, and replaces, the existing implementation
in pgcrypto. It can acquire strong random numbers from a number of sources,
depending on what's available:

- OpenSSL RAND_bytes(), if built with OpenSSL
- On Windows, the native cryptographic functions are used
- /dev/urandom

Unlike the current pgcrypto function, the source is chosen by configure.
That makes it easier to test different implementations, and ensures that
we don't accidentally fall back to a less secure implementation, if the
primary source fails. All of those methods are quite reliable, it would be
pretty surprising for them to fail, so we'd rather find out by failing
hard.

If no strong random source is available, we fall back to using erand48(),
seeded from current timestamp, like PostmasterRandom() was. That isn't
cryptographically secure, but allows us to still work on platforms that
don't have any of the above stronger sources. Because it's not very secure,
the built-in implementation is only used if explicitly requested with
--disable-strong-random.

This replaces the more complicated Fortuna algorithm we used to have in
pgcrypto, which is unfortunate, but all modern platforms have /dev/urandom,
so it doesn't seem worth the maintenance effort to keep that. pgcrypto
functions that require strong random numbers will be disabled with
--disable-strong-random.

Original patch by Magnus Hagander, tons of further work by Michael Paquier
and me.

Discussion: https://www.postgresql.org/message-id/CAB7nPqRy3krN8quR9XujMVVHYtXJ0_60nqgVc6oUk8ygyVkZsA@mail.gmail...
Discussion: https://www.postgresql.org/message-id/CAB7nPqRWkNYRRPJA7-cF+LfroYV10pvjdz6GNvxk-Eee9FypKA@mail.gmail...

Branch
------
master

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

Modified Files
--------------
configure                                          | 109 +++++
configure.in                                       |  52 +++
contrib/pgcrypto/Makefile                          |   2 +-
contrib/pgcrypto/expected/pgp-compression_1.out    |  42 ++
contrib/pgcrypto/expected/pgp-decrypt_1.out        | 424 +++++++++++++++++++
contrib/pgcrypto/expected/pgp-encrypt_1.out        | 161 +++++++
contrib/pgcrypto/expected/pgp-pubkey-encrypt_1.out |  62 +++
contrib/pgcrypto/fortuna.c                         | 463 ---------------------
contrib/pgcrypto/fortuna.h                         |  38 --
contrib/pgcrypto/internal.c                        |  63 ---
contrib/pgcrypto/openssl.c                         |  46 --
contrib/pgcrypto/pgcrypto.c                        |  27 +-
contrib/pgcrypto/pgp-encrypt.c                     |  22 +-
contrib/pgcrypto/pgp-mpi-internal.c                |  10 +-
contrib/pgcrypto/pgp-pgsql.c                       |  95 +----
contrib/pgcrypto/pgp-pubenc.c                      |  26 +-
contrib/pgcrypto/pgp-s2k.c                         |  15 +-
contrib/pgcrypto/px-crypt.c                        |   7 +-
contrib/pgcrypto/px.c                              |  34 +-
contrib/pgcrypto/px.h                              |   7 +-
contrib/pgcrypto/random.c                          | 247 -----------
doc/src/sgml/installation.sgml                     |  17 +
src/Makefile.global.in                             |   1 +
src/backend/libpq/auth.c                           |  62 ++-
src/backend/libpq/crypt.c                          |  10 +-
src/backend/postmaster/postmaster.c                | 146 ++++---
src/backend/storage/ipc/ipci.c                     |   3 +
src/backend/storage/lmgr/lwlocknames.txt           |   1 +
src/backend/utils/init/globals.c                   |   2 +-
src/backend/utils/misc/Makefile                    |   5 +-
src/backend/utils/misc/backend_random.c            | 158 +++++++
src/include/libpq/crypt.h                          |   2 +-
src/include/libpq/libpq-be.h                       |   1 -
src/include/miscadmin.h                            |   2 +-
src/include/pg_config.h.in                         |  12 +
src/include/pg_config.h.win32                      |  12 +
src/include/port.h                                 |   6 +
src/include/utils/backend_random.h                 |  19 +
src/port/Makefile                                  |   4 +
src/port/erand48.c                                 |   7 +
src/port/pg_strong_random.c                        | 149 +++++++
src/tools/msvc/Mkvcbuild.pm                        |   5 +-
42 files changed, 1472 insertions(+), 1104 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 21+ messages in thread

* Re: pgsql: Replace PostmasterRandom() with a stronger source, second attemp
@ 2016-12-06 22:46  Andres Freund <andres@anarazel.de>
  parent: Heikki Linnakangas <heikki.linnakangas@iki.fi>
  1 sibling, 1 reply; 21+ messages in thread

From: Andres Freund @ 2016-12-06 22:46 UTC (permalink / raw)
  To: Heikki Linnakangas <heikki.linnakangas@iki.fi>; +Cc: pgsql-committers

On 2016-12-05 11:44:37 +0000, Heikki Linnakangas wrote:
> Replace PostmasterRandom() with a stronger source, second attempt.

Since this went in I've seen
2016-12-06 14:42:17.005 PST [23658][] LOG:  wrong key in cancel request for process 23657
2016-12-06 14:42:19.010 PST [23662][] LOG:  wrong key in cancel request for process 23657
a couple times.

I've not yet started debugging it. But it seems to only happen in the
first (few?) queries in a new connection.


Andres


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers



^ permalink  raw  reply  [nested|flat] 21+ messages in thread

* Re: pgsql: Replace PostmasterRandom() with a stronger source, second attemp
@ 2016-12-06 23:56  Thomas Munro <thomas.munro@enterprisedb.com>
  parent: Heikki Linnakangas <heikki.linnakangas@iki.fi>
  1 sibling, 1 reply; 21+ messages in thread

From: Thomas Munro @ 2016-12-06 23:56 UTC (permalink / raw)
  To: Heikki Linnakangas <heikki.linnakangas@iki.fi>; +Cc: pgsql-committers

On Tue, Dec 6, 2016 at 12:44 AM, Heikki Linnakangas
<heikki.linnakangas@iki.fi> wrote:
> src/backend/storage/lmgr/lwlocknames.txt           |   1 +

Missing one tab?

-- 
Thomas Munro
http://www.enterprisedb.com

-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers

Attachments:

whitespace.patch (application/octet-stream, 401B) download diff --git a/src/backend/storage/lmgr/lwlocknames.txt b/src/backend/storage/lmgr/lwlocknames.txt index 0dcf7ef..dd04182 100644 --- a/src/backend/storage/lmgr/lwlocknames.txt +++ b/src/backend/storage/lmgr/lwlocknames.txt @@ -47,4 +47,4 @@ CommitTsLock 39 ReplicationOriginLock 40 MultiXactTruncationLock 41 OldSnapshotTimeMapLock 42 -BackendRandomLock 43 +BackendRandomLock 43
^ permalink raw reply [nested|flat] 21+ messages in thread

* Re: pgsql: Replace PostmasterRandom() with a stronger source, second attemp
@ 2016-12-07 00:30  Michael Paquier <michael.paquier@gmail.com>
  parent: Andres Freund <andres@anarazel.de>
  0 siblings, 1 reply; 21+ messages in thread

From: Michael Paquier @ 2016-12-07 00:30 UTC (permalink / raw)
  To: Andres Freund <andres@anarazel.de>; +Cc: Heikki Linnakangas <heikki.linnakangas@iki.fi>; pgsql-committers

On Wed, Dec 7, 2016 at 7:46 AM, Andres Freund <andres@anarazel.de> wrote:
> On 2016-12-05 11:44:37 +0000, Heikki Linnakangas wrote:
>> Replace PostmasterRandom() with a stronger source, second attempt.
>
> Since this went in I've seen
> 2016-12-06 14:42:17.005 PST [23658][] LOG:  wrong key in cancel request for process 23657
> 2016-12-06 14:42:19.010 PST [23662][] LOG:  wrong key in cancel request for process 23657
> a couple times.
>
> I've not yet started debugging it. But it seems to only happen in the
> first (few?) queries in a new connection.

Hm. I recall testing this patch if cancel keys are working or not, but
connecting with pgbench -C runnung in parallel I am seeing the
following spurious error:
=# select pg_sleep(10);
^CCancel request sent
Time: 10001.496 ms (00:10.001)

With the logs complaining as well:
[1-1] db=[unknown],user=[unknown],app=[unknown],client=[local] LOG:
wrong key in cancel request for process 57361

As far as I can see processCancelRequest uses a long variable, and it
gets compared with an int32. MyCancelKey has been changed to an int32
in globals.c with the above commit. So on 64b machines the current
code is aimed to fail. Attached is a patch to fix the issue.

It is taking me at most 10 times to reproduce the failure without the
patch, after trying 20~ times with the patch I am still able to cancel
the queries.
-- 
Michael

-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers

Attachments:

fix-cancel-key.patch (application/x-download, 763B) download diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index f0ed523371..59073e0354 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -2216,7 +2216,7 @@ processCancelRequest(Port *port, void *pkt) { CancelRequestPacket *canc = (CancelRequestPacket *) pkt; int backendPID; - long cancelAuthCode; + int32 cancelAuthCode; Backend *bp; #ifndef EXEC_BACKEND @@ -2226,7 +2226,7 @@ processCancelRequest(Port *port, void *pkt) #endif backendPID = (int) ntohl(canc->backendPID); - cancelAuthCode = (long) ntohl(canc->cancelAuthCode); + cancelAuthCode = (int32) ntohl(canc->cancelAuthCode); /* * See if we have a matching backend. In the EXEC_BACKEND case, we can no
^ permalink raw reply [nested|flat] 21+ messages in thread

* Re: pgsql: Replace PostmasterRandom() with a stronger source, second attemp
@ 2016-12-07 06:42  Heikki Linnakangas <hlinnaka@iki.fi>
  parent: Thomas Munro <thomas.munro@enterprisedb.com>
  0 siblings, 0 replies; 21+ messages in thread

From: Heikki Linnakangas @ 2016-12-07 06:42 UTC (permalink / raw)
  To: Thomas Munro <thomas.munro@enterprisedb.com>; Heikki Linnakangas <heikki.linnakangas@iki.fi>; +Cc: pgsql-committers

On 12/07/2016 01:56 AM, Thomas Munro wrote:
> On Tue, Dec 6, 2016 at 12:44 AM, Heikki Linnakangas
> <heikki.linnakangas@iki.fi> wrote:
>> src/backend/storage/lmgr/lwlocknames.txt           |   1 +
>
> Missing one tab?

Fixed, thanks.

I missed this because my editor is set up to use 4-space tabs for .c and 
.h files, but not for .txt files. With 8-space tabs, it seemed to align 
with the previous lines.

- Heikki



-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers



^ permalink  raw  reply  [nested|flat] 21+ messages in thread

* Re: pgsql: Replace PostmasterRandom() with a stronger source, second attemp
@ 2016-12-07 07:49  Heikki Linnakangas <hlinnaka@iki.fi>
  parent: Michael Paquier <michael.paquier@gmail.com>
  0 siblings, 0 replies; 21+ messages in thread

From: Heikki Linnakangas @ 2016-12-07 07:49 UTC (permalink / raw)
  To: Michael Paquier <michael.paquier@gmail.com>; Andres Freund <andres@anarazel.de>; +Cc: pgsql-committers

On 12/07/2016 02:30 AM, Michael Paquier wrote:
> With the logs complaining as well:
> [1-1] db=[unknown],user=[unknown],app=[unknown],client=[local] LOG:
> wrong key in cancel request for process 57361
>
> As far as I can see processCancelRequest uses a long variable, and it
> gets compared with an int32. MyCancelKey has been changed to an int32
> in globals.c with the above commit. So on 64b machines the current
> code is aimed to fail. Attached is a patch to fix the issue.

Pushed, thanks!

- Heikki



-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers



^ permalink  raw  reply  [nested|flat] 21+ messages in thread


end of thread, other threads:[~2016-12-07 07:49 UTC | newest]

Thread overview: 21+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-10-17 08:53 pgsql: Replace PostmasterRandom() with a stronger way of generating ran Heikki Linnakangas <heikki.linnakangas@iki.fi>
2016-10-17 14:50 ` Tom Lane <tgl@sss.pgh.pa.us>
2016-10-17 15:02   ` Robert Haas <robertmhaas@gmail.com>
2016-10-17 15:09   ` Heikki Linnakangas <hlinnaka@iki.fi>
2016-10-17 15:18     ` Stephen Frost <sfrost@snowman.net>
2016-10-17 15:21     ` Tom Lane <tgl@sss.pgh.pa.us>
2016-10-17 15:33       ` Magnus Hagander <magnus@hagander.net>
2016-10-17 17:48       ` Heikki Linnakangas <hlinnaka@iki.fi>
2016-10-17 18:14         ` Tom Lane <tgl@sss.pgh.pa.us>
2016-10-17 20:03           ` Robert Haas <robertmhaas@gmail.com>
2016-10-17 20:09         ` Robert Haas <robertmhaas@gmail.com>
2016-10-17 20:35           ` Tom Lane <tgl@sss.pgh.pa.us>
2016-10-18 01:50             ` Michael Paquier <michael.paquier@gmail.com>
2016-10-18 03:34               ` Tom Lane <tgl@sss.pgh.pa.us>
2016-10-18 12:53                 ` Michael Paquier <michael.paquier@gmail.com>
2016-12-05 11:44 pgsql: Replace PostmasterRandom() with a stronger source, second attemp Heikki Linnakangas <heikki.linnakangas@iki.fi>
2016-12-06 22:46 ` Re: pgsql: Replace PostmasterRandom() with a stronger source, second attemp Andres Freund <andres@anarazel.de>
2016-12-07 00:30   ` Re: pgsql: Replace PostmasterRandom() with a stronger source, second attemp Michael Paquier <michael.paquier@gmail.com>
2016-12-07 07:49     ` Re: pgsql: Replace PostmasterRandom() with a stronger source, second attemp Heikki Linnakangas <hlinnaka@iki.fi>
2016-12-06 23:56 ` Re: pgsql: Replace PostmasterRandom() with a stronger source, second attemp Thomas Munro <thomas.munro@enterprisedb.com>
2016-12-07 06:42   ` Re: pgsql: Replace PostmasterRandom() with a stronger source, second attemp Heikki Linnakangas <hlinnaka@iki.fi>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox