Skip to content

Commit

Permalink
atm: lift copyin from atm_dev_ioctl()
Browse files Browse the repository at this point in the history
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed May 21, 2020
1 parent 3608504 commit 8cacb41
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 33 deletions.
25 changes: 24 additions & 1 deletion net/atm/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,30 @@ static int do_vcc_ioctl(struct socket *sock, unsigned int cmd,
}
error = atm_getnames(buf, len);
} else {
error = atm_dev_ioctl(cmd, argp, compat);
int number;

if (IS_ENABLED(CONFIG_COMPAT) && compat) {
#ifdef CONFIG_COMPAT
struct compat_atmif_sioc __user *csioc = argp;
compat_uptr_t carg;

len = &csioc->length;
if (get_user(carg, &csioc->arg))
return -EFAULT;
buf = compat_ptr(carg);
if (get_user(number, &csioc->number))
return -EFAULT;
#endif
} else {
struct atmif_sioc __user *sioc = argp;

len = &sioc->length;
if (get_user(buf, &sioc->arg))
return -EFAULT;
if (get_user(number, &sioc->number))
return -EFAULT;
}
error = atm_dev_ioctl(cmd, buf, len, number, compat);
}

done:
Expand Down
35 changes: 5 additions & 30 deletions net/atm/resources.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,39 +227,14 @@ int atm_getnames(void __user *buf, int __user *iobuf_len)
return error;
}

int atm_dev_ioctl(unsigned int cmd, void __user *arg, int compat)
int atm_dev_ioctl(unsigned int cmd, void __user *buf, int __user *sioc_len,
int number, int compat)
{
void __user *buf;
int error, len, number, size = 0;
int error, len, size = 0;
struct atm_dev *dev;
int __user *sioc_len;

if (IS_ENABLED(CONFIG_COMPAT) && compat) {
#ifdef CONFIG_COMPAT
struct compat_atmif_sioc __user *csioc = arg;
compat_uptr_t carg;

sioc_len = &csioc->length;
if (get_user(carg, &csioc->arg))
return -EFAULT;
buf = compat_ptr(carg);

if (get_user(len, &csioc->length))
return -EFAULT;
if (get_user(number, &csioc->number))
return -EFAULT;
#endif
} else {
struct atmif_sioc __user *sioc = arg;

sioc_len = &sioc->length;
if (get_user(buf, &sioc->arg))
return -EFAULT;
if (get_user(len, &sioc->length))
return -EFAULT;
if (get_user(number, &sioc->number))
return -EFAULT;
}
if (get_user(len, sioc_len))
return -EFAULT;

dev = try_then_request_module(atm_dev_lookup(number), "atm-device-%d",
number);
Expand Down
4 changes: 2 additions & 2 deletions net/atm/resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ extern struct list_head atm_devs;
extern struct mutex atm_dev_mutex;

int atm_getnames(void __user *buf, int __user *iobuf_len);
int atm_dev_ioctl(unsigned int cmd, void __user *arg, int compat);

int atm_dev_ioctl(unsigned int cmd, void __user *buf, int __user *sioc_len,
int number, int compat);

#ifdef CONFIG_PROC_FS

Expand Down

0 comments on commit 8cacb41

Please sign in to comment.