Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6591419yba; Wed, 1 May 2019 15:46:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqzwbB9KjSHe/K2V5IXj/wbgasFYWb12FZf19NnJgHznNzjE7W59YxdLpahXC95NqEV2NXaq X-Received: by 2002:a62:e90d:: with SMTP id j13mr540823pfh.42.1556750799633; Wed, 01 May 2019 15:46:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556750799; cv=none; d=google.com; s=arc-20160816; b=1GC3mEHWZeOCJAcjso0fmCti2p+YCjyZ5oIvyChfXunLsS23v8HVy0VZoR2xEAaXPF 4byslTvh+DmyxpMEV1WvcmjFT5lV0L36OO7MXVE8BT94ksxnE2CWRarhqTlqQRvTXkJp TDW88dsJXz2E/vu4sALPpVy1jQLVFhHHlqcf9WsQVwwlR5VLZ43zAHIRad6+y7y8Mf7/ vy06buBAeTJkxS90CkwgWXLbyMdKrNWtEMLzW6jP1WmaFNp0u72OQNrn9Ol27U6e+rCD lTAmaC14c1cFoolUllW34UlZc1gGszKwBDQiR6lZtziiDYcZK5sMf5cWj50P0mSGhvns vZVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=C9i1GLaQBmEdGQnB+ySJfpErQJO5fr9Id0RQlbBXf84=; b=z+2FOmN654lF7IZSIHdCVHQs6d+sYBfVi8txFT6swsN7s5VwWAH+IOw1MueOf1V/Le TkXCwqo8VEaFBS7PxNcpzivgXVOPf8fkuGi1jNyFI68Eb3bUgR9Gsbujs5VkZNPfNXUt otp3TUUCQwW9sclnNKeXKHQz5TpI6HuLNeUVRWPBPdj0E2KTl08c9z/BFKFYyby144zP UkWh0T5YNvw2VIWYwfb7Q4Qh1MKhplpgIdK80agDVOaqn1qWXIErRFlji4yBxqYtwg4/ M+Rf9y6NqSL46rkxQRCJzUU//z5RaTQ0WrPMJLDnmhO1zQnZIu+0ZExV5W7iwLCTbSW3 945Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2I2LJrbf; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-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 i1si43349323pfr.150.2019.05.01.15.46.24; Wed, 01 May 2019 15:46:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-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=2I2LJrbf; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-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 S1726126AbfEAWqP (ORCPT + 99 others); Wed, 1 May 2019 18:46:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:47220 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726167AbfEAWqJ (ORCPT ); Wed, 1 May 2019 18:46:09 -0400 Received: from ebiggers-linuxstation.mtv.corp.google.com (unknown [104.132.1.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 79081217D6; Wed, 1 May 2019 22:46:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556750768; bh=zasOEShYERzZdFPiCVFwjBxPKVnej4e6HAp2E2v7iWU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2I2LJrbfXh52sDxFMLokfCyxrGL7QigFr/FKy+FHAoXvpvfKHBnUJFcq+1NVvjmaD iT+7TKcp6VAQhvHieFKvYmGR4EHOP4fRV2+SKWnVDRfVQiFYa2f4p75MS749H3YpUs Rkz+v4y9xTgIaPCTUkOuRjVQsbymuUVRUFrWkYjI= From: Eric Biggers To: linux-fscrypt@vger.kernel.org Cc: linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-mtd@lists.infradead.org, linux-fsdevel@vger.kernel.org, Chandan Rajendra Subject: [PATCH 12/13] ext4: decrypt only the needed block in __ext4_block_zero_page_range() Date: Wed, 1 May 2019 15:45:14 -0700 Message-Id: <20190501224515.43059-13-ebiggers@kernel.org> X-Mailer: git-send-email 2.21.0.593.g511ec345e18-goog In-Reply-To: <20190501224515.43059-1-ebiggers@kernel.org> References: <20190501224515.43059-1-ebiggers@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Chandan Rajendra In __ext4_block_zero_page_range(), only decrypt the block that actually needs to be decrypted, rather than assuming blocksize == PAGE_SIZE and decrypting the whole page. This is in preparation for allowing encryption on ext4 filesystems with blocksize != PAGE_SIZE. Signed-off-by: Chandan Rajendra (EB: rebase onto previous changes, improve the commit message, and use bh_offset()) Signed-off-by: Eric Biggers --- fs/ext4/inode.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index d24c50e4598f0..58597db621e1e 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -4073,9 +4073,8 @@ static int __ext4_block_zero_page_range(handle_t *handle, if (S_ISREG(inode->i_mode) && IS_ENCRYPTED(inode)) { /* We expect the key to be set. */ BUG_ON(!fscrypt_has_encryption_key(inode)); - BUG_ON(blocksize != PAGE_SIZE); WARN_ON_ONCE(fscrypt_decrypt_pagecache_blocks( - page, PAGE_SIZE, 0)); + page, blocksize, bh_offset(bh))); } } if (ext4_should_journal_data(inode)) { -- 2.21.0.593.g511ec345e18-goog