]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
fscrypt: decrypt only the needed blocks in __fscrypt_decrypt_bio()
authorEric Biggers <ebiggers@google.com>
Mon, 20 May 2019 16:29:48 +0000 (09:29 -0700)
committerEric Biggers <ebiggers@google.com>
Tue, 28 May 2019 17:27:53 +0000 (10:27 -0700)
In __fscrypt_decrypt_bio(), only decrypt the blocks that actually
comprise the bio, rather than assuming blocksize == PAGE_SIZE and
decrypting the entirety of every page used in the bio.

This is in preparation for allowing encryption on ext4 filesystems with
blocksize != PAGE_SIZE.

This is based on work by Chandan Rajendra.

Reviewed-by: Chandan Rajendra <chandan@linux.ibm.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
fs/crypto/bio.c

index 61da06fda45cc2456ccbe38a97047a26fb18882f..82da2510721f6b7189af9026a2854c8dbe089c40 100644 (file)
@@ -33,8 +33,8 @@ static void __fscrypt_decrypt_bio(struct bio *bio, bool done)
 
        bio_for_each_segment_all(bv, bio, iter_all) {
                struct page *page = bv->bv_page;
-               int ret = fscrypt_decrypt_pagecache_blocks(page, PAGE_SIZE, 0);
-
+               int ret = fscrypt_decrypt_pagecache_blocks(page, bv->bv_len,
+                                                          bv->bv_offset);
                if (ret)
                        SetPageError(page);
                else if (done)