From: Johan Hedberg Date: Wed, 9 Jan 2013 13:29:35 +0000 (+0200) Subject: Bluetooth: Fix checking for valid device class values X-Git-Tag: accepted/tizen/common/20141203.182822~2684^2~28^2^2~62^2~49^2~24 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=575b3a02e20a10bb8110378ef363a8a174018680;p=platform%2Fkernel%2Flinux-arm64.git Bluetooth: Fix checking for valid device class values The two lowest bits of the minor device class value are reserved and should be zero, and the three highest bits of the major device class likewise. The management code should therefore test for this and return a proper "invalid params" error if the condition is not met. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann Signed-off-by: Gustavo Padovan --- diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 1dd41d4..f3fec42 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1430,6 +1430,12 @@ static int set_dev_class(struct sock *sk, struct hci_dev *hdev, void *data, goto unlock; } + if ((cp->minor & 0x03) != 0 || (cp->major & 0xe0) != 0) { + err = cmd_status(sk, hdev->id, MGMT_OP_SET_DEV_CLASS, + MGMT_STATUS_INVALID_PARAMS); + goto unlock; + } + hdev->major_class = cp->major; hdev->minor_class = cp->minor;