Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bw9XM-0004fs-Om for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Oct 2016 15:09:12 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bw9XM-0005G1-8W for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Oct 2016 15:09:12 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bw9XL-0005Fu-GM for pgsql-hackers@postgresql.org; Mon, 17 Oct 2016 15:09:11 +0000 Received: from mail-lf0-x242.google.com ([2a00:1450:4010:c07::242]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1bw9XE-0007rx-4S for pgsql-hackers@postgresql.org; Mon, 17 Oct 2016 15:09:10 +0000 Received: by mail-lf0-x242.google.com with SMTP id b75so27003516lfg.3 for ; Mon, 17 Oct 2016 08:09:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=JGwk2di2Pwdp5KzpQBtfXcuJhii0aizXGPIUeW4gef0=; b=i7ZgqLqbWxufulfSc87O/15EKxolJbz4B+uA1oHHSACdDiLd+Bg+Ersyh4xr7lUnGD mt0tTR7YCrnz31tSqXgb6jwGspTrvSIigicV3HUfDP7zZ7JQRsHBn1BI5vFDS2QO2ggI WMyD3AV4aONsurNCbI6ccvefqbfA5b3Ir+lebtI+dVdktAD0+W6XVZKXeWqBtYF3Z1NM wqsCTk/dB177B80kItzJGVnGhW4erP7i1cUDfvbzFbTa9mrFPPFGTN1IaNDzKK9w2Upk q7Qq0jppzQR5BADmnOV2ZcB7ubwQJfZd4jZZAcghjwA1iIuQltrLX/qrXYJUhtUAhK9K zsoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:subject:to:references:cc:from:message-id :date:user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=JGwk2di2Pwdp5KzpQBtfXcuJhii0aizXGPIUeW4gef0=; b=F7gFrIfryVYrtHLO2NlMmByxyU+Jjq3jT8rLXKoR+SgsBHG9Le8IKALWKhTott7L3H SWFLwMDL7TulhJawVMTvVy1ziM8a+Wahy7vmaen1UcvklT1bSskTKiN8pFJpEy4UecNr dlFJ18cWDJ2b3pe6sZAVVq1r7+n+JXj723MPo0poQAymRhGbZCXaRSStQwrXoQuRaqmm vspH2gjrr8N8RGLVmXQNSzm+EITWSFL9WhZmeWpNhE1MeUBUJTdln5bplovRB79RVv0m 6N2vexOWWxpQTPktDSnGWKPqxq3MVnH/alXYQHkNn10p3vyJXiHmN/U43Dz2UEr+t4Jx 0vWw== X-Gm-Message-State: AA6/9RnYHvkhB3zUS2NLf7GDU5Vjmey1dkWNQ16IsZT3jM3PFfahCDo6Uj70VT2mkJz/AQ== X-Received: by 10.25.23.218 with SMTP id 87mr3658584lfx.86.1476716942069; Mon, 17 Oct 2016 08:09:02 -0700 (PDT) Received: from [192.168.1.111] (dsl-hkibrasgw1-58c38f-82.dhcp.inet.fi. [88.195.143.82]) by smtp.gmail.com with ESMTPSA id l65sm8048579lfl.30.2016.10.17.08.09.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Oct 2016 08:09:01 -0700 (PDT) Subject: Re: [COMMITTERS] pgsql: Replace PostmasterRandom() with a stronger way of generating ran To: Tom Lane , Heikki Linnakangas References: <26591.1476715823@sss.pgh.pa.us> Cc: pgsql-hackers@postgresql.org From: Heikki Linnakangas Message-ID: <4f31c7c5-817c-aa3b-ae48-a613008dc558@iki.fi> Date: Mon, 17 Oct 2016 18:09:00 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.4.0 MIME-Version: 1.0 In-Reply-To: <26591.1476715823@sss.pgh.pa.us> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 10/17/2016 05:50 PM, Tom Lane wrote: > Heikki Linnakangas 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