Skip to content

Commit

Permalink
nfc: enforce CAP_NET_RAW for raw sockets
Browse files Browse the repository at this point in the history
When creating a raw AF_NFC socket, CAP_NET_RAW needs to be checked
first.

Signed-off-by: Ori Nimron <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Armondile authored and davem330 committed Sep 24, 2019
1 parent e69dbd4 commit 3a35979
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions net/nfc/llcp_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3a35979

Please sign in to comment.