Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dC3T6-0005Qr-G2 for pgsql-hackers@arkaria.postgresql.org; Sat, 20 May 2017 12:26:48 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dC3T5-0003GN-On for pgsql-hackers@arkaria.postgresql.org; Sat, 20 May 2017 12:26:47 +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 1dC3T4-0003GC-Qz for pgsql-hackers@postgresql.org; Sat, 20 May 2017 12:26:47 +0000 Received: from mail-pg0-x22c.google.com ([2607:f8b0:400e:c05::22c]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1dC3Sw-0007qR-MV for pgsql-hackers@postgresql.org; Sat, 20 May 2017 12:26:45 +0000 Received: by mail-pg0-x22c.google.com with SMTP id u187so49323271pgb.0 for ; Sat, 20 May 2017 05:26:37 -0700 (PDT) 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=7e/js/X1dt8JJn6IFMHY9Z9dpIZcTXHjXE2hmwoA0t4=; b=MGcQbMuKfsxVfAXrp3rQKpRNGQWZpwftm7++RPLSUXPmrJPMem85DhDEgUVdFNOir+ DoD+qmZGNHM92tSyAzvzY8qIp/6dMXMTXdEilP7iJL8QmDnnA0qp6l0gfteZTq32+ICQ wCN8yoUYNAbWHmAWmt49v2b6mP4hf5uxXIv9Q= 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=7e/js/X1dt8JJn6IFMHY9Z9dpIZcTXHjXE2hmwoA0t4=; b=gDRjy8P3GMmSYTGtSFoN4ILSg+hxmtpEpzcdOpH7eSL6eMerzy+bVRECJauMA9B5UQ m/tzdi41jkzHyqgtUaoybG9gEQFctAZde+AQ59lTJOj+FK5osV/nZG/hYhDY6a068Auc AeCf/OuM5WqqX6DlKBSAwUbWqtZbh3JF8dj27I6rOCuwARsedJFlr+CNomjZv1i9O1yx nb8wu22ZgIfPcFaMCEVDDqixb0WZDetEufNRx9mQLLddYCLiv0ZbSjo4F3KfAPhdSATF 2OAY4dIP8FlW2SwftiES5DZ5U/vmen5YK9SYMVAe+6x39zs5S0o+19cMuaU4wwhin2SU Hc+w== X-Gm-Message-State: AODbwcDohQTTfY5vGDtwwdHqaJSMuvT8eNCXrS5sGNhPi8VvAaBEQTd2 Lr97fa9M7XtouzFz X-Received: by 10.101.69.194 with SMTP id m2mr7926133pgr.232.1495283196532; Sat, 20 May 2017 05:26:36 -0700 (PDT) Received: from rfd.leadboat.com (c-98-248-47-228.hsd1.ca.comcast.net. [98.248.47.228]) by smtp.gmail.com with ESMTPSA id s18sm20147462pfi.16.2017.05.20.05.26.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 20 May 2017 05:26:35 -0700 (PDT) Date: Sat, 20 May 2017 12:26:33 +0000 From: Noah Misch To: Andres Freund , Tom Lane Cc: pgsql-hackers@postgresql.org Subject: Re: OK, so culicidae is *still* broken Message-ID: <20170520122633.GB828137@rfd.leadboat.com> References: <7036.1492231361@sss.pgh.pa.us> <18D5D7AF-C587-4B63-B2CF-13590849A624@anarazel.de> <32559.1492278226@sss.pgh.pa.us> <1842.1492289285@sss.pgh.pa.us> <20170415210643.cdapwhwmbiwaqd6e@alap3.anarazel.de> <2829.1492290578@sss.pgh.pa.us> <20170415211810.vsing3muvqfcswqx@alap3.anarazel.de> <3667.1492291494@sss.pgh.pa.us> <20170415213017.co7gkjlbcy44zlmw@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170415213017.co7gkjlbcy44zlmw@alap3.anarazel.de> User-Agent: Mutt/1.5.24 (2015-08-30) X-Pg-Spam-Score: -2.0 (--) 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 Sat, Apr 15, 2017 at 02:30:18PM -0700, Andres Freund wrote: > On 2017-04-15 17:24:54 -0400, Tom Lane wrote: > > Andres Freund writes: > > > On 2017-04-15 17:09:38 -0400, Tom Lane wrote: > > >> Why doesn't Windows' ability to map the segment into the new process > > >> before it executes take care of that? > > > > > Because of ASLR of the main executable (i.e. something like PIE). > > > > Not following. Are you saying that the main executable gets mapped into > > the process address space immediately, but shared libraries are not? At the time of the pgwin32_ReserveSharedMemoryRegion() call, the child process contains only ntdll.dll and the executable. > Without PIE/ASLR we can somewhat rely on pgwin32_ReserveSharedMemoryRegion > to find the space that PGSharedMemoryCreate allocated still unoccupied. I've never had access to a Windows system that can reproduce the fork failures. My best theory is that antivirus or similar software injects an additional DLL at that early stage. > > I wonder whether we could work around that by just destroying the created > > process and trying again if we get a collision. It'd be a tad > > inefficient, but hopefully collisions wouldn't happen often enough to be a > > big problem. > > That might work, although it's obviously not pretty. I didn't like that idea when Michael proposed it in 2015. Since disabling ASLR on the exe proved insufficient, I do like it now. It degrades nicely; if something raises the collision rate from 1% to 10%, that just looks like fork latency degrading. > We could also just > default to some out-of-the-way address for MapViewOfFileEx, that might > also work. Dave Vitek proposed that: https://www.postgresql.org/message-id/flat/5046CAEB.4010600%40grammatech.com I estimate more risk than retrying forks. There's no guarantee that a fixed address helpful today won't make the collisions worse after the next Windows security patch. -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers