Bluetooth: Fix buffer overflow with variable length commands
authorJohan Hedberg <johan.hedberg@intel.com>
Thu, 3 Jul 2014 10:52:27 +0000 (13:52 +0300)
committerMarcel Holtmann <marcel@holtmann.org>
Thu, 3 Jul 2014 15:42:59 +0000 (17:42 +0200)
commitba1d6936f6f83927f17a28ecc9cbb989fa0a7e34
tree7c5d003f401165f6c7eac97d2541c702dcdfd3ef
parent079446c8a254d65da0378a45c2106dbf1ff6a769
Bluetooth: Fix buffer overflow with variable length commands

The handler for variable length commands were trying to calculate the
expected length of the command based on the given parameter count, and
then comparing that with the received data. However, the expected count
was stored in a u16 which can easily overflow. With a carefully crafted
command this can then be made to match the given data even though the
parameter count is actually way too big, resulting in a buffer overflow
when parsing the parameters.

This patch fixes the issue by calculating a per-command maximum
parameter count and returns INVALID_PARAMS if it is exceeded.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
net/bluetooth/mgmt.c