[PATCH] net/bluetooth/cmtp/sock.c: add CAP_NET_RAW check.

Subsystems: bluetooth subsystem, the rest

STALE2196d

2 messages, 2 authors, 2020-08-18 · open the first message on its own page

[PATCH] net/bluetooth/cmtp/sock.c: add CAP_NET_RAW check.

From: Qingyu Li <hidden>
Date: 2020-08-18 08:16:01

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

Signed-off-by: Qingyu Li <redacted>
---
 net/bluetooth/cmtp/sock.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/net/bluetooth/cmtp/sock.c b/net/bluetooth/cmtp/sock.c
index 96d49d9fae96..476ccc9bee7c 100644
--- a/net/bluetooth/cmtp/sock.c
+++ b/net/bluetooth/cmtp/sock.c
@@ -207,6 +207,9 @@ static int cmtp_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, &cmtp_proto, kern);
 	if (!sk)
 		return -ENOMEM;
--
2.17.1

Re: [PATCH] net/bluetooth/cmtp/sock.c: add CAP_NET_RAW check.

From: Jesse Brandeburg <hidden>
Date: 2020-08-18 18:30:56

On Tue, 18 Aug 2020 16:15:55 +0800
Qingyu Li [off-list ref] wrote:
When creating a raw PF_BLUETOOTH socket,
CAP_NET_RAW needs to be checked first.
Please see my previous replies.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help