diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ecryptfs/inode.c | 4 | ||||
-rw-r--r-- | fs/ecryptfs/mmap.c | 11 |
2 files changed, 5 insertions, 10 deletions
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index c92cc1c00aae..7315547193ea 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/mount.h> | 31 | #include <linux/mount.h> |
32 | #include <linux/crypto.h> | 32 | #include <linux/crypto.h> |
33 | #include <linux/fs_stack.h> | 33 | #include <linux/fs_stack.h> |
34 | #include <asm/unaligned.h> | ||
34 | #include "ecryptfs_kernel.h" | 35 | #include "ecryptfs_kernel.h" |
35 | 36 | ||
36 | static struct dentry *lock_parent(struct dentry *dentry) | 37 | static struct dentry *lock_parent(struct dentry *dentry) |
@@ -364,8 +365,7 @@ static struct dentry *ecryptfs_lookup(struct inode *dir, struct dentry *dentry, | |||
364 | else | 365 | else |
365 | file_size = i_size_read(lower_dentry->d_inode); | 366 | file_size = i_size_read(lower_dentry->d_inode); |
366 | } else { | 367 | } else { |
367 | memcpy(&file_size, page_virt, sizeof(file_size)); | 368 | file_size = get_unaligned_be64(page_virt); |
368 | file_size = be64_to_cpu(file_size); | ||
369 | } | 369 | } |
370 | i_size_write(dentry->d_inode, (loff_t)file_size); | 370 | i_size_write(dentry->d_inode, (loff_t)file_size); |
371 | kmem_cache_free(ecryptfs_header_cache_2, page_virt); | 371 | kmem_cache_free(ecryptfs_header_cache_2, page_virt); |
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c index 2b6fe1e6e8ba..245c2dc02d5c 100644 --- a/fs/ecryptfs/mmap.c +++ b/fs/ecryptfs/mmap.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/file.h> | 32 | #include <linux/file.h> |
33 | #include <linux/crypto.h> | 33 | #include <linux/crypto.h> |
34 | #include <linux/scatterlist.h> | 34 | #include <linux/scatterlist.h> |
35 | #include <asm/unaligned.h> | ||
35 | #include "ecryptfs_kernel.h" | 36 | #include "ecryptfs_kernel.h" |
36 | 37 | ||
37 | /** | 38 | /** |
@@ -372,7 +373,6 @@ out: | |||
372 | */ | 373 | */ |
373 | static int ecryptfs_write_inode_size_to_header(struct inode *ecryptfs_inode) | 374 | static int ecryptfs_write_inode_size_to_header(struct inode *ecryptfs_inode) |
374 | { | 375 | { |
375 | u64 file_size; | ||
376 | char *file_size_virt; | 376 | char *file_size_virt; |
377 | int rc; | 377 | int rc; |
378 | 378 | ||
@@ -381,9 +381,7 @@ static int ecryptfs_write_inode_size_to_header(struct inode *ecryptfs_inode) | |||
381 | rc = -ENOMEM; | 381 | rc = -ENOMEM; |
382 | goto out; | 382 | goto out; |
383 | } | 383 | } |
384 | file_size = (u64)i_size_read(ecryptfs_inode); | 384 | put_unaligned_be64(i_size_read(ecryptfs_inode), file_size_virt); |
385 | file_size = cpu_to_be64(file_size); | ||
386 | memcpy(file_size_virt, &file_size, sizeof(u64)); | ||
387 | rc = ecryptfs_write_lower(ecryptfs_inode, file_size_virt, 0, | 385 | rc = ecryptfs_write_lower(ecryptfs_inode, file_size_virt, 0, |
388 | sizeof(u64)); | 386 | sizeof(u64)); |
389 | kfree(file_size_virt); | 387 | kfree(file_size_virt); |
@@ -403,7 +401,6 @@ static int ecryptfs_write_inode_size_to_xattr(struct inode *ecryptfs_inode) | |||
403 | struct dentry *lower_dentry = | 401 | struct dentry *lower_dentry = |
404 | ecryptfs_inode_to_private(ecryptfs_inode)->lower_file->f_dentry; | 402 | ecryptfs_inode_to_private(ecryptfs_inode)->lower_file->f_dentry; |
405 | struct inode *lower_inode = lower_dentry->d_inode; | 403 | struct inode *lower_inode = lower_dentry->d_inode; |
406 | u64 file_size; | ||
407 | int rc; | 404 | int rc; |
408 | 405 | ||
409 | if (!lower_inode->i_op->getxattr || !lower_inode->i_op->setxattr) { | 406 | if (!lower_inode->i_op->getxattr || !lower_inode->i_op->setxattr) { |
@@ -424,9 +421,7 @@ static int ecryptfs_write_inode_size_to_xattr(struct inode *ecryptfs_inode) | |||
424 | xattr_virt, PAGE_CACHE_SIZE); | 421 | xattr_virt, PAGE_CACHE_SIZE); |
425 | if (size < 0) | 422 | if (size < 0) |
426 | size = 8; | 423 | size = 8; |
427 | file_size = (u64)i_size_read(ecryptfs_inode); | 424 | put_unaligned_be64(i_size_read(ecryptfs_inode), xattr_virt); |
428 | file_size = cpu_to_be64(file_size); | ||
429 | memcpy(xattr_virt, &file_size, sizeof(u64)); | ||
430 | rc = lower_inode->i_op->setxattr(lower_dentry, ECRYPTFS_XATTR_NAME, | 425 | rc = lower_inode->i_op->setxattr(lower_dentry, ECRYPTFS_XATTR_NAME, |
431 | xattr_virt, size, 0); | 426 | xattr_virt, size, 0); |
432 | mutex_unlock(&lower_inode->i_mutex); | 427 | mutex_unlock(&lower_inode->i_mutex); |