Commit eb0e2cf6 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] Add missing put_user checks in n_tty

From: Steven Rostedt <rostedt@goodmis.org>

The n_tty driver is missing some put_user checks.
parent e7b90940
...@@ -1029,7 +1029,10 @@ static ssize_t read_chan(struct tty_struct *tty, struct file *file, ...@@ -1029,7 +1029,10 @@ static ssize_t read_chan(struct tty_struct *tty, struct file *file,
break; break;
cs = tty->link->ctrl_status; cs = tty->link->ctrl_status;
tty->link->ctrl_status = 0; tty->link->ctrl_status = 0;
put_user(cs, b++); if (put_user(cs, b++)) {
retval = -EFAULT;
break;
}
nr--; nr--;
break; break;
} }
...@@ -1068,7 +1071,10 @@ static ssize_t read_chan(struct tty_struct *tty, struct file *file, ...@@ -1068,7 +1071,10 @@ static ssize_t read_chan(struct tty_struct *tty, struct file *file,
/* Deal with packet mode. */ /* Deal with packet mode. */
if (tty->packet && b == buf) { if (tty->packet && b == buf) {
put_user(TIOCPKT_DATA, b++); if (put_user(TIOCPKT_DATA, b++)) {
retval = -EFAULT;
break;
}
nr--; nr--;
} }
...@@ -1095,12 +1101,17 @@ static ssize_t read_chan(struct tty_struct *tty, struct file *file, ...@@ -1095,12 +1101,17 @@ static ssize_t read_chan(struct tty_struct *tty, struct file *file,
spin_unlock_irqrestore(&tty->read_lock, flags); spin_unlock_irqrestore(&tty->read_lock, flags);
if (!eol || (c != __DISABLED_CHAR)) { if (!eol || (c != __DISABLED_CHAR)) {
put_user(c, b++); if (put_user(c, b++)) {
retval = -EFAULT;
break;
}
nr--; nr--;
} }
if (eol) if (eol)
break; break;
} }
if (retval)
break;
} else { } else {
int uncopied; int uncopied;
uncopied = copy_from_read_buf(tty, &b, &nr); uncopied = copy_from_read_buf(tty, &b, &nr);
...@@ -1135,7 +1146,7 @@ static ssize_t read_chan(struct tty_struct *tty, struct file *file, ...@@ -1135,7 +1146,7 @@ static ssize_t read_chan(struct tty_struct *tty, struct file *file,
current->state = TASK_RUNNING; current->state = TASK_RUNNING;
size = b - buf; size = b - buf;
if (size) { if (!retval && size) {
retval = size; retval = size;
if (nr) if (nr)
clear_bit(TTY_PUSH, &tty->flags); clear_bit(TTY_PUSH, &tty->flags);
......
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