diff options
author | Qingyu Li <ieatmuttonchuan@gmail.com> | 2020-08-10 09:51:00 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-08-19 08:15:03 +0200 |
commit | b200620cada4eaa63108be32e040ed557a1965fd (patch) | |
tree | 6f837361cad5910fc9b9f14cced4b6e05b0b6676 /net | |
parent | 597d2df941303316651fc147457bf85aced2f959 (diff) | |
download | linux-stable-b200620cada4eaa63108be32e040ed557a1965fd.tar.gz linux-stable-b200620cada4eaa63108be32e040ed557a1965fd.tar.bz2 linux-stable-b200620cada4eaa63108be32e040ed557a1965fd.zip |
net/nfc/rawsock.c: add CAP_NET_RAW check.
[ Upstream commit 26896f01467a28651f7a536143fe5ac8449d4041 ]
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/nfc/rawsock.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/net/nfc/rawsock.c b/net/nfc/rawsock.c index e2188deb08dc..b927730d9ab0 100644 --- a/net/nfc/rawsock.c +++ b/net/nfc/rawsock.c @@ -344,10 +344,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) |