]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
Input: cyapa_gen6 - fix out-of-bounds stack access
authorArnd Bergmann <arnd@arndb.de>
Mon, 14 Dec 2020 21:37:46 +0000 (13:37 -0800)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 20 Jan 2021 13:26:16 +0000 (14:26 +0100)
commit136816bd2f82e3058fcbccedad3647d7acb42794
treef458d6cf82aa488de821cffa7b56f00c5368ac16
parent9b2356217c8922499bc0ffdf117ca64ccd91e253
Input: cyapa_gen6 - fix out-of-bounds stack access

BugLink: https://bugs.launchpad.net/bugs/1910822
commit f051ae4f6c732c231046945b36234e977f8467c6 upstream.

gcc -Warray-bounds warns about a serious bug in
cyapa_pip_retrieve_data_structure:

drivers/input/mouse/cyapa_gen6.c: In function 'cyapa_pip_retrieve_data_structure.constprop':
include/linux/unaligned/access_ok.h:40:17: warning: array subscript -1 is outside array bounds of 'struct retrieve_data_struct_cmd[1]' [-Warray-bounds]
   40 |  *((__le16 *)p) = cpu_to_le16(val);
drivers/input/mouse/cyapa_gen6.c:569:13: note: while referencing 'cmd'
  569 |  } __packed cmd;
      |             ^~~

Apparently the '-2' was added to the pointer instead of the value,
writing garbage into the stack next to this variable.

Fixes: c2c06c41f700 ("Input: cyapa - add gen6 device module support")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20201026161332.3708389-1-arnd@kernel.org
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
drivers/input/mouse/cyapa_gen6.c