Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5075288imm; Sun, 26 Aug 2018 10:06:56 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaAecnW2v0XsktYF7mVAEBRkJ9m93gqCrEWJrwybwwNzbqHaL1o5eCEy4uAq+W19l3RWzps X-Received: by 2002:a65:5004:: with SMTP id f4-v6mr9119957pgo.54.1535303216213; Sun, 26 Aug 2018 10:06:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535303216; cv=none; d=google.com; s=arc-20160816; b=fpfRWL7Pl+y7opgOIZArTMISMOuuV+iWx6HZpaKeS7uJHh4zGAV3b6QI4vQKrIUhH2 WeF3jxEYm0fxmgoQ4pXSSlg6m30SZj8QRjUA2RyCKe7GEwpEib8oRpqRMq+5Nze5sl6J 7ZygCY/reEubXoJ4dqYUqvABs9lPhiyOy+tKDfLbJgLOMjk2nOB6ODTJ0d4LWXJjO5g8 jf54l1yfU2QZ8FTCdv4QowiuXfBYe18ejkvuDWrTTXb5Nq/eN91qqOq2KMrqeM6GvhCT QDSQ0TKrx+k4kmqKb/iMD0tNG0QXiZZN+IC2rOOHXWnW8icvBEJiH5gWhI/qjh9PfRs0 T5mw== 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:dkim-signature:arc-authentication-results; bh=6E3KvTszlfC+fwyKkuh0LwuYP/wPJEQurVMyXTN1atc=; b=yMFQLapSxCIt23ybVuSOd79eV8Ye0dxkCRCDD9LMm78aZ5bkEYlpSAO2AvTbRqXkd/ fKQpIkpxW+REoXqaUEOOkdfyOmfgomioF/nctRnqFdly+t154GA5ZAUlUUfrKlQSaKCt FN8LNWxiA3+JQeDvkcLtYRcOlwkYHXBEI1HxRGHVpKzjMPlPJROJVe8d63QL5dpVv3n/ Pk6Zd1K822nP4EjBZIyzZskGY5FyrVm5YbPYf+wMaWJBssBbkVG38D0wjl3RyW2O/571 cpH/r5GOF3by5gmx/IRqBoZcX/j0YMv53xf6/tXR23f8VWzP441EtmzDOuIDGtXLErNH VvEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="YKO/eJeb"; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c22-v6si11216163plo.271.2018.08.26.10.06.28; Sun, 26 Aug 2018 10:06:56 -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=@kernel.org header.s=default header.b="YKO/eJeb"; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726945AbeHZUrn (ORCPT + 99 others); Sun, 26 Aug 2018 16:47:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:33958 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726714AbeHZUrm (ORCPT ); Sun, 26 Aug 2018 16:47:42 -0400 Received: from sol.localdomain (c-67-185-97-198.hsd1.wa.comcast.net [67.185.97.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 32FFD208C1; Sun, 26 Aug 2018 17:04:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1535303076; bh=ohaZbZAB95OjMvy7U3GOyZwt2LQUz230ySU1sSUuS6k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YKO/eJebcKyjtkaEnYRW+KGAwoHJC+HtU56EmGM0fagRT8D186na3vA2xa+XvLaR4 UWtUnK1ihI5Ls4gS+XSKfYaOgsR/XXOLj94Iwu9AiokLVvD24lNKyf//aRwWR24lR2 Bpr/GuK13K/i6VdnHAyhWzlVd5DC1GiW9vordyUE= Date: Sun, 26 Aug 2018 10:04:34 -0700 From: Eric Biggers To: Chuck Lever Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-integrity@vger.kernel.org, linux-fscrypt@vger.kernel.org, linux-kernel@vger.kernel.org, Mimi Zohar , Dmitry Kasatkin , Michael Halcrow , Victor Hsieh Subject: Re: [RFC PATCH 02/10] fs-verity: add data verification hooks for ->readpages() Message-ID: <20180826170433.GA728@sol.localdomain> References: <20180824161642.1144-1-ebiggers@kernel.org> <20180824161642.1144-3-ebiggers@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Chuck, On Sun, Aug 26, 2018 at 11:55:57AM -0400, Chuck Lever wrote: > > + > > +/** > > + * fsverity_verify_page - verify a data page > > + * > > + * Verify a page that has just been read from a file against that file's Merkle > > + * tree. The page is assumed to be a pagecache page. > > + * > > + * Return: true if the page is valid, else false. > > + */ > > +bool fsverity_verify_page(struct page *data_page) > > +{ > > + struct inode *inode = data_page->mapping->host; > > + const struct fsverity_info *vi = get_fsverity_info(inode); > > + struct ahash_request *req; > > + bool valid; > > + > > + req = ahash_request_alloc(vi->hash_alg->tfm, GFP_KERNEL); > > + if (unlikely(!req)) > > + return false; > > + > > + valid = verify_page(inode, vi, req, data_page); > > + > > + ahash_request_free(req); > > + > > + return valid; > > +} > > +EXPORT_SYMBOL_GPL(fsverity_verify_page); > > + > > +/** > > + * fsverity_verify_bio - verify a 'read' bio that has just completed > > + * > > + * Verify a set of pages that have just been read from a file against that > > + * file's Merkle tree. The pages are assumed to be pagecache pages. Pages that > > + * fail verification are set to the Error state. Verification is skipped for > > + * pages already in the Error state, e.g. due to fscrypt decryption failure. > > + */ > > +void fsverity_verify_bio(struct bio *bio) > > Hi Eric- > > This kind of API won't work for remote filesystems, which do not use > "struct bio" to do their I/O. Could a remote filesystem solely use > fsverity_verify_page instead? > Yes, filesystems don't have to use fsverity_verify_bio(). They can call fsverity_verify_page() on each page instead. I will clarify this in the next revision of the patchset. - Eric