Commit e0ac3f98 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge branch 'vt_copy_cleanup' into tty-next

The vt copy_from/to_user cleanups were in a separate branch for others
to work off of.
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parents 8bc39bca f8564c93
...@@ -322,15 +322,13 @@ int con_set_trans_old(unsigned char __user * arg) ...@@ -322,15 +322,13 @@ int con_set_trans_old(unsigned char __user * arg)
{ {
int i; int i;
unsigned short inbuf[E_TABSZ]; unsigned short inbuf[E_TABSZ];
unsigned char ubuf[E_TABSZ];
if (!access_ok(VERIFY_READ, arg, E_TABSZ)) if (copy_from_user(ubuf, arg, E_TABSZ))
return -EFAULT; return -EFAULT;
for (i = 0; i < E_TABSZ ; i++) { for (i = 0; i < E_TABSZ ; i++)
unsigned char uc; inbuf[i] = UNI_DIRECT_BASE | ubuf[i];
__get_user(uc, arg+i);
inbuf[i] = UNI_DIRECT_BASE | uc;
}
console_lock(); console_lock();
memcpy(translations[USER_MAP], inbuf, sizeof(inbuf)); memcpy(translations[USER_MAP], inbuf, sizeof(inbuf));
...@@ -345,9 +343,6 @@ int con_get_trans_old(unsigned char __user * arg) ...@@ -345,9 +343,6 @@ int con_get_trans_old(unsigned char __user * arg)
unsigned short *p = translations[USER_MAP]; unsigned short *p = translations[USER_MAP];
unsigned char outbuf[E_TABSZ]; unsigned char outbuf[E_TABSZ];
if (!access_ok(VERIFY_WRITE, arg, E_TABSZ))
return -EFAULT;
console_lock(); console_lock();
for (i = 0; i < E_TABSZ ; i++) for (i = 0; i < E_TABSZ ; i++)
{ {
...@@ -356,22 +351,16 @@ int con_get_trans_old(unsigned char __user * arg) ...@@ -356,22 +351,16 @@ int con_get_trans_old(unsigned char __user * arg)
} }
console_unlock(); console_unlock();
for (i = 0; i < E_TABSZ ; i++) return copy_to_user(arg, outbuf, sizeof(outbuf)) ? -EFAULT : 0;
__put_user(outbuf[i], arg+i);
return 0;
} }
int con_set_trans_new(ushort __user * arg) int con_set_trans_new(ushort __user * arg)
{ {
int i;
unsigned short inbuf[E_TABSZ]; unsigned short inbuf[E_TABSZ];
if (!access_ok(VERIFY_READ, arg, E_TABSZ*sizeof(unsigned short))) if (copy_from_user(inbuf, arg, sizeof(inbuf)))
return -EFAULT; return -EFAULT;
for (i = 0; i < E_TABSZ ; i++)
__get_user(inbuf[i], arg+i);
console_lock(); console_lock();
memcpy(translations[USER_MAP], inbuf, sizeof(inbuf)); memcpy(translations[USER_MAP], inbuf, sizeof(inbuf));
update_user_maps(); update_user_maps();
...@@ -381,19 +370,13 @@ int con_set_trans_new(ushort __user * arg) ...@@ -381,19 +370,13 @@ int con_set_trans_new(ushort __user * arg)
int con_get_trans_new(ushort __user * arg) int con_get_trans_new(ushort __user * arg)
{ {
int i;
unsigned short outbuf[E_TABSZ]; unsigned short outbuf[E_TABSZ];
if (!access_ok(VERIFY_WRITE, arg, E_TABSZ*sizeof(unsigned short)))
return -EFAULT;
console_lock(); console_lock();
memcpy(outbuf, translations[USER_MAP], sizeof(outbuf)); memcpy(outbuf, translations[USER_MAP], sizeof(outbuf));
console_unlock(); console_unlock();
for (i = 0; i < E_TABSZ ; i++) return copy_to_user(arg, outbuf, sizeof(outbuf)) ? -EFAULT : 0;
__put_user(outbuf[i], arg+i);
return 0;
} }
/* /*
...@@ -557,14 +540,9 @@ int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list) ...@@ -557,14 +540,9 @@ int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list)
if (!ct) if (!ct)
return 0; return 0;
unilist = kmalloc_array(ct, sizeof(struct unipair), GFP_KERNEL); unilist = memdup_user(list, ct * sizeof(struct unipair));
if (!unilist) if (IS_ERR(unilist))
return -ENOMEM; return PTR_ERR(unilist);
for (i = ct, plist = unilist; i; i--, plist++, list++) {
__get_user(plist->unicode, &list->unicode);
__get_user(plist->fontpos, &list->fontpos);
}
console_lock(); console_lock();
...@@ -757,11 +735,11 @@ EXPORT_SYMBOL(con_copy_unimap); ...@@ -757,11 +735,11 @@ EXPORT_SYMBOL(con_copy_unimap);
*/ */
int con_get_unimap(struct vc_data *vc, ushort ct, ushort __user *uct, struct unipair __user *list) int con_get_unimap(struct vc_data *vc, ushort ct, ushort __user *uct, struct unipair __user *list)
{ {
int i, j, k; int i, j, k, ret = 0;
ushort ect; ushort ect;
u16 **p1, *p2; u16 **p1, *p2;
struct uni_pagedir *p; struct uni_pagedir *p;
struct unipair *unilist, *plist; struct unipair *unilist;
unilist = kmalloc_array(ct, sizeof(struct unipair), GFP_KERNEL); unilist = kmalloc_array(ct, sizeof(struct unipair), GFP_KERNEL);
if (!unilist) if (!unilist)
...@@ -792,13 +770,11 @@ int con_get_unimap(struct vc_data *vc, ushort ct, ushort __user *uct, struct uni ...@@ -792,13 +770,11 @@ int con_get_unimap(struct vc_data *vc, ushort ct, ushort __user *uct, struct uni
} }
} }
console_unlock(); console_unlock();
for (i = min(ect, ct), plist = unilist; i; i--, list++, plist++) { if (copy_to_user(list, unilist, min(ect, ct) * sizeof(struct unipair)))
__put_user(plist->unicode, &list->unicode); ret = -EFAULT;
__put_user(plist->fontpos, &list->fontpos); put_user(ect, uct);
}
__put_user(ect, uct);
kfree(unilist); kfree(unilist);
return ((ect <= ct) ? 0 : -ENOMEM); return ret ? ret : (ect <= ct) ? 0 : -ENOMEM;
} }
/* /*
......
...@@ -2709,13 +2709,13 @@ int tioclinux(struct tty_struct *tty, unsigned long arg) ...@@ -2709,13 +2709,13 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
* related to the kernel should not use this. * related to the kernel should not use this.
*/ */
data = vt_get_shift_state(); data = vt_get_shift_state();
ret = __put_user(data, p); ret = put_user(data, p);
break; break;
case TIOCL_GETMOUSEREPORTING: case TIOCL_GETMOUSEREPORTING:
console_lock(); /* May be overkill */ console_lock(); /* May be overkill */
data = mouse_reporting(); data = mouse_reporting();
console_unlock(); console_unlock();
ret = __put_user(data, p); ret = put_user(data, p);
break; break;
case TIOCL_SETVESABLANK: case TIOCL_SETVESABLANK:
console_lock(); console_lock();
...@@ -2724,7 +2724,7 @@ int tioclinux(struct tty_struct *tty, unsigned long arg) ...@@ -2724,7 +2724,7 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
break; break;
case TIOCL_GETKMSGREDIRECT: case TIOCL_GETKMSGREDIRECT:
data = vt_get_kmsg_redirect(); data = vt_get_kmsg_redirect();
ret = __put_user(data, p); ret = put_user(data, p);
break; break;
case TIOCL_SETKMSGREDIRECT: case TIOCL_SETKMSGREDIRECT:
if (!capable(CAP_SYS_ADMIN)) { if (!capable(CAP_SYS_ADMIN)) {
......
...@@ -266,10 +266,6 @@ do_unimap_ioctl(int cmd, struct unimapdesc __user *user_ud, int perm, struct vc_ ...@@ -266,10 +266,6 @@ do_unimap_ioctl(int cmd, struct unimapdesc __user *user_ud, int perm, struct vc_
if (copy_from_user(&tmp, user_ud, sizeof tmp)) if (copy_from_user(&tmp, user_ud, sizeof tmp))
return -EFAULT; return -EFAULT;
if (tmp.entries)
if (!access_ok(VERIFY_WRITE, tmp.entries,
tmp.entry_ct*sizeof(struct unipair)))
return -EFAULT;
switch (cmd) { switch (cmd) {
case PIO_UNIMAP: case PIO_UNIMAP:
if (!perm) if (!perm)
...@@ -1170,10 +1166,6 @@ compat_unimap_ioctl(unsigned int cmd, struct compat_unimapdesc __user *user_ud, ...@@ -1170,10 +1166,6 @@ compat_unimap_ioctl(unsigned int cmd, struct compat_unimapdesc __user *user_ud,
if (copy_from_user(&tmp, user_ud, sizeof tmp)) if (copy_from_user(&tmp, user_ud, sizeof tmp))
return -EFAULT; return -EFAULT;
tmp_entries = compat_ptr(tmp.entries); tmp_entries = compat_ptr(tmp.entries);
if (tmp_entries)
if (!access_ok(VERIFY_WRITE, tmp_entries,
tmp.entry_ct*sizeof(struct unipair)))
return -EFAULT;
switch (cmd) { switch (cmd) {
case PIO_UNIMAP: case PIO_UNIMAP:
if (!perm) if (!perm)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment