Input: zforce - don't overwrite the stack
authorOleksij Rempel <external.Oleksij.Rempel@de.bosch.com>
Mon, 13 Jul 2015 16:54:42 +0000 (09:54 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Thu, 16 Jul 2015 17:47:30 +0000 (10:47 -0700)
If we get a corrupted packet with PAYLOAD_LENGTH > FRAME_MAXSIZE, we
will silently overwrite the stack.

Cc: stable@vger.kernel.org
Signed-off-by: Oleksij Rempel <external.Oleksij.Rempel@de.bosch.com>
Signed-off-by: Dirk Behme <dirk.behme@de.bosch.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/touchscreen/zforce_ts.c

index f58a196521a9a99fc3d4838b86db7aba4b7aca02..80285c71786ee58a85d268adb20ad283a1fd54a9 100644 (file)
@@ -429,7 +429,7 @@ static int zforce_read_packet(struct zforce_ts *ts, u8 *buf)
                goto unlock;
        }
 
-       if (buf[PAYLOAD_LENGTH] == 0) {
+       if (buf[PAYLOAD_LENGTH] == 0 || buf[PAYLOAD_LENGTH] > FRAME_MAXSIZE) {
                dev_err(&client->dev, "invalid payload length: %d\n",
                        buf[PAYLOAD_LENGTH]);
                ret = -EIO;