ieee802154: enforce CAP_NET_RAW for raw sockets
authorOri Nimron <orinimron123@gmail.com>
Fri, 20 Sep 2019 07:35:48 +0000 (09:35 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 5 Oct 2019 10:47:44 +0000 (12:47 +0200)
[ Upstream commit e69dbd4619e7674c1679cba49afd9dd9ac347eef ]

When creating a raw AF_IEEE802154 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>
Acked-by: Stefan Schmidt <stefan@datenfreihafen.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/ieee802154/socket.c

index a60658c85a9ad09b405f2d928e70acf64a9ebc4d..e95004b507d3fb914dea91979db3cbad4a4151f6 100644 (file)
@@ -1001,6 +1001,9 @@ static int ieee802154_create(struct net *net, struct socket *sock,
 
        switch (sock->type) {
        case SOCK_RAW:
+               rc = -EPERM;
+               if (!capable(CAP_NET_RAW))
+                       goto out;
                proto = &ieee802154_raw_prot;
                ops = &ieee802154_raw_ops;
                break;