staging: istallion: fix arbitrary kernel memory reads/writes
authorVasiliy Kulikov <segoon@openwall.com>
Thu, 14 Apr 2011 15:56:25 +0000 (19:56 +0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 25 Apr 2011 23:45:22 +0000 (16:45 -0700)
commit5d46f3266728913d05106ee82fb5f043be06eb21
treefe5fdcc013d3b0b7f648eec6bfdd49360cdf3531
parent7816c45bf13255157c00fb8aca86cb64d825e878
staging: istallion: fix arbitrary kernel memory reads/writes

stli_brdstats is defined as global variable.  After de-BKL-ization in
the patch b4eda9cb48eac1b7 an access to the variable is not serialized
anymore.  This leads to the race window between the check and the use
in stli_getbrdstats():

        if (copy_from_user(&stli_brdstats, bp, sizeof(combrd_t)))
                return -EFAULT;
        if (stli_brdstats.brd >= STL_MAXBRDS) <<<
                return -ENODEV;
        brdp = stli_brds[stli_brdstats.brd];  <<<

If one process calls COM_GETBRDSTATS ioctl() with sane .brd, second
process calls COM_GETBRDSTATS ioctl() with invalid .brd, and the
second process' copy_from_user() executes exactly between the check and
stli_brds[] indexation of the first process, then the first process gets
contents of memory at *stli_brds[stli_brdstats.brd] address.  Also
the resulting .nrpanels field may be too big, in this case
stli_brdstats.panels array overflows.

Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/tty/istallion.c