Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3315699imu; Sun, 11 Nov 2018 12:12:14 -0800 (PST) X-Google-Smtp-Source: AJdET5eY0FyVWGtK+wXec4VpcEXw6pQjBN9Bua6zVcPiQHKNJ00mOWz/o6YKsFO+Wq1EEMBE3gqt X-Received: by 2002:a63:1904:: with SMTP id z4mr14550275pgl.135.1541967134323; Sun, 11 Nov 2018 12:12:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541967134; cv=none; d=google.com; s=arc-20160816; b=npUBWJlxlyDHhHez4fcZEkdxpcDpXGUBz2uJPkadNIPDPhT3+PxfgYpznbGXSDwSnV 8QEmuUQq/lDgvusVojiREQEQ1hoNl/wL7J2BksP4ErhFXr3zE9Pbpb+zMfNTY89zLyCh RAiK5Pq10uNaikhT82QB7nB8QOg2LSz89I3/vuOTJLxFF7iR2Z8mh6RayrsWdKo9H17I mGs8rc0pKaKfnrxq+9HN108TYeeId2tGT3RmENWCR7P701Jf7fGLU7ERGsnz8XY/+Y6L +I2GfCTImTn/VwGO3VsPFsA/ng0QJx2d0nywemdaxH6aFOzaYF1o0K+mw6bXJKM+fTWH p/rA== 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=3ZjHJJS2PTTAJE/R9zqsNCW2eO04UVzWhs0q6esnyPo=; b=q5cEZg1OKSQSvln8zPXw0fEZN9wqlqQzcXOiwFeHsNYP1smAmvAeTC0zokTBxkXO8Q haYFihzjdPZcA9nsGNey3Nd8q88JXnvBeK3dxn90Dip1Doo/0doBBExbzTxpp5Jm0uUG tawoBewwIUSyxWuY03kTlyPOLteR1CKg6oIXzhIblRNI6Kvkgp93Noc0ab4zWPhxAGvx ddWhYOnnzNPVG/V1CMF0tzFvmBEHk6c0Hz+hf6+GYOyUbz68zUTRKvqGehdhS6Cq+SE4 dbPjwdUZdRtnyJW7joOjDSvqdmrapmla3cwa1QzMczfNXJ67MW17+64Ws2Yv3TMjCvLD Nb9Q== 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 d2-v6si14635457plh.168.2018.11.11.12.11.58; Sun, 11 Nov 2018 12:12:14 -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 S1731627AbeKLGAh (ORCPT + 99 others); Mon, 12 Nov 2018 01:00:37 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:52442 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731019AbeKLGAg (ORCPT ); Mon, 12 Nov 2018 01:00:36 -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 1gLvt1-0000oG-Hw; Sun, 11 Nov 2018 19:59:11 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsS-0001Y5-8C; Sun, 11 Nov 2018 19:58:36 +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, "Guillaume Nault" , "David S. Miller" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 139/366] l2tp: only accept PPP sessions in pppol2tp_connect() 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 7ac6ab1f8a38ba7f8d97f95475bb6a2575db4658 upstream. l2tp_session_priv() returns a struct pppol2tp_session pointer only for PPPoL2TP sessions. In particular, if the session is an L2TP_PWTYPE_ETH pseudo-wire, l2tp_session_priv() returns a pointer to an l2tp_eth_sess structure, which is much smaller than struct pppol2tp_session. This leads to invalid memory dereference when trying to lock ps->sk_lock. Fixes: d9e31d17ceba ("l2tp: Add L2TP ethernet pseudowire support") Signed-off-by: Guillaume Nault Signed-off-by: David S. Miller Signed-off-by: Ben Hutchings --- net/l2tp/l2tp_ppp.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/net/l2tp/l2tp_ppp.c +++ b/net/l2tp/l2tp_ppp.c @@ -756,6 +756,12 @@ static int pppol2tp_connect(struct socke session = l2tp_session_get(sock_net(sk), tunnel, session_id, false); if (session) { drop_refcnt = true; + + if (session->pwtype != L2TP_PWTYPE_PPP) { + error = -EPROTOTYPE; + goto end; + } + ps = l2tp_session_priv(session); /* Using a pre-existing session is fine as long as it hasn't