Skip to content

Commit 26896f0

Browse files
Lqingyudavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1dab587 commit 26896f0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

net/nfc/rawsock.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,13 @@ static int rawsock_create(struct net *net, struct socket *sock,
328328
if ((sock->type != SOCK_SEQPACKET) && (sock->type != SOCK_RAW))
329329
return -ESOCKTNOSUPPORT;
330330

331-
if (sock->type == SOCK_RAW)
331+
if (sock->type == SOCK_RAW) {
332+
if (!capable(CAP_NET_RAW))
333+
return -EPERM;
332334
sock->ops = &rawsock_raw_ops;
333-
else
335+
} else {
334336
sock->ops = &rawsock_ops;
337+
}
335338

336339
sk = sk_alloc(net, PF_NFC, GFP_ATOMIC, nfc_proto->proto, kern);
337340
if (!sk)

0 commit comments

Comments
 (0)