From patchwork Tue May 12 03:51:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaegeuk Kim X-Patchwork-Id: 6385381 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 43ED8BEEE1 for ; Tue, 12 May 2015 03:51:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7560A203DA for ; Tue, 12 May 2015 03:51:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9CC9C203C4 for ; Tue, 12 May 2015 03:51:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752627AbbELDvJ (ORCPT ); Mon, 11 May 2015 23:51:09 -0400 Received: from mail.kernel.org ([198.145.29.136]:60192 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752247AbbELDvJ (ORCPT ); Mon, 11 May 2015 23:51:09 -0400 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 11241203DA; Tue, 12 May 2015 03:51:08 +0000 (UTC) Received: from localhost (unknown [166.170.42.189]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1F08B203DB; Tue, 12 May 2015 03:51:07 +0000 (UTC) From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: Jaegeuk Kim Subject: [PATCH] f2fs crypto: use inode number for xts_tweak Date: Mon, 11 May 2015 20:51:03 -0700 Message-Id: <1431402663-24809-1-git-send-email-jaegeuk@kernel.org> X-Mailer: git-send-email 2.1.1 X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Previoulsy when making xts_tweak, page->index was used. But, when it supports fcollapse, the block address was moved, so that we can lose the original page->index, which causes decrytion failure. In order to avoid that, let's use the inode->i_ino for xfs_tweak hint. Signed-off-by: Jaegeuk Kim --- fs/f2fs/crypto.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/fs/f2fs/crypto.c b/fs/f2fs/crypto.c index 1dd0835..35986a5 100644 --- a/fs/f2fs/crypto.c +++ b/fs/f2fs/crypto.c @@ -375,7 +375,6 @@ typedef enum { static int f2fs_page_crypto(struct f2fs_crypto_ctx *ctx, struct inode *inode, f2fs_direction_t rw, - pgoff_t index, struct page *src_page, struct page *dest_page) @@ -420,10 +419,10 @@ static int f2fs_page_crypto(struct f2fs_crypto_ctx *ctx, req, CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP, f2fs_crypt_complete, &ecr); - BUILD_BUG_ON(F2FS_XTS_TWEAK_SIZE < sizeof(index)); - memcpy(xts_tweak, &index, sizeof(index)); - memset(&xts_tweak[sizeof(index)], 0, - F2FS_XTS_TWEAK_SIZE - sizeof(index)); + BUILD_BUG_ON(F2FS_XTS_TWEAK_SIZE < sizeof(inode->i_ino)); + memcpy(xts_tweak, &inode->i_ino, sizeof(inode->i_ino)); + memset(&xts_tweak[sizeof(inode->i_ino)], 0, + F2FS_XTS_TWEAK_SIZE - sizeof(inode->i_ino)); sg_init_table(&dst, 1); sg_set_page(&dst, dest_page, PAGE_CACHE_SIZE, 0); @@ -496,7 +495,7 @@ struct page *f2fs_encrypt(struct inode *inode, } ctx->bounce_page = ciphertext_page; ctx->control_page = plaintext_page; - err = f2fs_page_crypto(ctx, inode, F2FS_ENCRYPT, plaintext_page->index, + err = f2fs_page_crypto(ctx, inode, F2FS_ENCRYPT, plaintext_page, ciphertext_page); if (err) { f2fs_release_crypto_ctx(ctx); @@ -524,7 +523,7 @@ int f2fs_decrypt(struct f2fs_crypto_ctx *ctx, struct page *page) BUG_ON(!PageLocked(page)); return f2fs_page_crypto(ctx, page->mapping->host, - F2FS_DECRYPT, page->index, page, page); + F2FS_DECRYPT, page, page); } /*