[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20200818083357.GA5442@oppo>
Date: Tue, 18 Aug 2020 16:33:57 +0800
From: Qingyu Li <ieatmuttonchuan@...il.com>
To: marcel@...tmann.org, johan.hedberg@...il.com, davem@...emloft.net,
kuba@...nel.org, matthieu.baerts@...sares.net,
stefan@...enfreihafen.org, arnd@...db.de, gustavoars@...nel.org,
bigeasy@...utronix.de
Cc: linux-bluetooth@...r.kernel.org, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] 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.
Signed-off-by: Qingyu Li <ieatmuttonchuan@...il.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
Powered by blists - more mailing lists