public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] l2tp: fix missing refcount drop in pppol2tp_tunnel_ioctl()
@ 2018-08-03 15:00 Guillaume Nault
  2018-08-03 19:42 ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Guillaume Nault @ 2018-08-03 15:00 UTC (permalink / raw)
  To: netdev; +Cc: James Chapman

If 'session' is not NULL and is not a PPP pseudo-wire, then we fail to
drop the reference taken by l2tp_session_get().

Fixes: ecd012e45ab5 ("l2tp: filter out non-PPP sessions in pppol2tp_tunnel_ioctl()")
Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
---
Sorry for the stupid mistake. I guess I got blinded by the apparent
simplicity of the bug when I wrote the original patch.

net/l2tp/l2tp_ppp.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c
index e398797878a9..cf6cca260e7b 100644
--- a/net/l2tp/l2tp_ppp.c
+++ b/net/l2tp/l2tp_ppp.c
@@ -1201,13 +1201,18 @@ static int pppol2tp_tunnel_ioctl(struct l2tp_tunnel *tunnel,
 				l2tp_session_get(sock_net(sk), tunnel,
 						 stats.session_id);
 
-			if (session && session->pwtype == L2TP_PWTYPE_PPP) {
-				err = pppol2tp_session_ioctl(session, cmd,
-							     arg);
+			if (!session) {
+				err = -EBADR;
+				break;
+			}
+			if (session->pwtype != L2TP_PWTYPE_PPP) {
 				l2tp_session_dec_refcount(session);
-			} else {
 				err = -EBADR;
+				break;
 			}
+
+			err = pppol2tp_session_ioctl(session, cmd, arg);
+			l2tp_session_dec_refcount(session);
 			break;
 		}
 #ifdef CONFIG_XFRM
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-08-10 20:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-03 15:00 [PATCH net] l2tp: fix missing refcount drop in pppol2tp_tunnel_ioctl() Guillaume Nault
2018-08-03 19:42 ` David Miller
2018-08-05 11:24   ` Guillaume Nault
2018-08-10 17:58     ` Guillaume Nault
2018-08-10 18:04       ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox