l2tp: check ps->sock before running pppol2tp_session_ioctl()
authorGuillaume Nault <g.nault@alphalink.fr>
Fri, 13 Oct 2017 17:22:35 +0000 (19:22 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sun, 15 Oct 2017 01:38:56 +0000 (18:38 -0700)
When pppol2tp_session_ioctl() is called by pppol2tp_tunnel_ioctl(),
the session may be unconnected. That is, it was created by
pppol2tp_session_create() and hasn't been connected with
pppol2tp_connect(). In this case, ps->sock is NULL, so we need to check
for this case in order to avoid dereferencing a NULL pointer.

Fixes: 309795f4bec2 ("l2tp: Add netlink control API for L2TP")
Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/l2tp/l2tp_ppp.c

index bc6e8bfc5be4997e421c0b5326a8b37e2ffc9901..f50452b919d5ece9d70e2c25634bc8fef9962e6b 100644 (file)
@@ -988,6 +988,9 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
                 session->name, cmd, arg);
 
        sk = ps->sock;
+       if (!sk)
+               return -EBADR;
+
        sock_hold(sk);
 
        switch (cmd) {