Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp344817ybl; Mon, 12 Aug 2019 17:40:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqwcMeiIxru94WoZvUvAk3CgGLSWgN6vquAt5tLU0xN27ia4pVylv2SeHG5ILSUXSmVm0Ixr X-Received: by 2002:a17:902:e30d:: with SMTP id cg13mr35488167plb.173.1565656839339; Mon, 12 Aug 2019 17:40:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565656839; cv=none; d=google.com; s=arc-20160816; b=VMR8PdhGfB4mF+GzIjYRDv98hFsuLijVk2zknNK9wRWRYMcl0mi56jJKNowMQzVG6T 5GIGsY8eGd+eZlG+UqV+jBi3waLyws1e4WcQXxa4KetTAPwRb3coHl94adtwzlv0DxaB RPHltJD5sZyG7EITANc3fI4R/OPqZg+y9oWc49h25woLJqWS6Mbc7hxxFuP1lmGBULk9 iBeItgJHL3dxsVGrAzZ1B9j5wLa3m0rYPW2Ii9puDCj95nCIbV9VJWE+2+SKhzWXpr8U H5J4s1x3i0lrXjpqZTHRsp33Mg99bLcVusrDuyggt79V3OEuhSXIU74G6QYmiuip15qt MnuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=8Nj8gcAdAyF2PrqbSBR9mjod/iUGSBR3MkMGJVHtkSU=; b=G+I3rLOlfQPOYB1EhNRP4WZrmGzSV8xPFAA/xZ4SxsIC9mio6yNYXm960VPAdN+3xR tJcGDNxgVcJLaCqtnDdlogEqP12waabqBmaRvHPXk3xFBQLrLvOaVDAY3ym4qg+0sCQp f0kdt+Lzwybr8cFB915UnxXncHveFgSBH+LOii8WSt7SoJa+ZD11IL0f2h38uNXLVDLL kI/5v2ZD/pJ8Kn1ihBzSLpGrylXlhzRWsBTM6MGKvwjPO8EX76XRtgCK4rHlPlq/dxOC cRANDv6FoyMWOhsAXA7nJkBlbKOlDlo8Iq0BCILcfKROq2fhSAaKRnjn6yWyJMo0XKAR mW/A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j191si64989123pgd.88.2019.08.12.17.40.25; Mon, 12 Aug 2019 17:40:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726512AbfHMAj5 (ORCPT + 99 others); Mon, 12 Aug 2019 20:39:57 -0400 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:40163 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726453AbfHMAj4 (ORCPT ); Mon, 12 Aug 2019 20:39:56 -0400 Received: from callcc.thunk.org (guestnat-104-133-9-109.corp.google.com [104.133.9.109] (may be forged)) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id x7D0dcO9023746 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 12 Aug 2019 20:39:39 -0400 Received: by callcc.thunk.org (Postfix, from userid 15806) id B8C504218EF; Mon, 12 Aug 2019 20:39:37 -0400 (EDT) Date: Mon, 12 Aug 2019 20:39:37 -0400 From: "Theodore Y. Ts'o" To: Eric Biggers Cc: linux-fscrypt@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-mtd@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-crypto@vger.kernel.org, keyrings@vger.kernel.org, linux-api@vger.kernel.org, Satya Tangirala , Paul Crowley , Jaegeuk Kim Subject: Re: [PATCH v8 13/20] fscrypt: v2 encryption policy support Message-ID: <20190813003937.GK28705@mit.edu> References: <20190805162521.90882-1-ebiggers@kernel.org> <20190805162521.90882-14-ebiggers@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190805162521.90882-14-ebiggers@kernel.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Mon, Aug 05, 2019 at 09:25:14AM -0700, Eric Biggers wrote: > From: Eric Biggers > > Add a new fscrypt policy version, "v2". It has the following changes > from the original policy version, which we call "v1" (*): > > - Master keys (the user-provided encryption keys) are only ever used as > input to HKDF-SHA512. This is more flexible and less error-prone, and > it avoids the quirks and limitations of the AES-128-ECB based KDF. > Three classes of cryptographically isolated subkeys are defined: > > - Per-file keys, like used in v1 policies except for the new KDF. > > - Per-mode keys. These implement the semantics of the DIRECT_KEY > flag, which for v1 policies made the master key be used directly. > These are also planned to be used for inline encryption when > support for it is added. > > - Key identifiers (see below). > > - Each master key is identified by a 16-byte master_key_identifier, > which is derived from the key itself using HKDF-SHA512. This prevents > users from associating the wrong key with an encrypted file or > directory. This was easily possible with v1 policies, which > identified the key by an arbitrary 8-byte master_key_descriptor. > > - The key must be provided in the filesystem-level keyring, not in a > process-subscribed keyring. > > The following UAPI additions are made: > > - The existing ioctl FS_IOC_SET_ENCRYPTION_POLICY can now be passed a > fscrypt_policy_v2 to set a v2 encryption policy. It's disambiguated > from fscrypt_policy/fscrypt_policy_v1 by the version code prefix. > > - A new ioctl FS_IOC_GET_ENCRYPTION_POLICY_EX is added. It allows > getting the v1 or v2 encryption policy of an encrypted file or > directory. The existing FS_IOC_GET_ENCRYPTION_POLICY ioctl could not > be used because it did not have a way for userspace to indicate which > policy structure is expected. The new ioctl includes a size field, so > it is extensible to future fscrypt policy versions. > > - The ioctls FS_IOC_ADD_ENCRYPTION_KEY, FS_IOC_REMOVE_ENCRYPTION_KEY, > and FS_IOC_GET_ENCRYPTION_KEY_STATUS now support managing keys for v2 > encryption policies. Such keys are kept logically separate from keys > for v1 encryption policies, and are identified by 'identifier' rather > than by 'descriptor'. The 'identifier' need not be provided when > adding a key, since the kernel will calculate it anyway. > > This patch temporarily keeps adding/removing v2 policy keys behind the > same permission check done for adding/removing v1 policy keys: > capable(CAP_SYS_ADMIN). However, the next patch will carefully take > advantage of the cryptographically secure master_key_identifier to allow > non-root users to add/remove v2 policy keys, thus providing a full > replacement for v1 policies. > > (*) Actually, in the API fscrypt_policy::version is 0 while on-disk > fscrypt_context::format is 1. But I believe it makes the most sense > to advance both to '2' to have them be in sync, and to consider the > numbering to start at 1 except for the API quirk. > > Signed-off-by: Eric Biggers Looks good, feel free to add: Reviewed-by: Theodore Ts'o