Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3332192imu; Sun, 11 Nov 2018 12:33:37 -0800 (PST) X-Google-Smtp-Source: AJdET5fHVgq7Ur7hok/yt2tt1wajX4lXab8xJqQvJxJ+eEVhObRSubOrp5JsIF57Ub1aFGcobDC4 X-Received: by 2002:a17:902:e005:: with SMTP id ca5-v6mr17047319plb.195.1541968417579; Sun, 11 Nov 2018 12:33:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541968417; cv=none; d=google.com; s=arc-20160816; b=LliXVszatxXOx3MZzWbtMn3C1QIaUKYhgAf3fRL5PaV5qWDibID1akTJPR4q1GQJnu QLPLDBz+C11HPcM80LhQCh08CdzXPXUOGmGG7/HmcQncmfkeEnHUsQCqWxmEjyRTeSoU 6jEFAxywX8TC2yDY4eldeHyxP6f1QbdXT3O3pr/xpEuSgeC2AUWn8fmog2RMWN0WZl0H ukXF0fVmoFrra2uZKW+4H0AzGZJwEaUSTGUF/yGVBKqbE1AfW0b0qR1d71wVTGyAq7sQ AXzCMwhvHDuzOaP1Zxd5+L5FZ5XIfdXkBAHNxeOd0eG3a6JbS0aSWEFHQAHTbDp0InVJ aiDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=/i+8qfGcr73zICbZLFEM0D+Vzrc2mMmqdDcpzLD6m+k=; b=VSbhsA3baW++MQCuJ1eVU1uV7l6NZ59O+KIKOD86smr9tOfVLJoKiwzVqtQvryHLGX KN16wNJJKLhwosoStkQBm8Add3MYZ5fz42WHpo837J2zGaP2Z2EeGe4/INSBoa+sKdf8 tCGo+xV9CIMrDyXaoFpKdqxOEUZ1s73gWxDHUq8pyAaePbG5zg0l5yMaN391l1R+NTlm +ePkgjOE4HKy3P1B5JfC+6oKrzCcfF9wd97hoyoLaGzFbYTS2C6t7u0RCH36rKnaM55o rY92DEJqF0o7uuzfkcIU9fERhmE+jbaeLmNLKxJViSJZC3nDqeH9IxIuXbT4wk2Dxf3L +15Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d12-v6si14967771plr.92.2018.11.11.12.33.22; Sun, 11 Nov 2018 12:33:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730546AbeKLGWc (ORCPT + 99 others); Mon, 12 Nov 2018 01:22:32 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:50174 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730278AbeKLFsQ (ORCPT ); Mon, 12 Nov 2018 00:48:16 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvsc-0000l7-D7; Sun, 11 Nov 2018 19:58:46 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsZ-0001ox-0w; Sun, 11 Nov 2018 19:58:43 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "David S. Miller" , "Guillaume Nault" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 309/366] l2tp: fix missing refcount drop in pppol2tp_tunnel_ioctl() In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.61-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Guillaume Nault commit f664e37dcc525768280cb94321424a09beb1c992 upstream. 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 Signed-off-by: David S. Miller [bwh: Backported to 3.16: Also call session->deref in both cases] Signed-off-by: Ben Hutchings --- net/l2tp/l2tp_ppp.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) --- a/net/l2tp/l2tp_ppp.c +++ b/net/l2tp/l2tp_ppp.c @@ -1231,15 +1231,22 @@ static int pppol2tp_tunnel_ioctl(struct l2tp_session_get(sock_net(sk), tunnel, stats.session_id, true); - 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) { if (session->deref) session->deref(session); l2tp_session_dec_refcount(session); - } else { err = -EBADR; + break; } + + err = pppol2tp_session_ioctl(session, cmd, arg); + if (session->deref) + session->deref(session); + l2tp_session_dec_refcount(session); break; } #ifdef CONFIG_XFRM