summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorOri Nimron <orinimron123@gmail.com>2019-09-20 09:35:49 +0200
committerDavid S. Miller <davem@davemloft.net>2019-09-24 16:37:18 +0200
commit3a359798b176183ef09efb7a3dc59abad1cc7104 (patch)
treea0d906192a23f75f300b533636d03bfb5b2af674 /net
parente69dbd4619e7674c1679cba49afd9dd9ac347eef (diff)
downloadlinux-stable-3a359798b176183ef09efb7a3dc59abad1cc7104.tar.gz
linux-stable-3a359798b176183ef09efb7a3dc59abad1cc7104.tar.bz2
linux-stable-3a359798b176183ef09efb7a3dc59abad1cc7104.zip
nfc: enforce CAP_NET_RAW for raw sockets
When creating a raw AF_NFC socket, CAP_NET_RAW needs to be checked first. Signed-off-by: Ori Nimron <orinimron123@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/nfc/llcp_sock.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c
index 9b8742947aff..8dfea26536c9 100644
--- a/net/nfc/llcp_sock.c
+++ b/net/nfc/llcp_sock.c
@@ -1004,10 +1004,13 @@ static int llcp_sock_create(struct net *net, struct socket *sock,
sock->type != SOCK_RAW)
return -ESOCKTNOSUPPORT;
- if (sock->type == SOCK_RAW)
+ if (sock->type == SOCK_RAW) {
+ if (!capable(CAP_NET_RAW))
+ return -EPERM;
sock->ops = &llcp_rawsock_ops;
- else
+ } else {
sock->ops = &llcp_sock_ops;
+ }
sk = nfc_llcp_sock_alloc(sock, sock->type, GFP_ATOMIC, kern);
if (sk == NULL)