Skip to content

Commit 3e1bc8b

Browse files
Guillaume Naultdavem330
authored andcommitted
l2tp: prevent pppol2tp_connect() from creating kernel sockets
If 'fd' is negative, l2tp_tunnel_create() creates a tunnel socket using the configuration passed in 'tcfg'. Currently, pppol2tp_connect() sets the relevant fields to zero, tricking l2tp_tunnel_create() into setting up an unusable kernel socket. We can't set 'tcfg' with the required fields because there's no way to get them from the current connect() parameters. So let's restrict kernel sockets creation to the netlink API, which is the original use case. Fixes: 789a4a2 ("l2tp: Add support for static unmanaged L2TPv3 tunnels") Signed-off-by: Guillaume Nault <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7ac6ab1 commit 3e1bc8b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

net/l2tp/l2tp_ppp.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,15 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr,
701701
.encap = L2TP_ENCAPTYPE_UDP,
702702
.debug = 0,
703703
};
704+
705+
/* Prevent l2tp_tunnel_register() from trying to set up
706+
* a kernel socket.
707+
*/
708+
if (fd < 0) {
709+
error = -EBADF;
710+
goto end;
711+
}
712+
704713
error = l2tp_tunnel_create(sock_net(sk), fd, ver, tunnel_id, peer_tunnel_id, &tcfg, &tunnel);
705714
if (error < 0)
706715
goto end;

0 commit comments

Comments
 (0)