From: Qingyu Li <ieatmuttonchuan@gmail•com>
To: marcel@holtmann•org, johan.hedberg@gmail•com,
davem@davemloft•net, kuba@kernel•org,
matthieu.baerts@tessares•net, stefan@datenfreihafen•org,
arnd@arndb•de, gustavoars@kernel•org, bigeasy@linutronix•de
Cc: linux-bluetooth@vger•kernel.org, netdev@vger•kernel.org,
linux-kernel@vger•kernel.org
Subject: [PATCH] net/bluetooth/rfcomm/sock.c: add CAP_NET_RAW check.
Date: Tue, 18 Aug 2020 16:33:57 +0800 [thread overview]
Message-ID: <20200818083357.GA5442@oppo> (raw)
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
reply other threads:[~2020-08-18 8:34 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200818083357.GA5442@oppo \
--to=ieatmuttonchuan@gmail$(echo .)com \
--cc=arnd@arndb$(echo .)de \
--cc=bigeasy@linutronix$(echo .)de \
--cc=davem@davemloft$(echo .)net \
--cc=gustavoars@kernel$(echo .)org \
--cc=johan.hedberg@gmail$(echo .)com \
--cc=kuba@kernel$(echo .)org \
--cc=linux-bluetooth@vger$(echo .)kernel.org \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=marcel@holtmann$(echo .)org \
--cc=matthieu.baerts@tessares$(echo .)net \
--cc=netdev@vger$(echo .)kernel.org \
--cc=stefan@datenfreihafen$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox