From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42145C352A3 for ; Mon, 10 Feb 2020 12:35:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 11A1B2168B for ; Mon, 10 Feb 2020 12:35:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338102; bh=wOcNyjm+mwOODpPFkM42+asVMReuzY0jZgrInWYPVzw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=dtxk2066c+Z9NwA4E/dCcxHcehXmJ4SFL2ypq45wbwzSK6cfzLlMk5hl73J+OiZwD XO2phZP3TkA5/+satMT5Cfhjws4OaHDmwRcqBtefw1KYVlRtB4rgApt6Smdnwq4JEV 7Hx+I+Y3fHaQ0Y2B4zoYEbf79uBEhehr9vaOrsis= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727599AbgBJMfB (ORCPT ); Mon, 10 Feb 2020 07:35:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:51066 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727008AbgBJMfA (ORCPT ); Mon, 10 Feb 2020 07:35:00 -0500 Received: from localhost (unknown [209.37.97.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 868C621569; Mon, 10 Feb 2020 12:34:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338098; bh=wOcNyjm+mwOODpPFkM42+asVMReuzY0jZgrInWYPVzw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KXmM1jXMQFI9Pnxn17ehc/xYHywLzEC0ttDoA8m3kAu84qq1AIbnWnBCr6CQWyvmE FBA5srgerUiFuvkV7o062W1S8t3ISWg24nJaEAOz190yoVEMS1kPJtjpJMZb4jzd3h kEs7AV+E3MeG1Pcmugo1QtXZysQ7dA8rcx+f+sf8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ridge Kennedy , James Chapman , "David S. Miller" Subject: [PATCH 4.19 013/195] l2tp: Allow duplicate session creation with UDP Date: Mon, 10 Feb 2020 04:31:11 -0800 Message-Id: <20200210122307.000630132@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210122305.731206734@linuxfoundation.org> References: <20200210122305.731206734@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ridge Kennedy [ Upstream commit 0d0d9a388a858e271bb70e71e99e7fe2a6fd6f64 ] In the past it was possible to create multiple L2TPv3 sessions with the same session id as long as the sessions belonged to different tunnels. The resulting sessions had issues when used with IP encapsulated tunnels, but worked fine with UDP encapsulated ones. Some applications began to rely on this behaviour to avoid having to negotiate unique session ids. Some time ago a change was made to require session ids to be unique across all tunnels, breaking the applications making use of this "feature". This change relaxes the duplicate session id check to allow duplicates if both of the colliding sessions belong to UDP encapsulated tunnels. Fixes: dbdbc73b4478 ("l2tp: fix duplicate session creation") Signed-off-by: Ridge Kennedy Acked-by: James Chapman Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/l2tp/l2tp_core.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/net/l2tp/l2tp_core.c +++ b/net/l2tp/l2tp_core.c @@ -325,8 +325,13 @@ int l2tp_session_register(struct l2tp_se spin_lock_bh(&pn->l2tp_session_hlist_lock); + /* IP encap expects session IDs to be globally unique, while + * UDP encap doesn't. + */ hlist_for_each_entry(session_walk, g_head, global_hlist) - if (session_walk->session_id == session->session_id) { + if (session_walk->session_id == session->session_id && + (session_walk->tunnel->encap == L2TP_ENCAPTYPE_IP || + tunnel->encap == L2TP_ENCAPTYPE_IP)) { err = -EEXIST; goto err_tlock_pnlock; }