Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp738825imm; Sat, 1 Sep 2018 19:38:14 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda++svcxdg3z+yOcawP/XFyOr9apS9x5VaWvKiQ5QIX2ClDK2KX+YZfWluXKUZVYclalVmc X-Received: by 2002:a62:cc83:: with SMTP id j3-v6mr23078095pfk.255.1535855894620; Sat, 01 Sep 2018 19:38:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535855894; cv=none; d=google.com; s=arc-20160816; b=XG1hBvfmFh0usVd1x5tSqYtlZRALLBijfh5jHpEIgBi3GQdOObZdNjGytNz43DfhjR TYyBDVQ25aleQVWoAM85idM+DPoOHMS1IXeY+xd41KB55U0/KyLdgb7mwWBaFe1Nh+23 xWiVouoHTdxoijcjRjUEnlDd9i5fPsKR7NysPZjuOGU8iFaik5J7uhZo60nj564vGMvj maVZ1nvCvNlK/s/mMF4ooTiFPaz/CSg8JbE0BEaXnVte/mkXNt2rTApIqLsecQy2QDDq Wb2HwNvbykL6dOtwGG5Mj5WvSnFUj8T+wR/deFrkhMX7Z9o7uqXbgmm8kF7LMqpvUqmI 8rCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=p8w4jSbjkZqEagZMMJ/CTLchE9OB8JVUasc6oXa5qrc=; b=Aq6k78ltORQrn5YFULaB6HujQ9CHJVCs2Bq7TzyhveUMBiMKwoHG6k8PqOuHioQgY7 aQnenXf7BAgkTfhp6aeEuUZgTZVkkRCZ1GCxg8fYOb1sttQfTVc5UE7f4SyzJzBXV+sH dsIO3Q1lniseYAuwwBQo9cjOkdEMmXuyMYxENbYRS0foF4jxZQd14VSqP9Lclx8acZrR iO2+uoJcBsb7IIXuFON+gerX0RXj1Zl7xs1mbwOQ+MBkbZywXy2O/mfR3E08nqE2wS3/ mtcUf0bm5TMf3aIon2Ql4OnganfxpDHskysCOY0qPR3nrgFwgCPWtLAsx602xi400dmj 3plQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lixom-net.20150623.gappssmtp.com header.s=20150623 header.b=1srtefVM; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l11-v6si15087530pls.245.2018.09.01.19.37.46; Sat, 01 Sep 2018 19:38:14 -0700 (PDT) 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=@lixom-net.20150623.gappssmtp.com header.s=20150623 header.b=1srtefVM; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726123AbeIBGt7 (ORCPT + 99 others); Sun, 2 Sep 2018 02:49:59 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:44752 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725867AbeIBGt7 (ORCPT ); Sun, 2 Sep 2018 02:49:59 -0400 Received: by mail-lf1-f66.google.com with SMTP id g6-v6so12660369lfb.11 for ; Sat, 01 Sep 2018 19:35:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lixom-net.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=p8w4jSbjkZqEagZMMJ/CTLchE9OB8JVUasc6oXa5qrc=; b=1srtefVMW8bZTt/A4PrF8enodAiK/l/7PqxXvQPpRWpMXFH8WWgU+zd0bHfRTDb/Dk LQssGBjuhAExlBkaT8qeu58eNaO1BwnC1mp8gOfIQHF6u65LxIsXYRrwqHrReR+CkNcz ER7BGbBfIKugZsQoGHlJoqG9EToX5wD8qHjCLjePzyvVJ8h0xgkQjkMVfZHWfmeK5EQO KEmoLSzJXTJw+RLKhUMJPXTIbZEZdBHfwG4PPdJYWaV3cwEzd7aGmiBqgDuuszAL6h28 rlD8TZYbSTm4RwmOfP9lZkdC6TUcWyGWKUk/42JV6mUr90u1h3Pml23OCePezA4lb5cV T3tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=p8w4jSbjkZqEagZMMJ/CTLchE9OB8JVUasc6oXa5qrc=; b=QIa+YUC7PQif2Vhxwx6aACoehW85FobRNJZGiqn79TWwYjQ8EQAZiO2kcdsmM6AQlr UTIZ/d99LvhCvcyuKvwx5ZefVYe+z0k6M/GJLuIF2t8XETaR17YgglZcDQI28FXbBeey cEug65pjxAgIPdytQH/PHBmuDoN6Gq47UmKh52sINZyaBNhfV04aEN145VmHDkgYy+Q6 DnfT9NZicY95u9J3Cem4lq3oq9SPz2tLtJ7bWMSeQ0URZxYCfPwH6cxrILUs/2It8/Gl 6z+wdlBHpJfgD7A1Dq8Ub7kGuLr1Kt+mHElX69c9tIk8sJfLepDrToYymihfxcl1kWqT 52fg== X-Gm-Message-State: APzg51APAzWscJs6EUaHC2qohDjl5vO2LMn+nuP7G9b7LRyODLP+yqab yGVDGtxaWwDXRV0UkKUA+ez3YOt/jE/yL7ymaoXp4A== X-Received: by 2002:a19:5f54:: with SMTP id a20-v6mr2323153lfj.42.1535855755136; Sat, 01 Sep 2018 19:35:55 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a19:cc08:0:0:0:0:0 with HTTP; Sat, 1 Sep 2018 19:35:53 -0700 (PDT) X-Originating-IP: [99.152.116.91] In-Reply-To: <20180825041647.GA726@sol.localdomain> References: <20180824161642.1144-1-ebiggers@kernel.org> <20180824161642.1144-3-ebiggers@kernel.org> <2f2382c3-e5e9-f0da-dc89-42dfc7b2b636@huawei.com> <20180825041647.GA726@sol.localdomain> From: Olof Johansson Date: Sat, 1 Sep 2018 19:35:53 -0700 Message-ID: Subject: Re: [RFC PATCH 02/10] fs-verity: add data verification hooks for ->readpages() To: Eric Biggers Cc: Gao Xiang , linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, Dmitry Kasatkin , Michael Halcrow , Linux Kernel Mailing List , linux-fscrypt@vger.kernel.org, linux-integrity@vger.kernel.org, Mimi Zohar , Victor Hsieh Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Fri, Aug 24, 2018 at 9:16 PM, Eric Biggers wrote: > Hi Gao, > > On Sat, Aug 25, 2018 at 10:29:26AM +0800, Gao Xiang wrote: >> Hi, >> >> At last, I hope filesystems could select the on-disk position of hash tree and 'struct fsverity_descriptor' >> rather than fixed in the end of verity files...I think if fs-verity preparing such support and interfaces could be better.....hmmm... :( > > In theory it would be a much cleaner design to store verity metadata separately > from the data. But the Merkle tree can be very large. For example, a 1 GB file > using SHA-512 would have a 16.6 MB Merkle tree. So the Merkle tree can't be an > extended attribute, since the xattrs API requires xattrs to be small (<= 64 KB), > and most filesystems further limit xattr sizes in their on-disk format to as > little as 4 KB. Furthermore, even if both of these limits were to be increased, > the xattrs functions (both the syscalls, and the internal functions that > filesystems have) are all based around getting/setting the entire xattr value. > > Also when used with fscrypt, we want the Merkle tree and fsverity_descriptor to > be encrypted, so they doesn't leak plaintext hashes. And we want the Merkle > tree to be paged into memory, just like the file contents, to take advantage of > the usual Linux memory management. > > What we really need is *streams*, like NTFS has. But the filesystems we're > targetting don't support streams, nor does the Linux syscall interface have any > API for accessing streams, nor does the VFS support them. > > Adding streams support to all those things would be a huge multi-year effort, > controversial, and almost certainly not worth it just for fs-verity. > > So simply storing the verity metadata past i_size seems like the best solution > for now. > > That being said, in the future we could pretty easily swap out the calls to > read_mapping_page() with something else if a particular filesystem wanted to > store the metadata somewhere else. We actually even originally had a function > ->read_metadata_page() in the filesystem's fsverity_operations, but it turned > out to be unnecessary and I replaced it with directly calling > read_mapping_page(), but it could be changed back at any time. What about an xattr not to hold the Merkle tree, but to contain a suitable reference to a file/inode+offset that contains it (+ toplevel hash for said tree/file or the descriptor/struct)? If you also expose said file in the directory structure, things such as backups might be easier to handle. For where the tree is appended to the file, you could self-reference. -Olof