Skip to contentSkip to conversation

Bluetooth: Limit HCI raw socket options to actual raw sockets

PATCH In review Marcel Holtmann 1 participant 1 message Feb 20, 2012

Subsystems (2)
lore
Share & tools
lore

Marcel Holtmann

author maintainer
#0 lore raw

PATCH 4/8 Bluetooth: Limit HCI raw socket options to actual raw sockets

Currently the socket options of HCI sockets can be set on raw and control sockets, but on control sockets they make no sense. So just return EINVAL in that case.

---
 net/bluetooth/hci_sock.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
net/bluetooth/hci_sock.c +6 -0
index d3381f9..3d86aa6 100644
@@ -601,6 +601,11 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname, char
 
 	lock_sock(sk);
 
+	if (hci_pi(sk)->channel != HCI_CHANNEL_RAW) {
+		err = -EINVAL;
+		goto done;
+	}
+
 	switch (optname) {
 	case HCI_DATA_DIR:
 		if (get_user(opt, (int __user *)optval)) {
@@ -663,6 +668,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname, char
 		break;
 	}
 
+done:
 	release_sock(sk);
 	return err;
 }
Signature · 1 line
1.7.7.6