linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net/bluetooth/rfcomm/sock.c: add CAP_NET_RAW check.
@ 2020-08-18  8:33 Qingyu Li
  0 siblings, 0 replies; only message in thread
From: Qingyu Li @ 2020-08-18  8:33 UTC (permalink / raw)
  To: marcel, johan.hedberg, davem, kuba, matthieu.baerts, stefan,
	arnd, gustavoars, bigeasy
  Cc: linux-bluetooth, netdev, linux-kernel

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

Signed-off-by: Qingyu Li <ieatmuttonchuan@gmail.com>
---
 net/bluetooth/rfcomm/sock.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
index ae6f80730561..d67d49e5aa00 100644
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
@@ -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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-08-18  8:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-18  8:33 [PATCH] net/bluetooth/rfcomm/sock.c: add CAP_NET_RAW check Qingyu Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).