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

When creating a raw AF_APPLETALK 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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/appletalk/ddp.c

index d1b68cc7da8992904141c6fd9bcc32a85e598847..475f332b1ad2d85c9a8bf0d740973329eccb4bd7 100644 (file)
@@ -1029,6 +1029,11 @@ static int atalk_create(struct net *net, struct socket *sock, int protocol,
         */
        if (sock->type != SOCK_RAW && sock->type != SOCK_DGRAM)
                goto out;
+
+       rc = -EPERM;
+       if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
+               goto out;
+
        rc = -ENOMEM;
        sk = sk_alloc(net, PF_APPLETALK, GFP_KERNEL, &ddp_proto, kern);
        if (!sk)