From owner-freebsd-fs@freebsd.org Wed Aug 22 19:41:57 2018 Return-Path: Delivered-To: freebsd-fs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BE89F10937EE; Wed, 22 Aug 2018 19:41:57 +0000 (UTC) (envelope-from asomers@gmail.com) Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2D4FA87177; Wed, 22 Aug 2018 19:41:56 +0000 (UTC) (envelope-from asomers@gmail.com) Received: by mail-lf1-f53.google.com with SMTP id l26-v6so2262886lfc.8; Wed, 22 Aug 2018 12:41:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RD5GRRHc6X1znKWsJ+9utq8OFRZ9jwTiwJ24c16bRXE=; b=lCP/UYHHscX5PD+JfiP4J8DSqMnWki/u0CoG1Z99PWf7kTKYp87H5UCMUhHxxaUnO9 7ysc/0MpyQnOP/h04JPAEpGiq6ZywoUxUJkwIS8nMhV+F2y1lmG4Yyu/Jv1v2Xv4vTWm TaSQDlqxJsBTdDr7aJa8ZzPfX4II42OViNnsSS8jrRA4SmQeWIyPomgKPf4tQilOPnn2 KEBIontL/1rR+1tx72jXO2ozFLPIa37ipdOKf7zg+Vad1/9qxwjU1JvjSZ8KaaGjmkA7 C0t01CIQYbEa1tW7yQPoNRtW+tZzwrWiMb6yFYC9eOOsJpPFufPfj1oFQM21z1FCx4En H4AQ== X-Gm-Message-State: APzg51Bs1lvCmYnH+eZpEhGqVUgAxwEOq0hQUtwigY90EiSytmhH/hxN fPbsf0DnGRD/8yp+ERNYUvTsIdCKhvCPwX9ck5U= X-Google-Smtp-Source: ANB0VdazmXcqfQa30ukVrSF12oG5LmKPKkbyoSfSsZh7OXe46SQTW47gB6ZwLwFLTzhGMoaavcB2fyLJzZD2zPad8xA= X-Received: by 2002:a19:6619:: with SMTP id a25-v6mr3156876lfc.62.1534966561322; Wed, 22 Aug 2018 12:36:01 -0700 (PDT) MIME-Version: 1.0 References: <9FDF249A-E320-4652-834E-7EEC5C4FB7CA@ixsystems.com> In-Reply-To: From: Alan Somers Date: Wed, 22 Aug 2018 13:35:48 -0600 Message-ID: Subject: Re: Native Encryption for ZFS on FreeBSD CFT To: Sean Fagan Cc: Matthew Macy , FreeBSD CURRENT , freebsd-fs Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.27 X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Aug 2018 19:41:58 -0000 Only encrypting L0 blocks also leaks a lot of information. That means that, if encryption is set to anything but "off", watermarking attacks will still be possible based on the size and sparsity of a file. Because I believe that with any encryption mode, ZFS turns continuous runs of zeros into holes. And I don't see anything in zio_crypt.c that addresses that. -Alan On Wed, Aug 22, 2018 at 1:23 PM Sean Fagan wrote: > On Aug 22, 2018, at 12:20 PM, Alan Somers wrote: > > ]That doesn't answer the question about what happens when dedup is > turned off. In that case, is the HMAC still used as the IV? If so, then > watermarking attacks are still possible. If ZFS switches to a random IV > when dedup is off, then it would probably be ok. > > From the same file: > > * Initialization Vector (IV): > > * An initialization vector for the encryption algorithms. This is used > to > * "tweak" the encryption algorithms so that two blocks of the same data > are > * encrypted into different ciphertext outputs, thus obfuscating block > patterns. > * The supported encryption modes (AES-GCM and AES-CCM) require that an IV > is > * never reused with the same encryption key. This value is stored > unencrypted > * and must simply be provided to the decryption function. We use a 96 bit > IV > * (as recommended by NIST) for all block encryption. For non-dedup blocks > we > * derive the IV randomly. The first 64 bits of the IV are stored in the > second > * word of DVA[2] and the remaining 32 bits are stored in the upper 32 > bits of > * blk_fill. This is safe because encrypted blocks can't use the upper 32 > bits > * of blk_fill. We only encrypt level 0 blocks, which normally have a fill > count > * of 1. The only exception is for DMU_OT_DNODE objects, where the fill > count of > * level 0 blocks is the number of allocated dnodes in that block. The > on-disk > * format supports at most 2^15 slots per L0 dnode block, because the > maximum > * block size is 16MB (2^24). In either case, for level 0 blocks this > number > * will still be smaller than UINT32_MAX so it is safe to store the IV in > the > * top 32 bits of blk_fill, while leaving the bottom 32 bits of the fill > count > * for the dnode code. > > > Sean > > >