summaryrefslogtreecommitdiff
path: root/drivers/char/hvc_rtas.c
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2010-11-08 19:01:47 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2010-12-09 13:26:46 -0800
commit8dded7dc4c71fd206ffa2b7725a1c74544104009 (patch)
treedf814cafe44868db4cba08559c866de93cd4136b /drivers/char/hvc_rtas.c
parent814a341523e6715b36074cf2a0afc7833384fe9e (diff)
tty: prevent DOS in the flush_to_ldisc
commit e045fec48970df84647a47930fcf7a22ff7229c0 upstream. There's a small window inside the flush_to_ldisc function, where the tty is unlocked and calling ldisc's receive_buf function. If in this window new buffer is added to the tty, the processing might never leave the flush_to_ldisc function. This scenario will hog the cpu, causing other tty processing starving, and making it impossible to interface the computer via tty. I was able to exploit this via pty interface by sending only control characters to the master input, causing the flush_to_ldisc to be scheduled, but never actually generate any output. To reproduce, please run multiple instances of following code. - SNIP #define _XOPEN_SOURCE #include <stdlib.h> #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> int main(int argc, char **argv) { int i, slave, master = getpt(); char buf[8192]; sprintf(buf, "%s", ptsname(master)); grantpt(master); unlockpt(master); slave = open(buf, O_RDWR); if (slave < 0) { perror("open slave failed"); return 1; } for(i = 0; i < sizeof(buf); i++) buf[i] = rand() % 32; while(1) { write(master, buf, sizeof(buf)); } return 0; } - SNIP The attached patch (based on -next tree) fixes this by checking on the tty buffer tail. Once it's reached, the current work is rescheduled and another could run. Signed-off-by: Jiri Olsa <jolsa@redhat.com> Acked-by: Alan Cox <alan@lxorguk.ukuu.org.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/char/hvc_rtas.c')
0 files changed, 0 insertions, 0 deletions