diff options
author | Jens Axboe <axboe@kernel.dk> | 2017-06-28 10:09:45 -0400 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2017-06-28 10:09:45 -0400 |
commit | 5657cb0797c4ab303f5782442095319bd971257b (patch) | |
tree | ca0b3a6843965f6da3128472491f47cd3f6f3785 /fs/fcntl.c | |
parent | e9d5d4a0c13f47e331e39a4c66a9b3da701b280b (diff) |
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: c75b1d9421f8 ("fs: add fcntl() interface for setting/getting write life time hints")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/fcntl.c')
-rw-r--r-- | fs/fcntl.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/fs/fcntl.c b/fs/fcntl.c index 67bdc6e8ccad..ed051f825bad 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c | |||
@@ -264,15 +264,18 @@ static long fcntl_rw_hint(struct file *file, unsigned int cmd, | |||
264 | struct inode *inode = file_inode(file); | 264 | struct inode *inode = file_inode(file); |
265 | u64 *argp = (u64 __user *)arg; | 265 | u64 *argp = (u64 __user *)arg; |
266 | enum rw_hint hint; | 266 | enum rw_hint hint; |
267 | u64 h; | ||
267 | 268 | ||
268 | switch (cmd) { | 269 | switch (cmd) { |
269 | case F_GET_FILE_RW_HINT: | 270 | case F_GET_FILE_RW_HINT: |
270 | if (put_user(file_write_hint(file), argp)) | 271 | h = file_write_hint(file); |
272 | if (copy_to_user(argp, &h, sizeof(*argp))) | ||
271 | return -EFAULT; | 273 | return -EFAULT; |
272 | return 0; | 274 | return 0; |
273 | case F_SET_FILE_RW_HINT: | 275 | case F_SET_FILE_RW_HINT: |
274 | if (get_user(hint, argp)) | 276 | if (copy_from_user(&h, argp, sizeof(h))) |
275 | return -EFAULT; | 277 | return -EFAULT; |
278 | hint = (enum rw_hint) h; | ||
276 | if (!rw_hint_valid(hint)) | 279 | if (!rw_hint_valid(hint)) |
277 | return -EINVAL; | 280 | return -EINVAL; |
278 | 281 | ||
@@ -281,12 +284,14 @@ static long fcntl_rw_hint(struct file *file, unsigned int cmd, | |||
281 | spin_unlock(&file->f_lock); | 284 | spin_unlock(&file->f_lock); |
282 | return 0; | 285 | return 0; |
283 | case F_GET_RW_HINT: | 286 | case F_GET_RW_HINT: |
284 | if (put_user(inode->i_write_hint, argp)) | 287 | h = inode->i_write_hint; |
288 | if (copy_to_user(argp, &h, sizeof(*argp))) | ||
285 | return -EFAULT; | 289 | return -EFAULT; |
286 | return 0; | 290 | return 0; |
287 | case F_SET_RW_HINT: | 291 | case F_SET_RW_HINT: |
288 | if (get_user(hint, argp)) | 292 | if (copy_from_user(&h, argp, sizeof(h))) |
289 | return -EFAULT; | 293 | return -EFAULT; |
294 | hint = (enum rw_hint) h; | ||
290 | if (!rw_hint_valid(hint)) | 295 | if (!rw_hint_valid(hint)) |
291 | return -EINVAL; | 296 | return -EINVAL; |
292 | 297 | ||