Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c1c4f956 authored by Marcel Holtmann's avatar Marcel Holtmann Committed by Gustavo Padovan
Browse files

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: default avatarMarcel Holtmann <marcel@holtmann.org>
Signed-off-by: default avatarGustavo Padovan <gustavo.padovan@collabora.co.uk>
parent c2371e80
Loading
Loading
Loading
Loading
+17 −6
Original line number Diff line number Diff line
@@ -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);
@@ -591,14 +600,16 @@ 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);

done:
	release_sock(sk);
	return err;
}
}

static int hci_sock_bind(struct socket *sock, struct sockaddr *addr,
			 int addr_len)