Skip to content

Commit

Permalink
staging: istallion: fix arbitrary kernel memory reads/writes
Browse files Browse the repository at this point in the history
stli_brdstats is defined as global variable.  After de-BKL-ization in
the patch b4eda9c 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 <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
segoon authored and gregkh committed Apr 25, 2011
1 parent 7816c45 commit 5d46f32
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/staging/tty/istallion.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ static struct ktermios stli_deftermios = {
* re-used for each stats call.
*/
static comstats_t stli_comstats;
static combrd_t stli_brdstats;
static struct asystats stli_cdkstats;

/*****************************************************************************/
Expand Down Expand Up @@ -4005,6 +4004,7 @@ static int stli_getbrdstats(combrd_t __user *bp)
{
struct stlibrd *brdp;
unsigned int i;
combrd_t stli_brdstats;

if (copy_from_user(&stli_brdstats, bp, sizeof(combrd_t)))
return -EFAULT;
Expand Down

0 comments on commit 5d46f32

Please sign in to comment.