fs/fcntl: use copy_to/from_user() for u64 types
Some architectures (at least PPC) doesn't like get/put_user with
64-bit types on a 32-bit system. Use the variably sized copy
to/from user variants instead.
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Fixes: c75b1d9421
("fs: add fcntl() interface for setting/getting write life time hints")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
e9d5d4a0c1
commit
5657cb0797
13
fs/fcntl.c
13
fs/fcntl.c
|
@ -264,15 +264,18 @@ static long fcntl_rw_hint(struct file *file, unsigned int cmd,
|
||||||
struct inode *inode = file_inode(file);
|
struct inode *inode = file_inode(file);
|
||||||
u64 *argp = (u64 __user *)arg;
|
u64 *argp = (u64 __user *)arg;
|
||||||
enum rw_hint hint;
|
enum rw_hint hint;
|
||||||
|
u64 h;
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case F_GET_FILE_RW_HINT:
|
case F_GET_FILE_RW_HINT:
|
||||||
if (put_user(file_write_hint(file), argp))
|
h = file_write_hint(file);
|
||||||
|
if (copy_to_user(argp, &h, sizeof(*argp)))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
return 0;
|
return 0;
|
||||||
case F_SET_FILE_RW_HINT:
|
case F_SET_FILE_RW_HINT:
|
||||||
if (get_user(hint, argp))
|
if (copy_from_user(&h, argp, sizeof(h)))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
hint = (enum rw_hint) h;
|
||||||
if (!rw_hint_valid(hint))
|
if (!rw_hint_valid(hint))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
@ -281,12 +284,14 @@ static long fcntl_rw_hint(struct file *file, unsigned int cmd,
|
||||||
spin_unlock(&file->f_lock);
|
spin_unlock(&file->f_lock);
|
||||||
return 0;
|
return 0;
|
||||||
case F_GET_RW_HINT:
|
case F_GET_RW_HINT:
|
||||||
if (put_user(inode->i_write_hint, argp))
|
h = inode->i_write_hint;
|
||||||
|
if (copy_to_user(argp, &h, sizeof(*argp)))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
return 0;
|
return 0;
|
||||||
case F_SET_RW_HINT:
|
case F_SET_RW_HINT:
|
||||||
if (get_user(hint, argp))
|
if (copy_from_user(&h, argp, sizeof(h)))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
hint = (enum rw_hint) h;
|
||||||
if (!rw_hint_valid(hint))
|
if (!rw_hint_valid(hint))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue