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 1h4u6M-0000UU-Uy for pgsql-hackers@arkaria.postgresql.org; Fri, 15 Mar 2019 21:10:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h4u6L-0007Tm-EY for pgsql-hackers@arkaria.postgresql.org; Fri, 15 Mar 2019 21:10:49 +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 1h4u6L-0007TT-2z for pgsql-hackers@lists.postgresql.org; Fri, 15 Mar 2019 21:10:49 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h4u6I-0000eh-D0 for pgsql-hackers@postgresql.org; Fri, 15 Mar 2019 21:10:47 +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 x2FLANo0013457; Fri, 15 Mar 2019 17:10:23 -0400 From: Tom Lane To: Robert Haas cc: Antonin Houska , Toshi Harada , "pgsql-hackers@postgresql.org" Subject: Re: "WIP: Data at rest encryption" patch and, PostgreSQL 11-beta3 In-reply-to: References: <5907.1534140361@localhost> <201808150211.w7F2ApMj023097@ccmail04.silk.ntt-tx.co.jp> <19039.1536933944@localhost> <14646.1552570130@localhost> Comments: In-reply-to Robert Haas message dated "Fri, 15 Mar 2019 11:34:17 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <13455.1552684223.1@sss.pgh.pa.us> Date: Fri, 15 Mar 2019 17:10:23 -0400 Message-ID: <13456.1552684223@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Robert Haas writes: > If the WAL *is* encrypted, the state at this point is that the block > is unreadable, because the first 4kB of the block is the first half of > the bits that resulted from encrypting 8kB of data that includes the > new record, and the second 4kB of the block is the second half of the > bits that resulted from encrypting 8kB of data that did not include > the new record, and since the new record perturbed every bit on the > page with probability ~50%, what that means is you now have garbage. > That means that not only did we lose the new record, but we also lost > the 3.5kB of good data which the page previously contained. That's > NOT ok. Some of the changes associated with those WAL records may > have been flushed to disk already, or there may be commits in there > that were acknowledged to the client, and we can't just lose them. ISTM that this is only a problem if you choose the wrong encryption method. One not-wrong encryption method is to use a stream cipher --- maybe that's not the exact right technical term, but anyway I'm talking about a method which notionally XOR's the cleartext data with a random bit stream generated from the encryption key (probably along with other knowable inputs such as the block number). In such a method, corruption of individual on-disk bytes doesn't prevent you from getting the correct decryption of on-disk bytes that aren't corrupted. regards, tom lane