Skip to content

Commit 430ff79

Browse files
author
Al Viro
committed
orangefs: simplify compat ioctl handling
no need to mess with copy_in_user(), etc... Signed-off-by: Al Viro <[email protected]>
1 parent 5ed0127 commit 430ff79

File tree

1 file changed

+12
-42
lines changed

1 file changed

+12
-42
lines changed

fs/orangefs/devorangefs-req.c

Lines changed: 12 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -716,37 +716,6 @@ struct ORANGEFS_dev_map_desc32 {
716716
__s32 count;
717717
};
718718

719-
static unsigned long translate_dev_map26(unsigned long args, long *error)
720-
{
721-
struct ORANGEFS_dev_map_desc32 __user *p32 = (void __user *)args;
722-
/*
723-
* Depending on the architecture, allocate some space on the
724-
* user-call-stack based on our expected layout.
725-
*/
726-
struct ORANGEFS_dev_map_desc __user *p =
727-
compat_alloc_user_space(sizeof(*p));
728-
compat_uptr_t addr;
729-
730-
*error = 0;
731-
/* get the ptr from the 32 bit user-space */
732-
if (get_user(addr, &p32->ptr))
733-
goto err;
734-
/* try to put that into a 64-bit layout */
735-
if (put_user(compat_ptr(addr), &p->ptr))
736-
goto err;
737-
/* copy the remaining fields */
738-
if (copy_in_user(&p->total_size, &p32->total_size, sizeof(__s32)))
739-
goto err;
740-
if (copy_in_user(&p->size, &p32->size, sizeof(__s32)))
741-
goto err;
742-
if (copy_in_user(&p->count, &p32->count, sizeof(__s32)))
743-
goto err;
744-
return (unsigned long)p;
745-
err:
746-
*error = -EFAULT;
747-
return 0;
748-
}
749-
750719
/*
751720
* 32 bit user-space apps' ioctl handlers when kernel modules
752721
* is compiled as a 64 bit one
@@ -755,25 +724,26 @@ static long orangefs_devreq_compat_ioctl(struct file *filp, unsigned int cmd,
755724
unsigned long args)
756725
{
757726
long ret;
758-
unsigned long arg = args;
759727

760728
/* Check for properly constructed commands */
761729
ret = check_ioctl_command(cmd);
762730
if (ret < 0)
763731
return ret;
764732
if (cmd == ORANGEFS_DEV_MAP) {
765-
/*
766-
* convert the arguments to what we expect internally
767-
* in kernel space
768-
*/
769-
arg = translate_dev_map26(args, &ret);
770-
if (ret < 0) {
771-
gossip_err("Could not translate dev map\n");
772-
return ret;
773-
}
733+
struct ORANGEFS_dev_map_desc desc;
734+
struct ORANGEFS_dev_map_desc32 d32;
735+
736+
if (copy_from_user(&d32, (void __user *)args, sizeof(d32)))
737+
return -EFAULT;
738+
739+
desc.ptr = compat_ptr(d32.ptr);
740+
desc.total_size = d32.total_size;
741+
desc.size = d32.size;
742+
desc.count = d32.count;
743+
return orangefs_bufmap_initialize(&desc);
774744
}
775745
/* no other ioctl requires translation */
776-
return dispatch_ioctl_command(cmd, arg);
746+
return dispatch_ioctl_command(cmd, args);
777747
}
778748

779749
#endif /* CONFIG_COMPAT is in .config */

0 commit comments

Comments
 (0)