diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2015-03-14 22:28:05 -0400 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2015-03-15 03:59:39 -0400 |
commit | f6b7712eb660c50877a56772908326cd31125b21 (patch) | |
tree | 5e5cc33537fc9922f8b8047c96b0295d4322503a /net/bluetooth | |
parent | 1195fbb8d03e5a6d7e7e49a73592caeb113a0f70 (diff) |
Bluetooth: Send global configuration updates to all management users
Changes to the global configuration updates like settings, class of
device, name etc. can be received by every user. They are allowed to
read them in the first place so provide the updates via events as
well. Otherwise untrusted users start polling for updates and that
is not a desired behavior.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/hci_sock.c | 5 | ||||
-rw-r--r-- | net/bluetooth/mgmt.c | 34 |
2 files changed, 25 insertions, 14 deletions
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index f4b10344b1e5..7c719602dbca 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c | |||
@@ -808,10 +808,15 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, | |||
808 | * socket when binding keeps this functionality. They | 808 | * socket when binding keeps this functionality. They |
809 | * however might be cleared later and then sending of these | 809 | * however might be cleared later and then sending of these |
810 | * events will be disabled, but that is then intentional. | 810 | * events will be disabled, but that is then intentional. |
811 | * | ||
812 | * This also enables generic events that are safe to be | ||
813 | * received by untrusted users. Example for such events | ||
814 | * are changes to settings, class of device, name etc. | ||
811 | */ | 815 | */ |
812 | if (haddr.hci_channel == HCI_CHANNEL_CONTROL) { | 816 | if (haddr.hci_channel == HCI_CHANNEL_CONTROL) { |
813 | hci_sock_set_flag(sk, HCI_MGMT_INDEX_EVENTS); | 817 | hci_sock_set_flag(sk, HCI_MGMT_INDEX_EVENTS); |
814 | hci_sock_set_flag(sk, HCI_MGMT_UNCONF_INDEX_EVENTS); | 818 | hci_sock_set_flag(sk, HCI_MGMT_UNCONF_INDEX_EVENTS); |
819 | hci_sock_set_flag(sk, HCI_MGMT_GENERIC_EVENTS); | ||
815 | } | 820 | } |
816 | break; | 821 | break; |
817 | } | 822 | } |
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 920acf0625f6..fa5654d89702 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -260,6 +260,13 @@ static int mgmt_index_event(u16 event, struct hci_dev *hdev, void *data, | |||
260 | flag, NULL); | 260 | flag, NULL); |
261 | } | 261 | } |
262 | 262 | ||
263 | static int mgmt_generic_event(u16 event, struct hci_dev *hdev, void *data, | ||
264 | u16 len, struct sock *skip_sk) | ||
265 | { | ||
266 | return mgmt_send_event(event, hdev, HCI_CHANNEL_CONTROL, data, len, | ||
267 | HCI_MGMT_GENERIC_EVENTS, skip_sk); | ||
268 | } | ||
269 | |||
263 | static int mgmt_event(u16 event, struct hci_dev *hdev, void *data, u16 len, | 270 | static int mgmt_event(u16 event, struct hci_dev *hdev, void *data, u16 len, |
264 | struct sock *skip_sk) | 271 | struct sock *skip_sk) |
265 | { | 272 | { |
@@ -607,8 +614,8 @@ static int new_options(struct hci_dev *hdev, struct sock *skip) | |||
607 | { | 614 | { |
608 | __le32 options = get_missing_options(hdev); | 615 | __le32 options = get_missing_options(hdev); |
609 | 616 | ||
610 | return mgmt_event(MGMT_EV_NEW_CONFIG_OPTIONS, hdev, &options, | 617 | return mgmt_generic_event(MGMT_EV_NEW_CONFIG_OPTIONS, hdev, &options, |
611 | sizeof(options), skip); | 618 | sizeof(options), skip); |
612 | } | 619 | } |
613 | 620 | ||
614 | static int send_options_rsp(struct sock *sk, u16 opcode, struct hci_dev *hdev) | 621 | static int send_options_rsp(struct sock *sk, u16 opcode, struct hci_dev *hdev) |
@@ -1552,11 +1559,10 @@ failed: | |||
1552 | 1559 | ||
1553 | static int new_settings(struct hci_dev *hdev, struct sock *skip) | 1560 | static int new_settings(struct hci_dev *hdev, struct sock *skip) |
1554 | { | 1561 | { |
1555 | __le32 ev; | 1562 | __le32 ev = cpu_to_le32(get_current_settings(hdev)); |
1556 | |||
1557 | ev = cpu_to_le32(get_current_settings(hdev)); | ||
1558 | 1563 | ||
1559 | return mgmt_event(MGMT_EV_NEW_SETTINGS, hdev, &ev, sizeof(ev), skip); | 1564 | return mgmt_generic_event(MGMT_EV_NEW_SETTINGS, hdev, &ev, |
1565 | sizeof(ev), skip); | ||
1560 | } | 1566 | } |
1561 | 1567 | ||
1562 | int mgmt_new_settings(struct hci_dev *hdev) | 1568 | int mgmt_new_settings(struct hci_dev *hdev) |
@@ -3677,8 +3683,8 @@ static int set_local_name(struct sock *sk, struct hci_dev *hdev, void *data, | |||
3677 | if (err < 0) | 3683 | if (err < 0) |
3678 | goto failed; | 3684 | goto failed; |
3679 | 3685 | ||
3680 | err = mgmt_event(MGMT_EV_LOCAL_NAME_CHANGED, hdev, data, len, | 3686 | err = mgmt_generic_event(MGMT_EV_LOCAL_NAME_CHANGED, hdev, |
3681 | sk); | 3687 | data, len, sk); |
3682 | 3688 | ||
3683 | goto failed; | 3689 | goto failed; |
3684 | } | 3690 | } |
@@ -6673,8 +6679,8 @@ int mgmt_powered(struct hci_dev *hdev, u8 powered) | |||
6673 | mgmt_pending_foreach(0, hdev, cmd_complete_rsp, &status); | 6679 | mgmt_pending_foreach(0, hdev, cmd_complete_rsp, &status); |
6674 | 6680 | ||
6675 | if (memcmp(hdev->dev_class, zero_cod, sizeof(zero_cod)) != 0) | 6681 | if (memcmp(hdev->dev_class, zero_cod, sizeof(zero_cod)) != 0) |
6676 | mgmt_event(MGMT_EV_CLASS_OF_DEV_CHANGED, hdev, | 6682 | mgmt_generic_event(MGMT_EV_CLASS_OF_DEV_CHANGED, hdev, |
6677 | zero_cod, sizeof(zero_cod), NULL); | 6683 | zero_cod, sizeof(zero_cod), NULL); |
6678 | 6684 | ||
6679 | new_settings: | 6685 | new_settings: |
6680 | err = new_settings(hdev, match.sk); | 6686 | err = new_settings(hdev, match.sk); |
@@ -7325,8 +7331,8 @@ void mgmt_set_class_of_dev_complete(struct hci_dev *hdev, u8 *dev_class, | |||
7325 | mgmt_pending_foreach(MGMT_OP_REMOVE_UUID, hdev, sk_lookup, &match); | 7331 | mgmt_pending_foreach(MGMT_OP_REMOVE_UUID, hdev, sk_lookup, &match); |
7326 | 7332 | ||
7327 | if (!status) | 7333 | if (!status) |
7328 | mgmt_event(MGMT_EV_CLASS_OF_DEV_CHANGED, hdev, dev_class, 3, | 7334 | mgmt_generic_event(MGMT_EV_CLASS_OF_DEV_CHANGED, hdev, |
7329 | NULL); | 7335 | dev_class, 3, NULL); |
7330 | 7336 | ||
7331 | if (match.sk) | 7337 | if (match.sk) |
7332 | sock_put(match.sk); | 7338 | sock_put(match.sk); |
@@ -7355,8 +7361,8 @@ void mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status) | |||
7355 | return; | 7361 | return; |
7356 | } | 7362 | } |
7357 | 7363 | ||
7358 | mgmt_event(MGMT_EV_LOCAL_NAME_CHANGED, hdev, &ev, sizeof(ev), | 7364 | mgmt_generic_event(MGMT_EV_LOCAL_NAME_CHANGED, hdev, &ev, sizeof(ev), |
7359 | cmd ? cmd->sk : NULL); | 7365 | cmd ? cmd->sk : NULL); |
7360 | } | 7366 | } |
7361 | 7367 | ||
7362 | void mgmt_read_local_oob_data_complete(struct hci_dev *hdev, u8 *hash192, | 7368 | void mgmt_read_local_oob_data_complete(struct hci_dev *hdev, u8 *hash192, |