Bluetooth: Introduce trusted flag for management control sockets
authorMarcel Holtmann <marcel@holtmann.org>
Sun, 15 Mar 2015 02:27:58 +0000 (19:27 -0700)
committerJohan Hedberg <johan.hedberg@intel.com>
Sun, 15 Mar 2015 07:56:00 +0000 (09:56 +0200)
Providing a global trusted flag for management control sockets provides
an easy way for identifying sockets and imposing restriction on it. For
now all management sockets are trusted since they require CAP_NET_ADMIN.

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

index b8318711135adee2119a1957cf19529f894f8043..7a24acaafeeaed3b38637b05f4c7095c7819a00c 100644 (file)
@@ -181,6 +181,7 @@ enum {
 
 /* HCI socket flags */
 enum {
+       HCI_SOCK_TRUSTED,
        HCI_MGMT_INDEX_EVENTS,
        HCI_MGMT_UNCONF_INDEX_EVENTS,
        HCI_MGMT_EXT_INDEX_EVENTS,
index 00775c4fef8333d08a62c8f8c161bbb3c65ee251..54118868b3f67cf62cce93166fc4a3ff12896261 100644 (file)
@@ -796,6 +796,11 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr,
                        goto done;
                }
 
+               /* The monitor interface is restricted to CAP_NET_RAW
+                * capabilities and with that implicitly trusted.
+                */
+               hci_sock_set_flag(sk, HCI_SOCK_TRUSTED);
+
                send_monitor_replay(sk);
 
                atomic_inc(&monitor_promisc);
@@ -817,6 +822,12 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr,
                        goto done;
                }
 
+               /* Since the access to control channels is currently
+                * restricted to CAP_NET_ADMIN capabilities, every
+                * socket is implicitly trusted.
+                */
+               hci_sock_set_flag(sk, HCI_SOCK_TRUSTED);
+
                /* At the moment the index and unconfigured index events
                 * are enabled unconditionally. Setting them on each
                 * socket when binding keeps this functionality. They