Commit 5d56356a authored by Kulikov Vasiliy's avatar Kulikov Vasiliy Committed by Greg Kroah-Hartman

68328serial: check return value of copy_*_user() instead of access_ok()

As copy_*_user() calls access_ok() it should not be called explicitly.
Signed-off-by: default avatarKulikov Vasiliy <segooon@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 80d04f22
...@@ -869,7 +869,9 @@ static int get_serial_info(struct m68k_serial * info, ...@@ -869,7 +869,9 @@ static int get_serial_info(struct m68k_serial * info,
tmp.close_delay = info->close_delay; tmp.close_delay = info->close_delay;
tmp.closing_wait = info->closing_wait; tmp.closing_wait = info->closing_wait;
tmp.custom_divisor = info->custom_divisor; tmp.custom_divisor = info->custom_divisor;
copy_to_user(retinfo,&tmp,sizeof(*retinfo)); if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
return -EFAULT;
return 0; return 0;
} }
...@@ -882,7 +884,8 @@ static int set_serial_info(struct m68k_serial * info, ...@@ -882,7 +884,8 @@ static int set_serial_info(struct m68k_serial * info,
if (!new_info) if (!new_info)
return -EFAULT; return -EFAULT;
copy_from_user(&new_serial,new_info,sizeof(new_serial)); if (copy_from_user(&new_serial, new_info, sizeof(new_serial)))
return -EFAULT;
old_info = *info; old_info = *info;
if (!capable(CAP_SYS_ADMIN)) { if (!capable(CAP_SYS_ADMIN)) {
...@@ -943,8 +946,7 @@ static int get_lsr_info(struct m68k_serial * info, unsigned int *value) ...@@ -943,8 +946,7 @@ static int get_lsr_info(struct m68k_serial * info, unsigned int *value)
status = 0; status = 0;
#endif #endif
local_irq_restore(flags); local_irq_restore(flags);
put_user(status,value); return put_user(status, value);
return 0;
} }
/* /*
...@@ -999,27 +1001,18 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file, ...@@ -999,27 +1001,18 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file,
send_break(info, arg ? arg*(100) : 250); send_break(info, arg ? arg*(100) : 250);
return 0; return 0;
case TIOCGSERIAL: case TIOCGSERIAL:
if (access_ok(VERIFY_WRITE, (void *) arg, return get_serial_info(info,
sizeof(struct serial_struct))) (struct serial_struct *) arg);
return get_serial_info(info,
(struct serial_struct *) arg);
return -EFAULT;
case TIOCSSERIAL: case TIOCSSERIAL:
return set_serial_info(info, return set_serial_info(info,
(struct serial_struct *) arg); (struct serial_struct *) arg);
case TIOCSERGETLSR: /* Get line status register */ case TIOCSERGETLSR: /* Get line status register */
if (access_ok(VERIFY_WRITE, (void *) arg, return get_lsr_info(info, (unsigned int *) arg);
sizeof(unsigned int)))
return get_lsr_info(info, (unsigned int *) arg);
return -EFAULT;
case TIOCSERGSTRUCT: case TIOCSERGSTRUCT:
if (!access_ok(VERIFY_WRITE, (void *) arg, if (copy_to_user((struct m68k_serial *) arg,
sizeof(struct m68k_serial))) info, sizeof(struct m68k_serial)))
return -EFAULT; return -EFAULT;
copy_to_user((struct m68k_serial *) arg,
info, sizeof(struct m68k_serial));
return 0; return 0;
default: default:
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
} }
......
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