Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Uum8p-0002LQ-Se for pgsql-bugs@arkaria.postgresql.org; Thu, 04 Jul 2013 16:12:20 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Uum8p-0005zT-B9 for pgsql-bugs@arkaria.postgresql.org; Thu, 04 Jul 2013 16:12:19 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Uum8o-0005y3-1a for pgsql-bugs@postgresql.org; Thu, 04 Jul 2013 16:12:18 +0000 Received: from mail-vb0-f53.google.com ([209.85.212.53]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Uum8h-0006vs-MB for pgsql-bugs@postgresql.org; Thu, 04 Jul 2013 16:12:17 +0000 Received: by mail-vb0-f53.google.com with SMTP id p12so1049879vbe.40 for ; Thu, 04 Jul 2013 09:12:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent :x-gm-message-state; bh=fRpBy+UMOtM2wXeusFWszxaBMJJGx7NyvD42GFBzN7c=; b=Ye+I2UcQ7mRPC8DzaeBdn10gSrepV0eXv4fclF/r46bHDJLpe3D5jHSJ/BldmCvFa/ VcaDDZplnjAhJ1JnXc/3Zqa8AFfJaKC5iMU1PJgT9JNn2OZy3WDGy6FN/huGfHA4tatJ ZZX8yQ4qYRhcTzL75zw2fqzOiZ2wassredIgxvKZDmSG05kfqtfIqflfJyUUhLnPP+Mr SLAg5sCWaJdJc0A4MA9I7gpjA1V6cHjwtmtNT33MzxBx7dWWbxvc5rfbgMTy9oWXYdDo q7dAtqAuIIE9UAH7G/2T/8768DkTz+LpIa2vpU8VDbvb7IECFAh2PfqF8AYfTOycN4PN Vbqw== X-Received: by 10.58.97.167 with SMTP id eb7mr3554356veb.45.1372954330945; Thu, 04 Jul 2013 09:12:10 -0700 (PDT) Received: from tornado.leadboat.com (ip68-105-236-221.hr.hr.cox.net. [68.105.236.221]) by mx.google.com with ESMTPSA id lm13sm1887171vec.8.2013.07.04.09.12.09 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 04 Jul 2013 09:12:10 -0700 (PDT) Date: Thu, 4 Jul 2013 12:12:07 -0400 From: Noah Misch To: Dave Vitek Cc: pgsql-bugs@postgresql.org, v-seishi@microsoft.com Subject: Re: windows 8 RTM compatibility issue (could not reserve shared memory region for child) Message-ID: <20130704161207.GA1046835@tornado.leadboat.com> References: <5046CAEB.4010600@grammatech.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5046CAEB.4010600@grammatech.com> User-Agent: Mutt/1.5.18 (2008-05-17) X-Gm-Message-State: ALoCoQk7PUWz53AOCbSly3vHU9jV8BOSXEyd5k2HB1PgMu25bwznBcY8VOkffC8uMfAxpsvGIlR+ X-Pg-Spam-Score: 0.1 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Hi Dave, On Tue, Sep 04, 2012 at 11:45:47PM -0400, Dave Vitek wrote: > LOG: could not reserve shared memory region (addr=0000000001410000) for child > 0000000000000F8C: 487 > LOG: could not fork new process for connection: A blocking operation was > interrupted by a call to WSACancelBlockingCall. > So why hasn't this ever happened before? I'm guessing that ASLR got > better in the latest windows 8 patch, or maybe there's just more stuff > in the virtual address space of a newborn process. > One straightforward "fix" is to specify a hardcoded address to > MapViewOfFileEx instead of NULL. This address should be carefully > selected such that it is in an area disjoint from the portions of the > address space that are potentially reserved in a newborn process, and > also unlikely to be in use inside the postmaster when it first maps the > shared memory. This is pretty trivial to do for a particular > version/configuration of Windows. However, I see no future-proof > solution (besides making the shared segment position independent). If > the hardcoded address is not available, you can always fall back on the > current behavior. Given the strong dedication to backward-compatibility in Windows, I would expect a way to bypass the new ASLR measures. Some web searching suggests linking postgres.exe with "/highentropyva:no" and/or "/dynamicbase:no" might help, but nothing conclusive. Thoughts? That would be preferable to relying on experimentally-derived safe addresses, which could cease to be safe after a mere Windows update or similar. > There is a security problem with the fix I outline above. It bypasses > ASLR to a limited degree, since the shared memory would likely end up > always living at the same address. I am not certain that MapViewOfFile > even tries to be unpredictable, but let's assume it does or will be > someday. I wouldn't worry about it too much. ASLR is a defense-in-depth measure; it comes into play when your software already has a flaw and potentially reduces the impact of that flaw. > I've attached a patch that implements the stuff above. I can share the > code for the program that tests whether an address is reliably available > in a newborn postgres process, if anyone is interested. Great detective work. Seeing that program could be helpful. Thanks, nm -- Noah Misch EnterpriseDB http://www.enterprisedb.com -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs