Skip to contentSkip to conversation

net/bluetooth/hci_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/hci_sock.c: add CAP_NET_RAW check.

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

---
 net/bluetooth/hci_sock.c | 3 +++
 1 file changed, 3 insertions(+)
net/bluetooth/hci_sock.c +3 -0
index 251b9128f530..c0919e209f05 100644
@@ -2034,6 +2034,9 @@ static int hci_sock_create(struct net *net, struct socket *sock, int protocol,
 	if (sock->type != SOCK_RAW)
 		return -ESOCKTNOSUPPORT;
 
+	if (!capable(CAP_NET_RAW))
+		return -EPERM;
+
 	sock->ops = &hci_sock_ops;
 
 	sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &hci_sk_proto, kern);

--
2.17.1

#1 lore raw
Quoted 3 lines · On Tue, 18 Aug 2020 15:56:48 +0800 Qingyu Li <[email protected]> wrote:

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

Thanks for the patch! Your subject doesn't need to end in a period. In your commit message, I can guess why you'd want this patch, but your commit message should include more info about why the kernel wants this patch included. Especially since this is a user visible change and likely a fix of a bug. Please review:
https://www.kernel.org/doc/html/latest/networking/netdev-FAQ.html
specifically:
https://www.kernel.org/doc/html/latest/networking/netdev-FAQ.html#q-any-other-tips-to-help-ensure-my-net-net-next-patch-gets-ok-d

This looks like a fix, please add a Fixes tag.