nfc: enforce CAP_NET_RAW for raw sockets When creating a raw AF_NFC socket, CAP_NET_RAW needs to be checked first.
Subsystems (3)
PATCH 1/1 nfc: enforce CAP_NET_RAW for raw sockets When creating a raw AF_NFC socket, CAP_NET_RAW needs to be checked first.
Signed-off-by Qingyu Li <[email protected]>
--- net/nfc/rawsock.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/nfc/rawsock.c +4 -1
@@ -332,8 +332,11 @@ 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 sock->ops = &rawsock_ops;
Jakub Kicinski
maintainerOn Thu, 6 Aug 2020 10:28:08 +0800 Qingyu Li wrote:
Commit message is required. Perhaps shorten the subject and put more info here.
Quoted 10 lines
Signed-off-by Qingyu Li <[email protected]>--- net/nfc/rawsock.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)net/nfc/rawsock.c +0
-0
net/nfc/rawsock.c static int rawsock_create(struct net *net, struct socket *sock, · line 339
Quoted 9 lines
net/nfc/rawsock.c +4
-1@@ -332,8 +332,11 @@ 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; + }
please run checkpatch.pl --strict and fix the issues.
Quoted 5 lines
net/nfc/rawsock.c +0
-0else sock->ops = &rawsock_ops;