Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1412767pxb; Fri, 22 Jan 2021 15:29:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJwen5oM6Y3yk/n6breQZnKjjw085RIjntLE7yH5DiCzPpE6TMyC957tkQlCQ152Bo032/PO X-Received: by 2002:a05:6402:3186:: with SMTP id di6mr5101399edb.45.1611358154724; Fri, 22 Jan 2021 15:29:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611358154; cv=none; d=google.com; s=arc-20160816; b=NkAytEOzFVRqfGlhnZxi8z8OXaazMYWxy8qqF7e1WcS1dqqTVuUxK8PVck/Gy08O+0 lsmEsdTKZvFZz297TGFGVAkkKpQrC6HgVYIod4hdzZEGinZo/Z252NCv5IiUniQqZNOp L7ytMDbRPJiOpuoErZ9hy1mKWSnTkTYql3jx3kYJVtlcQGPPbw6JDMfHtJiBhIWXkB5U knG0Bk3L2deJvVufpQ0qsziNYClsWYOtoVv51l8UpMw3s5hi6ruDBX4f3kcENssYJ0It y0O7fA8Hj+mSyFAWgqUeDxHGO10Ia/F2QVCnrdca65+b2AnpBTtKRRWk4XYqwZAH0vEu flFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=WuooQLj08FTndW6GG4FNdPUFeSvF4QeyXpQNaZQvMQU=; b=IKRI4NRE+45rxN3l6c/sfGdPezOZbB/quok1qvjn+aYBunO3dL9ck4WcgMYnPJ23cU zHZISyT++2mcYQLA3me+adFrk090bLii0GF70zF7+j3KhYenRXIuCpj/Oj8mqitPPSaa xEmFdQYx9YxLCgBTRcpZ1mgUdIaPcpVfAyYflW4M37S/ge4bxCwj2vbPZ3FM3BWWcjYx EdCYbTMZKyaW2SuvOgxiuhQBKwenicKmb1BhgzFt/G8hLVYihe6nxegn5Ez9TXnzasL1 ZN/FjY9mckxwnYsbGq9YWO8KMJIaVowcXf15lnSuH0azPVa3bP/+7seb0UOhPPl8ikST ow5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=YZ6nQ6FO; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g1si3565550ejc.697.2021.01.22.15.28.49; Fri, 22 Jan 2021 15:29:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=YZ6nQ6FO; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728360AbhAVX1s (ORCPT + 99 others); Fri, 22 Jan 2021 18:27:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728253AbhAVX1p (ORCPT ); Fri, 22 Jan 2021 18:27:45 -0500 Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37B15C0613D6 for ; Fri, 22 Jan 2021 15:27:03 -0800 (PST) Received: by mail-io1-xd2b.google.com with SMTP id u8so1522097ior.13 for ; Fri, 22 Jan 2021 15:27:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=WuooQLj08FTndW6GG4FNdPUFeSvF4QeyXpQNaZQvMQU=; b=YZ6nQ6FOxluHSewTFEdRxogFELFzJ61SLsAvjLFQZbuTGGMmwsF7JRUaxP7S0eEf3O zi4YxhJ311FM5HaM9OKi926md/9trhVY4f8oQ2L69cHtC8SiOc/RvEONC0Brp8EzYXLW lv6khpaUQGj21NLNM2haXeFieuHFHlPe5MsuHoJAAixyciIG/WrLFSbzGXn8urZA33tw GkWrMip0Wro8nMmVc+kl4jfg0hBCevvC6rr682OGhXTOkMjl301uDZC7QbGb7Yz/vxMK LBlL4RWfi61+hAnVPZfXrIwr9DYcO/sReuxxZfpkbORXS6rvMYifp7nAEYX563UTR1UV Vw2w== 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=WuooQLj08FTndW6GG4FNdPUFeSvF4QeyXpQNaZQvMQU=; b=YLG7FB+NOO6X+N8lfBDfMghjuSrm24HO0+k+jGsUVVOCQzWSH0qLm14jIJfugt3Azn 2lmetghjSXrhY61KOVHXi7iaZBOngVkqPnpvn7SRPsHaQZnNGNH8922pK2GfwUmJk16b fCu7jfF2X/t34ObPtrKMGqw9Wtsx38utLM8KcT1+rytN5k3Uq7FQGZCAAGhgV3/uZgPk devTe6kXD2tGBhnLTRRgE/3wZv48sPs1zd2QkuBsS6YZwA6DEteank59JBYJuULOVE66 jU+7M0+mpUiVW5rP8Z+XE5GsIdyKx+CzKl6KLghwb0HkeacHL4sty695y88e52seauRM S3Fw== X-Gm-Message-State: AOAM533963X1Q9m4e0id1pX6z4dfCr9y/wcrgBQZxXaOluvPJN5Mn+ju /JfoJ7GqzgDJxwJ/aj/Y2mMcgbiNxym+bRitEr/dKA== X-Received: by 2002:a92:4101:: with SMTP id o1mr174997ila.82.1611358022134; Fri, 22 Jan 2021 15:27:02 -0800 (PST) MIME-Version: 1.0 References: <20210115181819.34732-1-ebiggers@kernel.org> In-Reply-To: <20210115181819.34732-1-ebiggers@kernel.org> From: Victor Hsieh Date: Fri, 22 Jan 2021 15:26:48 -0800 Message-ID: Subject: Re: [PATCH 0/6] fs-verity: add an ioctl to read verity metadata To: Eric Biggers Cc: linux-fscrypt@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-api@vger.kernel.org, "Theodore Ts'o" , Jaegeuk Kim Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org LGTM. Thanks! Reviewed-by: Victor Hsieh On Fri, Jan 15, 2021 at 10:19 AM Eric Biggers wrote: > > [This patchset applies to v5.11-rc3] > > Add an ioctl FS_IOC_READ_VERITY_METADATA which allows reading verity > metadata from a file that has fs-verity enabled, including: > > - The Merkle tree > - The fsverity_descriptor (not including the signature if present) > - The built-in signature, if present > > This ioctl has similar semantics to pread(). It is passed the type of > metadata to read (one of the above three), and a buffer, offset, and > size. It returns the number of bytes read or an error. > > This ioctl doesn't make any assumption about where the metadata is > stored on-disk. It does assume the metadata is in a stable format, but > that's basically already the case: > > - The Merkle tree and fsverity_descriptor are defined by how fs-verity > file digests are computed; see the "File digest computation" section > of Documentation/filesystems/fsverity.rst. Technically, the way in > which the levels of the tree are ordered relative to each other wasn't > previously specified, but it's logical to put the root level first. > > - The built-in signature is the value passed to FS_IOC_ENABLE_VERITY. > > This ioctl is useful because it allows writing a server program that > takes a verity file and serves it to a client program, such that the > client can do its own fs-verity compatible verification of the file. > This only makes sense if the client doesn't trust the server and if the > server needs to provide the storage for the client. > > More concretely, there is interest in using this ability in Android to > export APK files (which are protected by fs-verity) to "protected VMs". > This would use Protected KVM (https://lwn.net/Articles/836693), which > provides an isolated execution environment without having to trust the > traditional "host". A "guest" VM can boot from a signed image and > perform specific tasks in a minimum trusted environment using files that > have fs-verity enabled on the host, without trusting the host or > requiring that the guest has its own trusted storage. > > Technically, it would be possible to duplicate the metadata and store it > in separate files for serving. However, that would be less efficient > and would require extra care in userspace to maintain file consistency. > > In addition to the above, the ability to read the built-in signatures is > useful because it allows a system that is using the in-kernel signature > verification to migrate to userspace signature verification. > > This patchset has been tested by new xfstests which call this new ioctl > via a new subcommand for the 'fsverity' program from fsverity-utils. > > Eric Biggers (6): > fs-verity: factor out fsverity_get_descriptor() > fs-verity: don't pass whole descriptor to fsverity_verify_signature() > fs-verity: add FS_IOC_READ_VERITY_METADATA ioctl > fs-verity: support reading Merkle tree with ioctl > fs-verity: support reading descriptor with ioctl > fs-verity: support reading signature with ioctl > > Documentation/filesystems/fsverity.rst | 76 ++++++++++ > fs/ext4/ioctl.c | 7 + > fs/f2fs/file.c | 11 ++ > fs/verity/Makefile | 1 + > fs/verity/fsverity_private.h | 13 +- > fs/verity/open.c | 133 +++++++++++------ > fs/verity/read_metadata.c | 195 +++++++++++++++++++++++++ > fs/verity/signature.c | 20 +-- > include/linux/fsverity.h | 12 ++ > include/uapi/linux/fsverity.h | 14 ++ > 10 files changed, 417 insertions(+), 65 deletions(-) > create mode 100644 fs/verity/read_metadata.c > > > base-commit: 7c53f6b671f4aba70ff15e1b05148b10d58c2837 > -- > 2.30.0 >