Skip to contentSkip to conversation

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

PATCH In review Qingyu Li 2 participants 2 messages Aug 18, 2020

Subsystems (4)
lore
Share & tools
lore

Qingyu Li

author
#0 lore raw

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

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

---
 net/bluetooth/hidp/sock.c | 3 +++
 1 file changed, 3 insertions(+)
net/bluetooth/hidp/sock.c +3 -0
index 595fb3c9d6c3..3dd9c8e0419a 100644
@@ -255,6 +255,9 @@ static int hidp_sock_create(struct net *net, struct socket *sock, int protocol,
 	if (sock->type != SOCK_RAW)
 		return -ESOCKTNOSUPPORT;
 
+	if (!capable(CAP_NET_RAW))
+		return -EPERM;
+
 	sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &hidp_proto, kern);
 	if (!sk)
 		return -ENOMEM;

--
2.17.1