From patchwork Thu Apr 8 18:33:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Burkov X-Patchwork-Id: 12192235 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6875EC43460 for ; Thu, 8 Apr 2021 18:34:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3AC04610FC for ; Thu, 8 Apr 2021 18:34:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232845AbhDHSeQ (ORCPT ); Thu, 8 Apr 2021 14:34:16 -0400 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:60099 "EHLO wout5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232840AbhDHSeP (ORCPT ); Thu, 8 Apr 2021 14:34:15 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id BC743EC2; Thu, 8 Apr 2021 14:34:03 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 08 Apr 2021 14:34:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bur.io; h=from :to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=fm3; bh=gd728l4b8OPmwqPe77VVeDs5yO I+vftdu42Je/9HNEc=; b=rSPEYfPLyHpYKG517Y/a4lNxs8hq4aJ1ukFlmPd43/ mGUzPASjpFSqEKgrD/zmCaWYyUCu5GJRtoFWsHaf+3dUvWEJoKugPxILs3c5vW2R 1NByMnHyl7J0rxMwcq+T+jbD0GkngPWbb4U8nduQmVfQRbCpk2reKfGeOVPg6uDx EAaxelszMEY38xNtAgHI6F1UZuvOv0AwsI4WZeEohJE2+Ocro76D4IQFf3lHiBlp O+SCpwhqQE1NcDwmqnLMSucNsgbPRMLtiXMtReoA8Y84q+L7Iy0E8q+vyJTaNYLF VwO42RrKuBUMaGVH5QCagtTYW4/q8sQ3RkNJXvQ4BJ+g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=gd728l4b8OPmwqPe77VVeDs5yOI+vftdu42Je/9HNEc=; b=Jc9rCtiM 1JO/hiKsFbK1wj0oUIsvZ36Q/7LHWIhiTgvlpj96RiWOXWl99aiYUADgE9OuC4hi Vh/NI6NNmGrko8TEfuXz8CWnqt05NMQ/qT3vMla4dszVil/0WXreCZwONcVh+p/m nTCQMpuoIKu/l46GY7BcQxpa7A47EovrmxHcv6SMgE7alWaSeUFLGpGtqle9xlr3 PpKdAx5WYpGzKMI4+g1CjPGATwYga8rJAgiCnIaOcq3uOT4tpBqgYTg4Hxuo0rTx jaWGs/CBtSc9us1gnGxIgOYNIWSVeHb4dGkawIYy/MbhMGVsxv7s9Kv9jiKdVdbJ ewWwoxrSCoK5VQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudejledguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpeeuohhrihhsuceuuhhrkhhovhcuoegsohhrihhssegsuhhr rdhioheqnecuggftrfgrthhtvghrnhepieeuffeuvdeiueejhfehiefgkeevudejjeejff evvdehtddufeeihfekgeeuheelnecukfhppedvtdejrdehfedrvdehfedrjeenucevlhhu shhtvghrufhiiigvpeefnecurfgrrhgrmhepmhgrihhlfhhrohhmpegsohhrihhssegsuh hrrdhioh X-ME-Proxy: Received: from localhost (unknown [207.53.253.7]) by mail.messagingengine.com (Postfix) with ESMTPA id 311311080057; Thu, 8 Apr 2021 14:34:03 -0400 (EDT) From: Boris Burkov To: linux-btrfs@vger.kernel.org, kernel-team@fb.com, linux-fscrypt@vger.kernel.org Subject: [PATCH v3 4/5] btrfs: fallback to buffered io for verity files Date: Thu, 8 Apr 2021 11:33:55 -0700 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fscrypt@vger.kernel.org Reading the contents with direct IO would circumvent verity checks, so fallback to buffered reads. For what it's worth, this is how ext4 handles it as well. Signed-off-by: Boris Burkov --- fs/btrfs/file.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index e8dcada0d239..9f8d90bbbe26 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -3613,6 +3613,9 @@ static ssize_t btrfs_direct_read(struct kiocb *iocb, struct iov_iter *to) struct inode *inode = file_inode(iocb->ki_filp); ssize_t ret; + if (fsverity_active(inode)) + return 0; + if (check_direct_read(btrfs_sb(inode->i_sb), to, iocb->ki_pos)) return 0;