1
0

Merge branch 'work.compat' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull compat updates from Al Viro:
 "Some biarch patches - getting rid of assorted (mis)uses of
  compat_alloc_user_space().

  Not much in that area this cycle..."

* 'work.compat' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  orangefs: simplify compat ioctl handling
  signalfd: lift sigmask copyin and size checks to callers of do_signalfd4()
  vmsplice(): lift importing iovec into vmsplice(2) and compat counterpart
This commit is contained in:
Linus Torvalds
2018-06-16 16:21:50 +09:00
3 changed files with 112 additions and 136 deletions

View File

@@ -719,37 +719,6 @@ struct ORANGEFS_dev_map_desc32 {
__s32 count;
};
static unsigned long translate_dev_map26(unsigned long args, long *error)
{
struct ORANGEFS_dev_map_desc32 __user *p32 = (void __user *)args;
/*
* Depending on the architecture, allocate some space on the
* user-call-stack based on our expected layout.
*/
struct ORANGEFS_dev_map_desc __user *p =
compat_alloc_user_space(sizeof(*p));
compat_uptr_t addr;
*error = 0;
/* get the ptr from the 32 bit user-space */
if (get_user(addr, &p32->ptr))
goto err;
/* try to put that into a 64-bit layout */
if (put_user(compat_ptr(addr), &p->ptr))
goto err;
/* copy the remaining fields */
if (copy_in_user(&p->total_size, &p32->total_size, sizeof(__s32)))
goto err;
if (copy_in_user(&p->size, &p32->size, sizeof(__s32)))
goto err;
if (copy_in_user(&p->count, &p32->count, sizeof(__s32)))
goto err;
return (unsigned long)p;
err:
*error = -EFAULT;
return 0;
}
/*
* 32 bit user-space apps' ioctl handlers when kernel modules
* is compiled as a 64 bit one
@@ -758,25 +727,26 @@ static long orangefs_devreq_compat_ioctl(struct file *filp, unsigned int cmd,
unsigned long args)
{
long ret;
unsigned long arg = args;
/* Check for properly constructed commands */
ret = check_ioctl_command(cmd);
if (ret < 0)
return ret;
if (cmd == ORANGEFS_DEV_MAP) {
/*
* convert the arguments to what we expect internally
* in kernel space
*/
arg = translate_dev_map26(args, &ret);
if (ret < 0) {
gossip_err("Could not translate dev map\n");
return ret;
}
struct ORANGEFS_dev_map_desc desc;
struct ORANGEFS_dev_map_desc32 d32;
if (copy_from_user(&d32, (void __user *)args, sizeof(d32)))
return -EFAULT;
desc.ptr = compat_ptr(d32.ptr);
desc.total_size = d32.total_size;
desc.size = d32.size;
desc.count = d32.count;
return orangefs_bufmap_initialize(&desc);
}
/* no other ioctl requires translation */
return dispatch_ioctl_command(cmd, arg);
return dispatch_ioctl_command(cmd, args);
}
#endif /* CONFIG_COMPAT is in .config */