Skip to content

Commit 25c150a

Browse files
lrh2000Vudentz
authored andcommitted
bluetooth: Perform careful capability checks in hci_sock_ioctl()
Previously, capability was checked using capable(), which verified that the caller of the ioctl system call had the required capability. In addition, the result of the check would be stored in the HCI_SOCK_TRUSTED flag, making it persistent for the socket. However, malicious programs can abuse this approach by deliberately sharing an HCI socket with a privileged task. The HCI socket will be marked as trusted when the privileged task occasionally makes an ioctl call. This problem can be solved by using sk_capable() to check capability, which ensures that not only the current task but also the socket opener has the specified capability, thus reducing the risk of privilege escalation through the previously identified vulnerability. Cc: stable@vger.kernel.org Fixes: f81f5b2 ("Bluetooth: Send control open and close messages for HCI raw sockets") Signed-off-by: Ruihan Li <lrh2000@pku.edu.cn> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
1 parent 25e97f7 commit 25c150a

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

net/bluetooth/hci_sock.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,14 @@ static int hci_sock_ioctl(struct socket *sock, unsigned int cmd,
10311031
if (hci_sock_gen_cookie(sk)) {
10321032
struct sk_buff *skb;
10331033

1034-
if (capable(CAP_NET_ADMIN))
1034+
/* Perform careful checks before setting the HCI_SOCK_TRUSTED
1035+
* flag. Make sure that not only the current task but also
1036+
* the socket opener has the required capability, since
1037+
* privileged programs can be tricked into making ioctl calls
1038+
* on HCI sockets, and the socket should not be marked as
1039+
* trusted simply because the ioctl caller is privileged.
1040+
*/
1041+
if (sk_capable(sk, CAP_NET_ADMIN))
10351042
hci_sock_set_flag(sk, HCI_SOCK_TRUSTED);
10361043

10371044
/* Send event to monitor */

0 commit comments

Comments
 (0)