Skip to content

Commit

Permalink
TTY: ttyprintk, don't touch behind tty->write_buf
Browse files Browse the repository at this point in the history
commit ee8b593 upstream.

If a user provides a buffer larger than a tty->write_buf chunk and
passes '\r' at the end of the buffer, we touch an out-of-bound memory.

Add a check there to prevent this.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Samo Pogacnik <samo_pogacnik@t-2.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
  • Loading branch information
Jiri Slaby authored and sashalevin committed Apr 28, 2016
1 parent d475711 commit ea663fb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/char/ttyprintk.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static int tpk_printk(const unsigned char *buf, int count)
tmp[tpk_curr + 1] = '\0';
printk(KERN_INFO "%s%s", tpk_tag, tmp);
tpk_curr = 0;
if (buf[i + 1] == '\n')
if ((i + 1) < count && buf[i + 1] == '\n')
i++;
break;
case '\n':
Expand Down

0 comments on commit ea663fb

Please sign in to comment.