Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gMnql-00084h-Sq for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Nov 2018 05:36:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gMnqg-0003HY-Pr for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Nov 2018 05:36:22 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gMnqg-0003HR-7V for pgsql-hackers@lists.postgresql.org; Wed, 14 Nov 2018 05:36:22 +0000 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gMnqc-0001SO-VR for pgsql-hackers@postgresql.org; Wed, 14 Nov 2018 05:36:20 +0000 Received: by mail-pf1-x42b.google.com with SMTP id u3-v6so4627610pfm.4 for ; Tue, 13 Nov 2018 21:36:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=aHs+QplMOehl7kDG354O8iABQBDQYLprppPj0aWbiAE=; b=dSjUr6IXxrPa5tXUPd9HGTFvgWEdGjuAyk+b2m2/GGD6Iz5R4VD6o5I94rPURh5Tbv dnLIMpiI2lINN6AQ4625nAUW2YkwdECNzjPE/k4NG2NuvpFfiHXoR3lgKPPiNlD+mOdY /n/b0PC9Vcrxox0a3F3af4GVXHNama7IVJ+b4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=aHs+QplMOehl7kDG354O8iABQBDQYLprppPj0aWbiAE=; b=gkIij+kdD4qWmc8LS59JdYbHDLnKAFpBQTAUfp2Lg7/5bFgva1cMkg/3mMB9cKpf/k 6xSQN5aPSzXGL3qU1KVKfdkmbmdxjPQQPW0lNRjqrjcMPbCOjfMs9eIgaquZQOXli8hq uAjf4Knvg3pYqwcJlnU92lJWHBDlOet1JL6BHmiAn+/kLdgv8PsWqNg8agF+jTcnBwiI N0oEaa4BMwKeFXLUMjkmwQEbEHoC2HOzdwo8hMlSI0VCsTPEJxeiFjVAEVB5MLtOS9r2 O4/3W0m7nt+cdCIKtz/0JIpHUQSkRjn6Ioo+T0AqcCa/jJCUUJ1GVRvM8Av7yPY0zNg7 yqpQ== X-Gm-Message-State: AGRZ1gLkx9olr5gLYM2X/RY/EQEGawEFl40BTUm5QrNtd41xIWIF3WyF 0dFUvEIJsVRlKDVgTtpBMF82CQ== X-Google-Smtp-Source: AJdET5c4wbq0yL0F51A3drsgIiOBipfccoxiyJR1QjT1WjgQCsmVGvTWcwKK5AXz73ZkLYL87fneag== X-Received: by 2002:a63:e055:: with SMTP id n21mr462189pgj.397.1542173656736; Tue, 13 Nov 2018 21:34:16 -0800 (PST) Received: from rfd.leadboat.com (c-73-158-248-138.hsd1.ca.comcast.net. [73.158.248.138]) by smtp.gmail.com with ESMTPSA id r83sm15523601pfc.115.2018.11.13.21.34.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Nov 2018 21:34:15 -0800 (PST) Date: Tue, 13 Nov 2018 21:34:12 -0800 From: Noah Misch To: Thomas Munro Cc: Tom Lane , Pg Hackers Subject: Re: DSM segment handle generation in background workers Message-ID: <20181114053412.GD1096408@rfd.leadboat.com> References: <17043.1539046409@sss.pgh.pa.us> <9879.1539233472@sss.pgh.pa.us> <20181112083358.GA1073796@rfd.leadboat.com> <32455.1542033541@sss.pgh.pa.us> <20181114022435.GC1096408@rfd.leadboat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Wed, Nov 14, 2018 at 05:50:26PM +1300, Thomas Munro wrote: > On Wed, Nov 14, 2018 at 3:24 PM Noah Misch wrote: > > On Mon, Nov 12, 2018 at 09:39:01AM -0500, Tom Lane wrote: > > > I doubt that's a good idea; to a first approximation, it would mean that > > > half the seed depends only on the PID and the other half only on the > > > timestamp. Maybe we could improve matters a little by left-shifting the > > > PID four bits or so, but I think we still want it to mix with some > > > rapidly-changing time bits. > > > > > > I'm not really sure that we need to do anything though. Basically, > > > what we've got here is a tradeoff between how many bits change over > > > a given timespan and how unpredictable those bits are. I don't see > > > that one of those is necessarily more important than the other. > > > > What counts is the ease of predicting a complete seed. HEAD's algorithm has > > ~13 trivially-predictable bits, and the algorithm that stood in BackendRun() > > from 98c5065 until 197e4af had no such bits. You're right that the other 19 > > bits are harder to predict than any given 19 bits under the old algorithm, but > > the complete seed remains more predictable than it was before 197e4af. > > However we mix them, given that the source code is well known, isn't > an attacker's job really to predict the time and pid, two not > especially well guarded secrets? True. Better to frame the issue as uniform distribution of seed, not unpredictability of seed selection. Incidentally, possible future work may be to use pg_strong_random() when available, like pgbench set_random_seed() does. That would achieve both unpredictability and uniform distribution. It would be mere defense in depth; if unpredictability matters, one still needs a CSPRNG (e.g. pgcrypto).