Skip to content
Permalink
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Lqingyu authored and davem330 committed Aug 11, 2020
1 parent 1dab587 commit 26896f0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions net/nfc/rawsock.c
Expand Up @@ -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)
Expand Down

0 comments on commit 26896f0

Please sign in to comment.