Input: add safety guards to input_set_keycode() android-10-release-qsbs MMI-QSBS30.62-17-12
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Fri, 13 Dec 2019 22:56:16 +0000 (14:56 -0800)
committerchenyt9 <chenyt9@lenovo.com>
Tue, 17 Nov 2020 08:37:28 +0000 (16:37 +0800)
commit6b0fec069ec00731caa5448ca0d3e7db95702dbd
treee6e275fbaa06dfb55d233cf60731f29f2704ecda
parent35c3ed17afd7da15ee288e9d2619c49062d12c8d
Input: add safety guards to input_set_keycode()

commit cb222aed03d798fc074be55e59d9a112338ee784 upstream.

If we happen to have a garbage in input device's keycode table with values
too big we'll end up doing clear_bit() with offset way outside of our
bitmaps, damaging other objects within an input device or even outside of
it. Let's add sanity checks to the returned old keycodes.

Mot-CRs-fixed: IKSIMP-31849
CVE-Fixed: CVE-2019-20636
Bug: 153715664

Reported-by: syzbot+c769968809f9359b07aa@syzkaller.appspotmail.com
Reported-by: syzbot+76f3a30e88d256644c78@syzkaller.appspotmail.com
Link: https://lore.kernel.org/r/20191207212757.GA245964@dtor-ws
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Jignesh Patel <jignesh@motorola.com>
Change-Id: I819da9e84f4e91140514e22fd6d4afc43359a3d2
Reviewed-on: https://gerrit.mot.com/1604271
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Xiangpo Zhao <zhaoxp3@motorola.com>
Submit-Approved: Jira Key
(cherry picked from commit a5aaf589dabb64175e48d82cbcf624cdb0564934)
drivers/input/input.c