Re: [PATCH] HID: Bluetooth: hidp: buffer overflow in hidp_process_report

From: Kees Cook
Date: Tue Jul 31 2018 - 19:41:40 EST


On Tue, Jul 31, 2018 at 3:02 PM, Mark Salyzyn <salyzyn@xxxxxxxxxxx> wrote:
> CVE-2018-9363
>
> The buffer length is unsigned at all layers, but gets cast to int and
> checked in hidp_process_report and can lead to a buffer overflow.
> Switch len parameter to unsigned int to resolve issue.
>
> This affects 3.18 and newer kernels.
>
> Signed-off-by: Mark Salyzyn <salyzyn@xxxxxxxxxxx>
> Fixes: a4b1b5877b514b276f0f31efe02388a9c2836728 ("HID: Bluetooth: hidp: make sure input buffers are big enough")

nit: normally just first 12 of the sha is used.

> Cc: Marcel Holtmann <marcel@xxxxxxxxxxxx>
> Cc: Johan Hedberg <johan.hedberg@xxxxxxxxx>
> Cc: "David S. Miller" <davem@xxxxxxxxxxxxx>
> Cc: Kees Cook <keescook@xxxxxxxxxxxx>
> Cc: Benjamin Tissoires <benjamin.tissoires@xxxxxxxxxx>
> Cc: linux-bluetooth@xxxxxxxxxxxxxxx
> Cc: netdev@xxxxxxxxxxxxxxx
> Cc: linux-kernel@xxxxxxxxxxxxxxx
> Cc: security@xxxxxxxxxx
> Cc: kernel-team@xxxxxxxxxxx
> ---
> net/bluetooth/hidp/core.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
> index 1036e4fa1ea2..3bba8f4b08a9 100644
> --- a/net/bluetooth/hidp/core.c
> +++ b/net/bluetooth/hidp/core.c
> @@ -431,8 +431,8 @@ static void hidp_del_timer(struct hidp_session *session)
> del_timer(&session->timer);
> }
>
> -static void hidp_process_report(struct hidp_session *session,
> - int type, const u8 *data, int len, int intr)
> +static void hidp_process_report(struct hidp_session *session, int type,
> + const u8 *data, unsigned int len, int intr)
> {
> if (len > HID_MAX_BUFFER_SIZE)
> len = HID_MAX_BUFFER_SIZE;

Acked-by: Kees Cook <keescook@xxxxxxxxxxxx>

Thanks!

-Kees

--
Kees Cook
Pixel Security