diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2016-08-29 23:00:37 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2016-09-19 14:19:34 -0400 |
commit | 5a6d2cf5f18b5afbae0b1b450070bbba50f1e3e0 (patch) | |
tree | baf25e5dbf080e43db99af9b5a5399904e439b35 /net/bluetooth | |
parent | 0ef2c42f8c4e372bad16f67dc0f4b15b9be910f6 (diff) |
Bluetooth: Assign the channel early when binding HCI sockets
Assignment of the hci_pi(sk)->channel should be done early when binding
the HCI socket. This avoids confusion with the RAW channel that is used
for legacy access.
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 | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index 0deca758fd9e..ca13fac1c132 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c | |||
@@ -1045,6 +1045,7 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, | |||
1045 | atomic_inc(&hdev->promisc); | 1045 | atomic_inc(&hdev->promisc); |
1046 | } | 1046 | } |
1047 | 1047 | ||
1048 | hci_pi(sk)->channel = haddr.hci_channel; | ||
1048 | hci_pi(sk)->hdev = hdev; | 1049 | hci_pi(sk)->hdev = hdev; |
1049 | break; | 1050 | break; |
1050 | 1051 | ||
@@ -1107,9 +1108,10 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, | |||
1107 | } | 1108 | } |
1108 | } | 1109 | } |
1109 | 1110 | ||
1110 | atomic_inc(&hdev->promisc); | 1111 | hci_pi(sk)->channel = haddr.hci_channel; |
1111 | |||
1112 | hci_pi(sk)->hdev = hdev; | 1112 | hci_pi(sk)->hdev = hdev; |
1113 | |||
1114 | atomic_inc(&hdev->promisc); | ||
1113 | break; | 1115 | break; |
1114 | 1116 | ||
1115 | case HCI_CHANNEL_MONITOR: | 1117 | case HCI_CHANNEL_MONITOR: |
@@ -1123,6 +1125,8 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, | |||
1123 | goto done; | 1125 | goto done; |
1124 | } | 1126 | } |
1125 | 1127 | ||
1128 | hci_pi(sk)->channel = haddr.hci_channel; | ||
1129 | |||
1126 | /* The monitor interface is restricted to CAP_NET_RAW | 1130 | /* The monitor interface is restricted to CAP_NET_RAW |
1127 | * capabilities and with that implicitly trusted. | 1131 | * capabilities and with that implicitly trusted. |
1128 | */ | 1132 | */ |
@@ -1149,6 +1153,8 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, | |||
1149 | err = -EPERM; | 1153 | err = -EPERM; |
1150 | goto done; | 1154 | goto done; |
1151 | } | 1155 | } |
1156 | |||
1157 | hci_pi(sk)->channel = haddr.hci_channel; | ||
1152 | break; | 1158 | break; |
1153 | 1159 | ||
1154 | default: | 1160 | default: |
@@ -1170,6 +1176,8 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, | |||
1170 | if (capable(CAP_NET_ADMIN)) | 1176 | if (capable(CAP_NET_ADMIN)) |
1171 | hci_sock_set_flag(sk, HCI_SOCK_TRUSTED); | 1177 | hci_sock_set_flag(sk, HCI_SOCK_TRUSTED); |
1172 | 1178 | ||
1179 | hci_pi(sk)->channel = haddr.hci_channel; | ||
1180 | |||
1173 | /* At the moment the index and unconfigured index events | 1181 | /* At the moment the index and unconfigured index events |
1174 | * are enabled unconditionally. Setting them on each | 1182 | * are enabled unconditionally. Setting them on each |
1175 | * socket when binding keeps this functionality. They | 1183 | * socket when binding keeps this functionality. They |
@@ -1180,7 +1188,7 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, | |||
1180 | * received by untrusted users. Example for such events | 1188 | * received by untrusted users. Example for such events |
1181 | * are changes to settings, class of device, name etc. | 1189 | * are changes to settings, class of device, name etc. |
1182 | */ | 1190 | */ |
1183 | if (haddr.hci_channel == HCI_CHANNEL_CONTROL) { | 1191 | if (hci_pi(sk)->channel == HCI_CHANNEL_CONTROL) { |
1184 | struct sk_buff *skb; | 1192 | struct sk_buff *skb; |
1185 | 1193 | ||
1186 | hci_sock_gen_cookie(sk); | 1194 | hci_sock_gen_cookie(sk); |
@@ -1203,8 +1211,6 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, | |||
1203 | break; | 1211 | break; |
1204 | } | 1212 | } |
1205 | 1213 | ||
1206 | |||
1207 | hci_pi(sk)->channel = haddr.hci_channel; | ||
1208 | sk->sk_state = BT_BOUND; | 1214 | sk->sk_state = BT_BOUND; |
1209 | 1215 | ||
1210 | done: | 1216 | done: |