platform/chrome: cros_ec_dev - double fetch bug in ioctl
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 21 Jun 2016 13:58:46 +0000 (16:58 +0300)
committerOlof Johansson <olof@lixom.net>
Tue, 5 Jul 2016 21:01:52 +0000 (14:01 -0700)
commit096cdc6f52225835ff503f987a0d68ef770bb78e
tree7e123fe975c5578ff97ad21811f9e4500210fb0c
parent33688abb2802ff3a230bd2441f765477b94cc89e
platform/chrome: cros_ec_dev - double fetch bug in ioctl

We verify "u_cmd.outsize" and "u_cmd.insize" but we need to make sure
that those values have not changed between the two copy_from_user()
calls.  Otherwise it could lead to a buffer overflow.

Additionally, cros_ec_cmd_xfer() can set s_cmd->insize to a lower value.
We should use the new smaller value so we don't copy too much data to
the user.

Reported-by: Pengfei Wang <wpengfeinudt@gmail.com>
Fixes: a841178445bb ('mfd: cros_ec: Use a zero-length array for command data')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Tested-by: Gwendal Grignou <gwendal@chromium.org>
Cc: <stable@vger.kernel.org> # v4.2+
Signed-off-by: Olof Johansson <olof@lixom.net>
drivers/platform/chrome/cros_ec_dev.c