For block size < page size scenario, the block to be decrypted can be mapped at a non-zero page offset and the length of the block is less than page size. Hence this commit fixes the corresponding arguments sent to fscrypt_decrypt_page(). Signed-off-by: Chandan Rajendra <chandan@xxxxxxxxxxxxxxxxxx> --- fs/crypto/bio.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/crypto/bio.c b/fs/crypto/bio.c index 778b826..32288c3 100644 --- a/fs/crypto/bio.c +++ b/fs/crypto/bio.c @@ -33,9 +33,15 @@ static void __fscrypt_decrypt_bio(struct bio *bio, bool done) bio_for_each_segment_all(bv, bio, i) { struct page *page = bv->bv_page; - int ret = fscrypt_decrypt_page(page->mapping->host, page, - PAGE_SIZE, 0, page->index); + struct inode *inode = page->mapping->host; + u64 blk; + int ret; + blk = page->index << (PAGE_SHIFT - inode->i_blkbits); + blk += bv->bv_offset >> inode->i_blkbits; + + ret = fscrypt_decrypt_page(page->mapping->host, page, + bv->bv_len, bv->bv_offset, blk); if (ret) { WARN_ON_ONCE(1); SetPageError(page); -- 2.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-fscrypt" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html
![]() |