Received: by 10.223.148.5 with SMTP id 5csp6606983wrq; Wed, 17 Jan 2018 16:20:50 -0800 (PST) X-Google-Smtp-Source: ACJfBovRel6u9IkISSqk+9oAeIBZ+AP4aKdH65MQ7W7AK7KDqOaQ/4osE5tG8UAGa+l8WbYU1RjX X-Received: by 10.98.62.69 with SMTP id l66mr16402170pfa.20.1516234850181; Wed, 17 Jan 2018 16:20:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516234850; cv=none; d=google.com; s=arc-20160816; b=pvURgY9XJzw8iJnttGl3TxyvvG7HTit3vmbR69g2dpbu0KJgR5GjDctEbMN2o+/bSa vyF2ZEnrrvz95Fyvt1AEOfnSlahy2n23n6Aol9m5w1HD+Q2bOzt5DKMOBQukgohVYfSL NoupB7T9ehnm+V8hKjBiwkNbOFdvbF9MNvMVHIKlYztxyn2SozucYbD/SOw8k1udF6+n RaXiVsxm8shUibsEhZ4bHgSSrEVKwJQSAqlU9loBnMwUpFBS/RaYakeka0k9Q4KsIIqr KEY9vurVFpEZPKd3ii0WXoPCOj4X2Wb2Sml/YOlh6GIjrb9WODQC1nEnhwmqx/v8HRsn sfnA== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=lCWk1BJXAc2gJ3bn8sM0t4Er5PE4mAsv9i+BJQCMfw0=; b=k7jwz2LjPrbvyzf0B5ypcdEsyxa/tovAMDBvWRY+33ntMX5cbNK13sLRJvef/d9YCf 8Jm5V4YYzZeXoSphX0xVVJn7ipe6y5D+dHs5K9ncllyp8yrhuCRxTQtPbDCeToUyq0wQ VIkMJ4JHBn5vUo88qyGYsZ8Y0SRyDt4jAnigFRuClZ61ax50otmgNtaePay224Iq+b7H 2QORpyhhv6V8XoZvPqIVb4i7G3OoHEbp/HOvu46t33M9yJcplcqxxCEHpjJueKI/Wdq1 E48K8KJEgDy6xQb4+e+cLfHumMJ34aSnkmJc4wzPoIPw9yonYywfFhUBStV/DENwcGqg eD1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=V7wr7Xqb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w9si4691791pgt.716.2018.01.17.16.20.35; Wed, 17 Jan 2018 16:20:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=V7wr7Xqb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754622AbeARASs (ORCPT + 99 others); Wed, 17 Jan 2018 19:18:48 -0500 Received: from mail-it0-f43.google.com ([209.85.214.43]:42499 "EHLO mail-it0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753126AbeARASp (ORCPT ); Wed, 17 Jan 2018 19:18:45 -0500 Received: by mail-it0-f43.google.com with SMTP id p139so11414295itb.1; Wed, 17 Jan 2018 16:18:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=lCWk1BJXAc2gJ3bn8sM0t4Er5PE4mAsv9i+BJQCMfw0=; b=V7wr7XqbPgeV75r28t6j65VN3DE2QqZ142jSdwfYL7RPtr42yDW+8HTzNzAI9eODBK WYrAp7JLL60skoOz+lXLt0eIiZ3LDsjOtY5bBJxr4kV8bGGFKbWzM/NSOoBWG6T577E3 fyxGJyufCfpIBNovikmmPFauZd7emjMjqiE2/Cg9LU9/3dE8icl1iVg5O7yrTFsjfkLQ QFSCSju/Wctwz9UqmeDfQz1cE1htY//9X7OwFoUuPbjhkHeW7Dcj2GH4W+I6x9e88WEA fHFs+nTuSAXIuTOqCjpGwcAknhiuffRYzpBqqtclGVhdOmat+JGbbOdFjjduWbGVsoOa taJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=lCWk1BJXAc2gJ3bn8sM0t4Er5PE4mAsv9i+BJQCMfw0=; b=IYJFB19FngIORvylt4FI3u/BquW0RG9piLmaAJTVZ1SD1gRG4Y+neMG8ktp0wkBTXK tMKTV9qyAuRNBa8J1wlB+cLo4H7TkSAPp5DZ5GHowvplqkUJfZjViR5W40SHNK7ttd3T 5vOjq/k5VAjn7K4hGpT09R3HcHtEJIZmDpkstIsNSdZj6r/rDKR2ip2kUa1b0ey2c31I NrXytG8nybYVpgqgJvh6FFEmsoqJj7tQfUVw6oIecN4PCCb3fvKZhdYlH08++coIgFzF nkeLReeBSg+HFC+ynfF4thUshAyZ5p3ej7CXLZsthgOdED4lFVjoks0f4R5vi9ciWoNq 4bog== X-Gm-Message-State: AKwxytdYLu89cXsmO1PNbZ+RMPUXFGKWc/NNY6csbjhegO6M4sxn0qQu k6c3op7XMUt9SB/nhnytdFQ= X-Received: by 10.36.73.204 with SMTP id e73mr25708134itd.85.1516234724801; Wed, 17 Jan 2018 16:18:44 -0800 (PST) Received: from gmail.com ([2620:15c:17:3:dc28:5c82:b905:e8a8]) by smtp.gmail.com with ESMTPSA id h21sm671034iod.41.2018.01.17.16.18.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 17 Jan 2018 16:18:44 -0800 (PST) Date: Wed, 17 Jan 2018 16:18:41 -0800 From: Eric Biggers To: =?iso-8859-1?Q?Andr=E9?= Draszik Cc: linux-kernel@vger.kernel.org, Mimi Zohar , David Howells , James Morris , "Serge E. Hallyn" , "Theodore Y. Ts'o" , Jaegeuk Kim , Kees Cook , linux-integrity@vger.kernel.org, keyrings@vger.kernel.org, linux-security-module@vger.kernel.org, linux-fscrypt@vger.kernel.org Subject: Re: [PATCH 1/3] encrypted-keys: add fscrypt format support Message-ID: <20180118001841.ntui5j2nsszgy3aj@gmail.com> References: <20180110124418.24385-1-git@andred.net> <20180111040022.GA943@zzz.localdomain> <1516199369.28972.93.camel@andred.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1516199369.28972.93.camel@andred.net> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andr?, On Wed, Jan 17, 2018 at 02:29:29PM +0000, Andr? Draszik wrote: > Thanks Eric for the review! > > On Wed, 2018-01-10 at 20:00 -0800, Eric Biggers wrote: > > Hi Andr?, > > > > On Wed, Jan 10, 2018 at 12:44:16PM +0000, Andr? Draszik wrote: > > > This is heavily based on commit 79a73d188726 > > > ("encrypted-keys: add ecryptfs format support"). > > > > > > The 'encrypted' key type defines its own payload format which contains a > > > symmetric key randomly generated that cannot be used directly by the > > > fscrypt subsystem, because it instead expects an fscrypt_key structure. > > > > > > This patch introduces the new format 'fscrypt' that allows to store an > > > fscrypt_key structure inside the encrypted key payload containing > > > a randomly generated symmetric key, as the same for the format 'default' > > > and 'ecryptfs'. > > > > > > More details about the usage of encrypted keys with the fscrypt > > > subsystem can be found in the file > > > 'Documentation/security/keys/fscrypt.rst'. > > > > > > > I don't think a new encrypted-key format is needed. fscrypt really only > > needs > > the raw key. > > This was actually my original approach, but I thought it might potentially > be useful to have a new encrypted-key type to be able to do verification of > parameters (e.g. key size) early. > Additionally, because the type is then encoded in the blob stored in the > file system (keyctl pipe), it'd be easy to spot incompatibilities in case > fscrypt internal data structures change, whereas without one can only rely > on the name of the key (key description), should such a change ever happen. 'struct fscrypt_key' isn't really useful because it doesn't have any reserved fields. So if we wanted to change the format we'd have to change the key description anyway, by setting some flag in the fscrypt_policy and the fscrypt_context that indicates a different key description should be used. And fscrypt does verify the key's size before it uses it already. Sure, it might to nice to verify it at add_key() time, but I don't think it's necessary. > > > Also I have proposed an fscrypt ioctl to add keys to a filesystem-level > > keyring, > > and it doesn't use 'struct fscrypt_key' at all: > > https://marc.info/?l=linux-fsdevel&m=150879505206393 > > > > So I think you should just use the "default" encrypted-key format, where > > the > > payload is just the raw key. fscrypt can very easily be updated to work > > with > > such keys. > > I've done that in v2 - I am generating the fscrypt_key temporarily on the > fly but haven't gotten rid of fscrypt_key altogether... Is that what you had > in mind? That would work, but we don't actually need the fscrypt_key structure at all. Just declare 'const u8 *raw' and 'u32 size' local variables and set them appropriately, then pass those into derive_key_aes() (changing its prototype) rather than the fscrypt_key. > > I also haven't based it on your work mentioned above, would that be > preferred? Not really, that patch series ("fscrypt: filesystem-level keyring and v2 policy support") is still in RFC status, so we don't know which would be merged first. I'm still looking for people with the interest and expertise to review it :-) That being said, we could choose to support the "encrypted" key type using only FS_IOC_ADD_ENCRYPTION_KEY, rather than the current mechanism of process-subscribed keyrings. (With FS_IOC_ADD_ENCRYPTION_KEY, we'd need to use a flag in 'struct fscrypt_add_key_args' to indicate that the key should be found by searching the current process's keyrings for an "encrypted" key with the given description, rather than taking the key directly from the ioctl argument.) But it wouldn't be a huge deal to support it both ways. Eric