From: Guillaume Nault Date: Fri, 13 Oct 2017 17:22:35 +0000 (+0200) Subject: l2tp: check ps->sock before running pppol2tp_session_ioctl() X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=95de39762794bf55dc17ee33b6d1502923f1ad18;p=pandora-kernel.git l2tp: check ps->sock before running pppol2tp_session_ioctl() commit 5903f594935a3841137c86b9d5b75143a5b7121c upstream. 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 Signed-off-by: David S. Miller Signed-off-by: Ben Hutchings --- diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c index d6dcff6303ec..5a068c5cb114 100644 --- a/net/l2tp/l2tp_ppp.c +++ b/net/l2tp/l2tp_ppp.c @@ -997,6 +997,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) {