Commit 0a688ad7 authored by Harvey Harrison's avatar Harvey Harrison Committed by Linus Torvalds

ecryptfs: inode.c mmap.c use unaligned byteorder helpers

Fixe sparse warnings:
fs/ecryptfs/inode.c:368:15: warning: cast to restricted __be64
fs/ecryptfs/mmap.c:385:12: warning: incorrect type in assignment (different base types)
fs/ecryptfs/mmap.c:385:12:    expected unsigned long long [unsigned] [assigned] [usertype] file_size
fs/ecryptfs/mmap.c:385:12:    got restricted __be64 [usertype] <noident>
fs/ecryptfs/mmap.c:428:12: warning: incorrect type in assignment (different base types)
fs/ecryptfs/mmap.c:428:12:    expected unsigned long long [unsigned] [assigned] [usertype] file_size
fs/ecryptfs/mmap.c:428:12:    got restricted __be64 [usertype] <noident>
Signed-off-by: default avatarHarvey Harrison <harvey.harrison@gmail.com>
Cc: Michael Halcrow <mhalcrow@us.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 29335c6a
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <linux/mount.h> #include <linux/mount.h>
#include <linux/crypto.h> #include <linux/crypto.h>
#include <linux/fs_stack.h> #include <linux/fs_stack.h>
#include <asm/unaligned.h>
#include "ecryptfs_kernel.h" #include "ecryptfs_kernel.h"
static struct dentry *lock_parent(struct dentry *dentry) static struct dentry *lock_parent(struct dentry *dentry)
...@@ -364,8 +365,7 @@ static struct dentry *ecryptfs_lookup(struct inode *dir, struct dentry *dentry, ...@@ -364,8 +365,7 @@ static struct dentry *ecryptfs_lookup(struct inode *dir, struct dentry *dentry,
else else
file_size = i_size_read(lower_dentry->d_inode); file_size = i_size_read(lower_dentry->d_inode);
} else { } else {
memcpy(&file_size, page_virt, sizeof(file_size)); file_size = get_unaligned_be64(page_virt);
file_size = be64_to_cpu(file_size);
} }
i_size_write(dentry->d_inode, (loff_t)file_size); i_size_write(dentry->d_inode, (loff_t)file_size);
kmem_cache_free(ecryptfs_header_cache_2, page_virt); kmem_cache_free(ecryptfs_header_cache_2, page_virt);
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <linux/file.h> #include <linux/file.h>
#include <linux/crypto.h> #include <linux/crypto.h>
#include <linux/scatterlist.h> #include <linux/scatterlist.h>
#include <asm/unaligned.h>
#include "ecryptfs_kernel.h" #include "ecryptfs_kernel.h"
/** /**
...@@ -372,7 +373,6 @@ static int ecryptfs_prepare_write(struct file *file, struct page *page, ...@@ -372,7 +373,6 @@ static int ecryptfs_prepare_write(struct file *file, struct page *page,
*/ */
static int ecryptfs_write_inode_size_to_header(struct inode *ecryptfs_inode) static int ecryptfs_write_inode_size_to_header(struct inode *ecryptfs_inode)
{ {
u64 file_size;
char *file_size_virt; char *file_size_virt;
int rc; int rc;
...@@ -381,9 +381,7 @@ static int ecryptfs_write_inode_size_to_header(struct inode *ecryptfs_inode) ...@@ -381,9 +381,7 @@ static int ecryptfs_write_inode_size_to_header(struct inode *ecryptfs_inode)
rc = -ENOMEM; rc = -ENOMEM;
goto out; goto out;
} }
file_size = (u64)i_size_read(ecryptfs_inode); put_unaligned_be64(i_size_read(ecryptfs_inode), file_size_virt);
file_size = cpu_to_be64(file_size);
memcpy(file_size_virt, &file_size, sizeof(u64));
rc = ecryptfs_write_lower(ecryptfs_inode, file_size_virt, 0, rc = ecryptfs_write_lower(ecryptfs_inode, file_size_virt, 0,
sizeof(u64)); sizeof(u64));
kfree(file_size_virt); kfree(file_size_virt);
...@@ -403,7 +401,6 @@ static int ecryptfs_write_inode_size_to_xattr(struct inode *ecryptfs_inode) ...@@ -403,7 +401,6 @@ static int ecryptfs_write_inode_size_to_xattr(struct inode *ecryptfs_inode)
struct dentry *lower_dentry = struct dentry *lower_dentry =
ecryptfs_inode_to_private(ecryptfs_inode)->lower_file->f_dentry; ecryptfs_inode_to_private(ecryptfs_inode)->lower_file->f_dentry;
struct inode *lower_inode = lower_dentry->d_inode; struct inode *lower_inode = lower_dentry->d_inode;
u64 file_size;
int rc; int rc;
if (!lower_inode->i_op->getxattr || !lower_inode->i_op->setxattr) { 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,9 +421,7 @@ static int ecryptfs_write_inode_size_to_xattr(struct inode *ecryptfs_inode)
xattr_virt, PAGE_CACHE_SIZE); xattr_virt, PAGE_CACHE_SIZE);
if (size < 0) if (size < 0)
size = 8; size = 8;
file_size = (u64)i_size_read(ecryptfs_inode); put_unaligned_be64(i_size_read(ecryptfs_inode), xattr_virt);
file_size = cpu_to_be64(file_size);
memcpy(xattr_virt, &file_size, sizeof(u64));
rc = lower_inode->i_op->setxattr(lower_dentry, ECRYPTFS_XATTR_NAME, rc = lower_inode->i_op->setxattr(lower_dentry, ECRYPTFS_XATTR_NAME,
xattr_virt, size, 0); xattr_virt, size, 0);
mutex_unlock(&lower_inode->i_mutex); mutex_unlock(&lower_inode->i_mutex);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment