diff options
author | Guillaume Nault <g.nault@alphalink.fr> | 2018-06-13 16:09:20 +0300 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2018-11-20 21:05:15 +0300 |
commit | 3df74949e931e79bcc0342ea3dc8fd1aaa84d475 (patch) | |
tree | 510087d08c45f772f6364964f102a5c1064d52ca /net/l2tp | |
parent | d506e9f339a0bc3219fcf3e951d7374b4a8b1c0b (diff) | |
download | linux-3df74949e931e79bcc0342ea3dc8fd1aaa84d475.tar.xz |
l2tp: prevent pppol2tp_connect() from creating kernel sockets
commit 3e1bc8bf974e2d4e7beb842a4c801c2542eff3bd upstream.
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: 789a4a2c61d8 ("l2tp: Add support for static unmanaged L2TPv3 tunnels")
Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'net/l2tp')
-rw-r--r-- | net/l2tp/l2tp_ppp.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c index 65d00618b131..b3f532cf0f8d 100644 --- a/net/l2tp/l2tp_ppp.c +++ b/net/l2tp/l2tp_ppp.c @@ -723,6 +723,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; |