Skip to contentSkip to conversation

net/bluetooth/rfcomm/sock.c: add CAP_NET_RAW check.

PATCH New Qingyu Li 1 participant 1 message Aug 18, 2020

Subsystems (4)
lore
Share & tools
lore

Qingyu Li

author
#0 lore raw

PATCH 1/1 net/bluetooth/rfcomm/sock.c: add CAP_NET_RAW check.

When creating a raw PF_BLUETOOTH socket,
CAP_NET_RAW needs to be checked first.

---
 net/bluetooth/rfcomm/sock.c | 3 +++
 1 file changed, 3 insertions(+)
net/bluetooth/rfcomm/sock.c +3 -0
index ae6f80730561..d67d49e5aa00 100644
@@ -321,6 +321,9 @@ static int rfcomm_sock_create(struct net *net, struct socket *sock,
 	if (sock->type != SOCK_STREAM && sock->type != SOCK_RAW)
 		return -ESOCKTNOSUPPORT;
 
+	if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
+		return -EPERM;
+
 	sock->ops = &rfcomm_sock_ops;
 
 	sk = rfcomm_sock_alloc(net, sock, protocol, GFP_ATOMIC, kern);

--
2.17.1