Skip to content

Commit

Permalink
Bluetooth: Restrict ioctls to HCI raw channel sockets
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Marcel Holtmann authored and Gustavo Padovan committed Sep 16, 2013
1 parent c2371e8 commit c1c4f95
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions net/bluetooth/hci_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,15 @@ static int hci_sock_ioctl(struct socket *sock, unsigned int cmd,

BT_DBG("cmd %x arg %lx", cmd, arg);

lock_sock(sk);

if (hci_pi(sk)->channel != HCI_CHANNEL_RAW) {
err = -EBADFD;
goto done;
}

release_sock(sk);

switch (cmd) {
case HCIGETDEVLIST:
return hci_get_dev_list(argp);
Expand Down Expand Up @@ -591,13 +600,15 @@ static int hci_sock_ioctl(struct socket *sock, unsigned int cmd,

case HCIINQUIRY:
return hci_inquiry(argp);

default:
lock_sock(sk);
err = hci_sock_bound_ioctl(sk, cmd, arg);
release_sock(sk);
return err;
}

lock_sock(sk);

err = hci_sock_bound_ioctl(sk, cmd, arg);

done:
release_sock(sk);
return err;
}

static int hci_sock_bind(struct socket *sock, struct sockaddr *addr,
Expand Down

0 comments on commit c1c4f95

Please sign in to comment.