From patchwork Wed May 5 19:20:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Burkov X-Patchwork-Id: 12240907 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.8 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=unavailable 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 E22EDC433B4 for ; Wed, 5 May 2021 19:20:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C915C613C4 for ; Wed, 5 May 2021 19:20:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235421AbhEETVw (ORCPT ); Wed, 5 May 2021 15:21:52 -0400 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:53665 "EHLO out2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235377AbhEETVs (ORCPT ); Wed, 5 May 2021 15:21:48 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 6DE5B5C0199; Wed, 5 May 2021 15:20:51 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 05 May 2021 15:20:51 -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=OTn2VJGUKEh++E08+3NbIo7Gy2 0jA/Y9uR37p8Tn0Kc=; b=FTcgRhX3EZlZd8POnj528VDWUT8fOKEk4m88hT4EfF 87zlBXiBd2hzz7JCgBiZ5ikqG5Pe03tn+215u+/lSYFZSR5oym4MvQ/Dv2LhoDyH V4WJjtJ8lTNe/S4THXHJLKimtdJTMqVeCZnemo61+Kixzlb526EMHV9icnzjOE43 DiO234Sr5kn5zjwTagAlp4jKhLUNNEq5Jpr0v1OTHqozXumGlPehwQ2sFJxmq7ss oMudCt92xVUjHTFIgOQT7w22Va694fBJnrasCmM/CLxPWfo9UG8Qz8fKDSuX4z8S y8glTQ4hXYdCDZk9cybYq/qLRXNTmFWhx++2fYVKCqkA== 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=OTn2VJGUKEh++E08+3NbIo7Gy20jA/Y9uR37p8Tn0Kc=; b=jUOHsVsm jIwYaRJmSVfAgcZdmeWGv5NprJiyKGjMML/8M5P/HmBSSjvRB57LT59J8RiCtsQ+ wkuFcujlD1EERYswizHJNaE/28wYHFwK7eHLazL2UTVKFEeLP4xeNJF4ruYNLv/j sCU0+Rk3cR6HtUdRlheWytquLI/Cy6Z/5zvGporHQSTO3kv17FiOmAv+2DSdSgqs Fo45gHYeI6MhiVX6uyp4cs5HG5MgSfffOmgLyQdPgbrUibPcbbOhJZt1uGlGLxoB oaA+xiVtA8eXnQph2mgIdY5druXmrnet1hEC48WFxhIoCLxBbBuFlB81V+EUxwNZ IdN1MjZl3wKGjA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdefkedgudefvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpeeuohhrihhsuceuuhhrkhhovhcuoegsohhrihhssegsuhhr rdhioheqnecuggftrfgrthhtvghrnhepieeuffeuvdeiueejhfehiefgkeevudejjeejff evvdehtddufeeihfekgeeuheelnecukfhppedvtdejrdehfedrvdehfedrjeenucevlhhu shhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpegsohhrihhssegsuh hrrdhioh X-ME-Proxy: Received: from localhost (unknown [207.53.253.7]) by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 5 May 2021 15:20:51 -0400 (EDT) From: Boris Burkov To: linux-btrfs@vger.kernel.org, linux-fscrypt@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v4 4/5] btrfs: fallback to buffered io for verity files Date: Wed, 5 May 2021 12:20:42 -0700 Message-Id: <6d7ffab08e76b18a5e29eff7268f860803a82c61.1620241221.git.boris@bur.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@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 a99470303bd9..34bc22fa6b1f 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -3628,6 +3628,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;