Skip to contentSkip to conversation

Allow BT_SECURITY for L2CAP raw sockets

PATCH In review Johan Hedberg 2 participants 2 messages Feb 20, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Allow BT_SECURITY for L2CAP raw sockets

Hi Marcel,

Here's the patch to permit BT_SECURITY for L2CAP raw sockets. It allows our BtIO code to be simpler since there's no need to do special L2CAP_LM tricks when doing paring using L2CAP raw sockets. It seemed to work fine in my tests (both SSP and legacy pairing) so if it's ok with you I'll also push the corresponding patch for bluetoothd (which without this patch would cause EINVAL when trying pairing on a newer kernel).

Johan

Quoted 1 line

From a6f7321f607712eafde755726d07ccf1a1fcdfab Mon Sep 17 00:00:00 2001

From: Johan Hedberg <[email protected]>
Date: Fri, 20 Feb 2009 14:56:00 +0200
Subject: [PATCH] Bluetooth: Permit BT_SECURITY also for L2CAP raw sockets

Userspace pairing code can be simplified if it doesn't have to fall back to using L2CAP_LM in the case of L2CAP raw sockets. This patch allows the BT_SECURITY socket option to be used for all types of L2CAP sockets.

---
 net/bluetooth/l2cap.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)
net/bluetooth/l2cap.c +0 -5
index 7c6768c..b935cf0 100644
@@ -1308,11 +1308,6 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch
 
 	switch (optname) {
 	case BT_SECURITY:
-		if (sk->sk_type != SOCK_SEQPACKET) {
-			err = -EINVAL;
-			break;
-		}
-
 		sec.level = BT_SECURITY_LOW;
 
 		len = min_t(unsigned int, sizeof(sec), optlen);
Signature · 1 line
1.5.6.3
maintainer
#1 lore raw

Hi Johan,

Quoted 6 lines

Here's the patch to permit BT_SECURITY for L2CAP raw sockets. It allows our BtIO code to be simpler since there's no need to do special L2CAP_LM tricks when doing paring using L2CAP raw sockets. It seemed to work fine in my tests (both SSP and legacy pairing) so if it's ok with you I'll also push the corresponding patch for bluetoothd (which without this patch would cause EINVAL when trying pairing on a newer kernel).

I pushed a little bit different version of the patch that only explicitly allows SOCK_SEQPACKET and SOCK_RAW. In addition I did the same for the getsockopt() case :)

Regards

Marcel