aboutsummaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorQingyu Li2020-08-10 09:51:00 +0800
committerDavid S. Miller2020-08-11 10:34:30 -0700
commit26896f01467a28651f7a536143fe5ac8449d4041 (patch)
treea981d1f145678f3671286b30e77725f90822fbfd /net
parent1dab5877e8ebb7a00fbf0e7d797c869aa37830b9 (diff)
net/nfc/rawsock.c: add CAP_NET_RAW check.
When creating a raw AF_NFC socket, CAP_NET_RAW needs to be checked first. Signed-off-by: Qingyu Li <ieatmuttonchuan@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/nfc/rawsock.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/net/nfc/rawsock.c b/net/nfc/rawsock.c
index b2061b6746ea..955c195ae14b 100644
--- a/net/nfc/rawsock.c
+++ b/net/nfc/rawsock.c
@@ -328,10 +328,13 @@ static int rawsock_create(struct net *net, struct socket *sock,
if ((sock->type != SOCK_SEQPACKET) && (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 = &rawsock_raw_ops;
- else
+ } else {
sock->ops = &rawsock_ops;
+ }
sk = sk_alloc(net, PF_NFC, GFP_ATOMIC, nfc_proto->proto, kern);
if (!sk)