Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3325155imu; Sun, 11 Nov 2018 12:24:34 -0800 (PST) X-Google-Smtp-Source: AJdET5fGuvegB5OjuvNDkimhGIob9YAGqFDMR1ynwZF1h1z5y+B4Qkpyc2LTAoidGF/PwViRRcVI X-Received: by 2002:a17:902:8bc6:: with SMTP id r6-v6mr17242983plo.194.1541967874430; Sun, 11 Nov 2018 12:24:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541967874; cv=none; d=google.com; s=arc-20160816; b=hPlaPuw/J252tldRQz2rfbXBeEydhNyWgy5fWJTL8Qr6GbsvOhG8UX/kMyCcex/Pyv L4Lla07hAdrRCLgDLLyx3zjd+dwFnjnSXXqLRs76LbSsRFh7r2qwfwGg+rnzd4nNq52R HaCiCFU6jZjS0WEuNlSCstH728xbNyAvDp1k+k8F3fcSvR0w7UsTbfws1HT1mOs4cUmk TPeWVBR+gwNIp/GaO7GRhmP+nXldGb8Q8g23zcEAMNDazvvB2Pn2+SnViQ9UArxjcsbG k5A3uoqgW/rr90dl0q/fuVJFTwrJGnBjxSekfSXEZ85CrdxtDUhyHwJ0cZF2DZxl6wfr 6Bwg== 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=P7B9Q6O4ApdH4DKXShQDHhXJ/aidSwoaCzDqot9W+bA=; b=Ma1fDpSWqv6sh/cdA1J07PtrzBBeNUKPLGYH0Wj7dJSjQN9gkfEsQn3fZKeITh0PLt yMulYjhHR9QgYK/ahtYSOECUAnLL9Jfmut4dSMHEEivKtaErcQS5jaNswZ3dK+Vcy96g Tnt/uc5ellf2XaqzeTmW9YNVeB3fVCw88yvjmPZor6Yb1UfZ72m4hyDsIvAz+aLf6DaO LFoihSLr3gfrkl6R+8XvR2TUyzqisULeg2nKxmJNBTUqFKblWHX62VxMQnJ7nV0dAKjy 23d8/3zduJGG8qv09vvKFdzg4woJzxMLQ+spQkOIHdUtZ/Jdf3YpUTFLqFvZMbApdsI/ Sqjg== 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.24.19; Sun, 11 Nov 2018 12:24:34 -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 S1731097AbeKLFx4 (ORCPT + 99 others); Mon, 12 Nov 2018 00:53:56 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:51668 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726508AbeKLFxz (ORCPT ); Mon, 12 Nov 2018 00:53:55 -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 1gLvt0-0000l4-Lt; Sun, 11 Nov 2018 19:59:10 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsS-0001YP-DN; 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, "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 143/366] l2tp: reject creation of non-PPP sessions on L2TPv2 tunnels 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 de9bada5d389903f4faf33980e6a95a2911c7e6d upstream. The /proc/net/pppol2tp handlers (pppol2tp_seq_*()) iterate over all L2TPv2 tunnels, and rightfully expect that only PPP sessions can be found there. However, l2tp_netlink accepts creating Ethernet sessions regardless of the underlying tunnel version. This confuses pppol2tp_seq_session_show(), which expects that l2tp_session_priv() returns a pppol2tp_session structure. When the session is an Ethernet pseudo-wire, a struct l2tp_eth_sess is returned instead. This leads to invalid memory access when pppol2tp_session_get_sock() later tries to dereference ps->sk. 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_netlink.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/net/l2tp/l2tp_netlink.c +++ b/net/l2tp/l2tp_netlink.c @@ -460,6 +460,12 @@ static int l2tp_nl_cmd_session_create(st goto out_tunnel; } + /* L2TPv2 only accepts PPP pseudo-wires */ + if (tunnel->version == 2 && cfg.pw_type != L2TP_PWTYPE_PPP) { + ret = -EPROTONOSUPPORT; + goto out_tunnel; + } + if (tunnel->version > 2) { if (info->attrs[L2TP_ATTR_OFFSET]) cfg.offset = nla_get_u16(info->attrs[L2TP_ATTR_OFFSET]);