net: hook socketpair() into LSM
authorDavid Herrmann <dh.herrmann@gmail.com>
Fri, 4 May 2018 14:28:20 +0000 (16:28 +0200)
committerJames Morris <james.morris@microsoft.com>
Fri, 4 May 2018 19:48:54 +0000 (12:48 -0700)
Use the newly created LSM-hook for socketpair(). The default hook
return-value is 0, so behavior stays the same unless LSMs start using
this hook.

Acked-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Tom Gundersen <teg@jklm.no>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: James Morris <james.morris@microsoft.com>
net/socket.c

index f10f1d947c78c193b49379b0ec641d81367fb4cf..667a7b3971347c0db6baf233ada479a5789500b0 100644 (file)
@@ -1420,6 +1420,13 @@ int __sys_socketpair(int family, int type, int protocol, int __user *usockvec)
                goto out;
        }
 
+       err = security_socket_socketpair(sock1, sock2);
+       if (unlikely(err)) {
+               sock_release(sock2);
+               sock_release(sock1);
+               goto out;
+       }
+
        err = sock1->ops->socketpair(sock1, sock2);
        if (unlikely(err < 0)) {
                sock_release(sock2);