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 0631FC352A3 for ; Mon, 10 Feb 2020 13:09:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D32A620714 for ; Mon, 10 Feb 2020 13:09:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581340147; bh=Uf5dyPUwOjnGG1vDaVTVkMec/xC2ujIU5L+gaCot1SM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=JlXkb+TTqudOOJuH9xGkB0fyYtk9l1yhDA9ehwqTCSqbbL/cH/CZ2eCgWXfqTSEL8 Ht1DSxeYjnnC36rdY6JovkfgPSFsZ1Uc3jOD7uNHXZFG7zp4khE0gtlfrZMuupcNbO 4A3r5AD553VCUMBxLSKRa1EVXGMm1IO1MWfsziUs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729605AbgBJNJF (ORCPT ); Mon, 10 Feb 2020 08:09:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:36950 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729410AbgBJMjX (ORCPT ); Mon, 10 Feb 2020 07:39:23 -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 D208820842; Mon, 10 Feb 2020 12:39:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338362; bh=Uf5dyPUwOjnGG1vDaVTVkMec/xC2ujIU5L+gaCot1SM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z2/37Bo1zVvGlXNYYN3FiY0zBDMfXST+y730+j2akBpRypz/WGiSXk495YhHPPnCz TUVlBmvc9wZ5HDqhsi3US6jRP5pyiYnZqjoBwF7S4Jv/XbZsKkxaJSl5Wz6IvGJEAb LP6HlOEggiEtJGsyyOlSDGPpnLgMlyZQq7cwKBuM= 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 5.5 004/367] l2tp: Allow duplicate session creation with UDP Date: Mon, 10 Feb 2020 04:28:37 -0800 Message-Id: <20200210122424.210562661@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210122423.695146547@linuxfoundation.org> References: <20200210122423.695146547@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 @@ -322,8 +322,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; }