@@ -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);
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@linux.vnet.ibm.com> --- fs/crypto/bio.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)