From: Jaegeuk Kim <jaegeuk@kernel.org>
To: linux-ext4@vger.kernel.org, Theodore Ts'o <tytso@mit.edu>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Subject: [PATCH 3/3] ext4 crypto: use inode number for xts_tweak
Date: Tue, 12 May 2015 14:21:05 -0700 [thread overview]
Message-ID: <1431465665-36803-2-git-send-email-jaegeuk@kernel.org> (raw)
In-Reply-To: <1431465665-36803-1-git-send-email-jaegeuk@kernel.org>
This patch was from:
"f2fs crypto: use inode number for xts_tweak
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 decryption failure.
In order to avoid that, let's use the inode->i_ino for xfs_tweak hint."
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fs/ext4/crypto.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/fs/ext4/crypto.c b/fs/ext4/crypto.c
index f265c08..5653646 100644
--- a/fs/ext4/crypto.c
+++ b/fs/ext4/crypto.c
@@ -337,7 +337,6 @@ typedef enum {
static int ext4_page_crypto(struct ext4_crypto_ctx *ctx,
struct inode *inode,
ext4_direction_t rw,
- pgoff_t index,
struct page *src_page,
struct page *dest_page)
@@ -382,10 +381,10 @@ static int ext4_page_crypto(struct ext4_crypto_ctx *ctx,
req, CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP,
ext4_crypt_complete, &ecr);
- BUILD_BUG_ON(EXT4_XTS_TWEAK_SIZE < sizeof(index));
- memcpy(xts_tweak, &index, sizeof(index));
- memset(&xts_tweak[sizeof(index)], 0,
- EXT4_XTS_TWEAK_SIZE - sizeof(index));
+ BUILD_BUG_ON(EXT4_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,
+ EXT4_XTS_TWEAK_SIZE - sizeof(inode->i_ino));
sg_init_table(&dst, 1);
sg_set_page(&dst, dest_page, PAGE_CACHE_SIZE, 0);
@@ -459,7 +458,7 @@ struct page *ext4_encrypt(struct inode *inode,
ctx->flags |= EXT4_WRITE_PATH_FL;
ctx->w.bounce_page = ciphertext_page;
ctx->w.control_page = plaintext_page;
- err = ext4_page_crypto(ctx, inode, EXT4_ENCRYPT, plaintext_page->index,
+ err = ext4_page_crypto(ctx, inode, EXT4_ENCRYPT,
plaintext_page, ciphertext_page);
if (err) {
ext4_release_crypto_ctx(ctx);
@@ -487,7 +486,7 @@ int ext4_decrypt(struct ext4_crypto_ctx *ctx, struct page *page)
BUG_ON(!PageLocked(page));
return ext4_page_crypto(ctx, page->mapping->host,
- EXT4_DECRYPT, page->index, page, page);
+ EXT4_DECRYPT, page, page);
}
/*
@@ -541,7 +540,7 @@ int ext4_encrypted_zeroout(struct inode *inode, struct ext4_extent *ex)
while (len--) {
err = ext4_page_crypto(ctx, inode, EXT4_ENCRYPT, lblk,
- ZERO_PAGE(0), ciphertext_page);
+ ciphertext_page);
if (err)
goto errout;
--
2.1.1
next prev parent reply other threads:[~2015-05-12 21:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-12 21:21 [PATCH 2/3] ext4 crypto: initialize crypto memory in early stage Jaegeuk Kim
2015-05-12 21:21 ` Jaegeuk Kim [this message]
2015-05-12 21:31 ` [PATCH 3/3 v2] ext4 crypto: use inode number for xts_tweak Jaegeuk Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1431465665-36803-2-git-send-email-jaegeuk@kernel.org \
--to=jaegeuk@kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).