mirror of
https://github.com/torvalds/linux.git
synced 2025-01-01 07:42:07 +00:00
Switch flock copyin/copyout primitives to copy_{from,to}_user()
... and lose HAVE_ARCH_...; if copy_{to,from}_user() on an architecture sucks badly enough to make it a problem, we have a worse problem. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
ca1579f6c6
commit
8c6657cb50
67
fs/fcntl.c
67
fs/fcntl.c
@ -452,57 +452,56 @@ out:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_COMPAT
|
#ifdef CONFIG_COMPAT
|
||||||
|
/* careful - don't use anywhere else */
|
||||||
|
#define copy_flock_fields(from, to) \
|
||||||
|
(to).l_type = (from).l_type; \
|
||||||
|
(to).l_whence = (from).l_whence; \
|
||||||
|
(to).l_start = (from).l_start; \
|
||||||
|
(to).l_len = (from).l_len; \
|
||||||
|
(to).l_pid = (from).l_pid;
|
||||||
|
|
||||||
static int get_compat_flock(struct flock *kfl, struct compat_flock __user *ufl)
|
static int get_compat_flock(struct flock *kfl, struct compat_flock __user *ufl)
|
||||||
{
|
{
|
||||||
if (!access_ok(VERIFY_READ, ufl, sizeof(*ufl)) ||
|
struct compat_flock fl;
|
||||||
__get_user(kfl->l_type, &ufl->l_type) ||
|
|
||||||
__get_user(kfl->l_whence, &ufl->l_whence) ||
|
if (copy_from_user(&fl, ufl, sizeof(struct compat_flock)))
|
||||||
__get_user(kfl->l_start, &ufl->l_start) ||
|
|
||||||
__get_user(kfl->l_len, &ufl->l_len) ||
|
|
||||||
__get_user(kfl->l_pid, &ufl->l_pid))
|
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
copy_flock_fields(*kfl, fl);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int get_compat_flock64(struct flock *kfl, struct compat_flock64 __user *ufl)
|
||||||
|
{
|
||||||
|
struct compat_flock64 fl;
|
||||||
|
|
||||||
|
if (copy_from_user(&fl, ufl, sizeof(struct compat_flock64)))
|
||||||
|
return -EFAULT;
|
||||||
|
copy_flock_fields(*kfl, fl);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int put_compat_flock(struct flock *kfl, struct compat_flock __user *ufl)
|
static int put_compat_flock(struct flock *kfl, struct compat_flock __user *ufl)
|
||||||
{
|
{
|
||||||
if (!access_ok(VERIFY_WRITE, ufl, sizeof(*ufl)) ||
|
struct compat_flock fl;
|
||||||
__put_user(kfl->l_type, &ufl->l_type) ||
|
|
||||||
__put_user(kfl->l_whence, &ufl->l_whence) ||
|
memset(&fl, 0, sizeof(struct compat_flock));
|
||||||
__put_user(kfl->l_start, &ufl->l_start) ||
|
copy_flock_fields(fl, *kfl);
|
||||||
__put_user(kfl->l_len, &ufl->l_len) ||
|
if (copy_to_user(ufl, &fl, sizeof(struct compat_flock)))
|
||||||
__put_user(kfl->l_pid, &ufl->l_pid))
|
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef HAVE_ARCH_GET_COMPAT_FLOCK64
|
|
||||||
static int get_compat_flock64(struct flock *kfl, struct compat_flock64 __user *ufl)
|
|
||||||
{
|
|
||||||
if (!access_ok(VERIFY_READ, ufl, sizeof(*ufl)) ||
|
|
||||||
__get_user(kfl->l_type, &ufl->l_type) ||
|
|
||||||
__get_user(kfl->l_whence, &ufl->l_whence) ||
|
|
||||||
__get_user(kfl->l_start, &ufl->l_start) ||
|
|
||||||
__get_user(kfl->l_len, &ufl->l_len) ||
|
|
||||||
__get_user(kfl->l_pid, &ufl->l_pid))
|
|
||||||
return -EFAULT;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef HAVE_ARCH_PUT_COMPAT_FLOCK64
|
|
||||||
static int put_compat_flock64(struct flock *kfl, struct compat_flock64 __user *ufl)
|
static int put_compat_flock64(struct flock *kfl, struct compat_flock64 __user *ufl)
|
||||||
{
|
{
|
||||||
if (!access_ok(VERIFY_WRITE, ufl, sizeof(*ufl)) ||
|
struct compat_flock64 fl;
|
||||||
__put_user(kfl->l_type, &ufl->l_type) ||
|
|
||||||
__put_user(kfl->l_whence, &ufl->l_whence) ||
|
memset(&fl, 0, sizeof(struct compat_flock64));
|
||||||
__put_user(kfl->l_start, &ufl->l_start) ||
|
copy_flock_fields(fl, *kfl);
|
||||||
__put_user(kfl->l_len, &ufl->l_len) ||
|
if (copy_to_user(ufl, &fl, sizeof(struct compat_flock64)))
|
||||||
__put_user(kfl->l_pid, &ufl->l_pid))
|
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#undef copy_flock_fields
|
||||||
|
|
||||||
static unsigned int
|
static unsigned int
|
||||||
convert_fcntl_cmd(unsigned int cmd)
|
convert_fcntl_cmd(unsigned int cmd)
|
||||||
|
Loading…
Reference in New Issue
Block a user