Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cTG6W-0004OG-8p for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Jan 2017 22:50:20 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cTG6V-0002rO-QM for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Jan 2017 22:50:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cTG56-0001Fb-OC for pgsql-hackers@postgreSQL.org; Mon, 16 Jan 2017 22:48:52 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cTG4z-00017u-PR for pgsql-hackers@postgreSQL.org; Mon, 16 Jan 2017 22:48:52 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v0GMmg5E021408; Mon, 16 Jan 2017 17:48:43 -0500 From: Tom Lane To: Alvaro Herrera cc: pgsql-hackers@postgreSQL.org Subject: Re: [COMMITTERS] pgsql: Permit dump/reload of not-too-large >1GB tuples In-reply-to: References: Comments: In-reply-to Alvaro Herrera message dated "Fri, 02 Dec 2016 04:05:29 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <21406.1484606922.1@sss.pgh.pa.us> Date: Mon, 16 Jan 2017 17:48:42 -0500 Message-ID: <21407.1484606922@sss.pgh.pa.us> X-Pg-Spam-Score: -5.1 (-----) 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 Alvaro Herrera writes: > Permit dump/reload of not-too-large >1GB tuples I noticed that this commit has created an overflow hazard on 64-bit hardware: it's not difficult to attempt to make a tuple exceeding 4GB. You just need a few GB-sized input values. But that's uncool for a couple of reasons: * HeapTupleData.t_len can't represent it (it's only uint32) * heap_form_tuple sets up the tuple to possibly become a composite datum, meaning it applies SET_VARSIZE. That's going to silently overflow for any size above 1GB. In short, as this stands it's a security problem. I'm not sure whether it's appropriate to try to change t_len to type Size to address the first problem. We could try, but I don't know what the fallout would be. Might be better to just add a check disallowing tuple size >= 4GB. As for the second problem, we clearly don't have any prospect of allowing composite datums that exceed 1GB, since they have to have varlena length words. We can allow plain HeapTuples to exceed that, but it'd be necessary to distinguish whether the value being built is going to become a composite datum or not. That requires an API break for heap_form_tuple, or else a separate function to convert a HeapTuple to Datum (and apply a suitable length check). Either way it's a bit of a mess. In any case, a great deal more work is needed before this can possibly be safe. I recommend reverting it pending that. 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