Skip to content

Commit

Permalink
nfc: enforce CAP_NET_RAW for raw sockets
Browse files Browse the repository at this point in the history
commit 3a35979 upstream.

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>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
  • Loading branch information
Ori Nimron authored and Ben Hutchings committed Nov 15, 2019
1 parent f49bd65 commit bc3d2e9
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);
if (sk == NULL)
Expand Down

0 comments on commit bc3d2e9

Please sign in to comment.