diff options
Diffstat (limited to 'fs/crypto/crypto.c')
-rw-r--r-- | fs/crypto/crypto.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/fs/crypto/crypto.c b/fs/crypto/crypto.c index 61057b7dbddb..98f87fe8f186 100644 --- a/fs/crypto/crypto.c +++ b/fs/crypto/crypto.c | |||
@@ -151,7 +151,10 @@ static int do_page_crypto(struct inode *inode, | |||
151 | struct page *src_page, struct page *dest_page, | 151 | struct page *src_page, struct page *dest_page, |
152 | gfp_t gfp_flags) | 152 | gfp_t gfp_flags) |
153 | { | 153 | { |
154 | u8 xts_tweak[FS_XTS_TWEAK_SIZE]; | 154 | struct { |
155 | __le64 index; | ||
156 | u8 padding[FS_XTS_TWEAK_SIZE - sizeof(__le64)]; | ||
157 | } xts_tweak; | ||
155 | struct skcipher_request *req = NULL; | 158 | struct skcipher_request *req = NULL; |
156 | DECLARE_FS_COMPLETION_RESULT(ecr); | 159 | DECLARE_FS_COMPLETION_RESULT(ecr); |
157 | struct scatterlist dst, src; | 160 | struct scatterlist dst, src; |
@@ -171,17 +174,15 @@ static int do_page_crypto(struct inode *inode, | |||
171 | req, CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP, | 174 | req, CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP, |
172 | page_crypt_complete, &ecr); | 175 | page_crypt_complete, &ecr); |
173 | 176 | ||
174 | BUILD_BUG_ON(FS_XTS_TWEAK_SIZE < sizeof(index)); | 177 | BUILD_BUG_ON(sizeof(xts_tweak) != FS_XTS_TWEAK_SIZE); |
175 | memcpy(xts_tweak, &index, sizeof(index)); | 178 | xts_tweak.index = cpu_to_le64(index); |
176 | memset(&xts_tweak[sizeof(index)], 0, | 179 | memset(xts_tweak.padding, 0, sizeof(xts_tweak.padding)); |
177 | FS_XTS_TWEAK_SIZE - sizeof(index)); | ||
178 | 180 | ||
179 | sg_init_table(&dst, 1); | 181 | sg_init_table(&dst, 1); |
180 | sg_set_page(&dst, dest_page, PAGE_SIZE, 0); | 182 | sg_set_page(&dst, dest_page, PAGE_SIZE, 0); |
181 | sg_init_table(&src, 1); | 183 | sg_init_table(&src, 1); |
182 | sg_set_page(&src, src_page, PAGE_SIZE, 0); | 184 | sg_set_page(&src, src_page, PAGE_SIZE, 0); |
183 | skcipher_request_set_crypt(req, &src, &dst, PAGE_SIZE, | 185 | skcipher_request_set_crypt(req, &src, &dst, PAGE_SIZE, &xts_tweak); |
184 | xts_tweak); | ||
185 | if (rw == FS_DECRYPT) | 186 | if (rw == FS_DECRYPT) |
186 | res = crypto_skcipher_decrypt(req); | 187 | res = crypto_skcipher_decrypt(req); |
187 | else | 188 | else |