Input: joydev - prevent potential read overflow in ioctl
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 17 Feb 2021 20:21:10 +0000 (12:21 -0800)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Fri, 19 Feb 2021 19:02:16 +0000 (11:02 -0800)
commit182d679b2298d62bf42bb14b12a8067b8e17b617
tree30f4dd514f60efc32de464610152f11b75e92354
parent0958351e93fa0ac142f6dd8bd844441594f30a57
Input: joydev - prevent potential read overflow in ioctl

The problem here is that "len" might be less than "joydev->nabs" so the
loops which verfy abspam[i] and keypam[] might read beyond the buffer.

Fixes: 999b874f4aa3 ("Input: joydev - validate axis/button maps before clobbering current ones")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/YCyzR8WvFRw4HWw6@mwanda
[dtor: additional check for len being even in joydev_handle_JSIOCSBTNMAP]
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/joydev.c