l2tp: prevent pppol2tp_connect() from creating kernel sockets
[muen/linux.git] / net / l2tp / l2tp_ppp.c
index 8b3b6947a07d7f08127a444ec4e7089b7188cb80..1b24f76ae210e2f89d791aa96c2d60da091c6520 100644 (file)
@@ -701,6 +701,15 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr,
                                .encap = L2TP_ENCAPTYPE_UDP,
                                .debug = 0,
                        };
+
+                       /* Prevent l2tp_tunnel_register() from trying to set up
+                        * a kernel socket.
+                        */
+                       if (fd < 0) {
+                               error = -EBADF;
+                               goto end;
+                       }
+
                        error = l2tp_tunnel_create(sock_net(sk), fd, ver, tunnel_id, peer_tunnel_id, &tcfg, &tunnel);
                        if (error < 0)
                                goto end;