aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/hci_sock.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2013-08-26 12:39:55 -0400
committerGustavo Padovan <gustavo.padovan@collabora.co.uk>2013-09-16 13:35:55 -0400
commitc1c4f9567040c5677828142f52b55422886bd62c (patch)
tree10d24a5ffcadbe0aa3bf52f19ffff7fe3d446868 /net/bluetooth/hci_sock.c
parentc2371e80b3d0d11df10579a39cdad3310c944325 (diff)
Bluetooth: Restrict ioctls to HCI raw channel sockets
The various legacy ioctls used with HCI sockets are limited to raw channel only. They are not used on the other channels and also have no meaning there. So return an error if tried to use them. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Diffstat (limited to 'net/bluetooth/hci_sock.c')
-rw-r--r--net/bluetooth/hci_sock.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index f92e913c8a03..ab570387f505 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -547,6 +547,15 @@ static int hci_sock_ioctl(struct socket *sock, unsigned int cmd,
547 547
548 BT_DBG("cmd %x arg %lx", cmd, arg); 548 BT_DBG("cmd %x arg %lx", cmd, arg);
549 549
550 lock_sock(sk);
551
552 if (hci_pi(sk)->channel != HCI_CHANNEL_RAW) {
553 err = -EBADFD;
554 goto done;
555 }
556
557 release_sock(sk);
558
550 switch (cmd) { 559 switch (cmd) {
551 case HCIGETDEVLIST: 560 case HCIGETDEVLIST:
552 return hci_get_dev_list(argp); 561 return hci_get_dev_list(argp);
@@ -591,13 +600,15 @@ static int hci_sock_ioctl(struct socket *sock, unsigned int cmd,
591 600
592 case HCIINQUIRY: 601 case HCIINQUIRY:
593 return hci_inquiry(argp); 602 return hci_inquiry(argp);
594
595 default:
596 lock_sock(sk);
597 err = hci_sock_bound_ioctl(sk, cmd, arg);
598 release_sock(sk);
599 return err;
600 } 603 }
604
605 lock_sock(sk);
606
607 err = hci_sock_bound_ioctl(sk, cmd, arg);
608
609done:
610 release_sock(sk);
611 return err;
601} 612}
602 613
603static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, 614static int hci_sock_bind(struct socket *sock, struct sockaddr *addr,