Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2319565pxb; Mon, 20 Sep 2021 18:42:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxc7dCPK0GQ5YWttXVCwg5XtdOkVe45Of1KTB+Qngkuc5AMYtiTHRFN1vI4nSru9wTSz4y4 X-Received: by 2002:a05:6638:1606:: with SMTP id x6mr15314551jas.59.1632188567940; Mon, 20 Sep 2021 18:42:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632188567; cv=none; d=google.com; s=arc-20160816; b=mohHmS1mfZ18Jo7ODjP1K1TkqfMlXcG5uLs2Uk1uD4H8W6JpYdUEyPIxasDGQcgOEi sQ+m87YdlCnB7S6FPZE4TlnqGI7f3mhXh97ZakQVMQyS5PPVebDgVDR2ijRa+nYXMCoV FiP71oARIXainMeHEVa5UUxJ3r7/e6p8AH2ks/fVWxlYG1W0vmDsEAdtL287j6pyLIhr DsJtWI2ofyyCiMWsbSONlBE8bwA+sSnmoeepYuXNKBXmp5erQzk+mwB4dHliv6asxgUq 4oNQrRCtJhXJrQgBzQtqo2LvsQCjFKdhpMBUmlqOZ56g4P7l2779HZelzDLvtY8hkMLh q+Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zDdnurjYo5My6I7gaarqWlt41B0uMQ8I6DjHQNjaxaQ=; b=hsifHC9P3O0gRjfICUTJxQX/VSs3YUPqBDi8oUxiTsa6AKXXVCTQnMapfenk574oz5 HOwdt4Dem+doptWpSDGNaGszPgEopMYZzcQDc2iGpjPTOpTZmfBx0FSj53UnAw9kNsKO rUwwCLZlUQRzsxMuT47n4kfM654jRxCrT1TzZb5ZJc8bKukaVIzVG9i8OaGH86cyvKmY xMA44Nwre9ghZT7gMRnXEjbb9rSfBktcnA0FHVjmxUyEYEgeX49WbJ+vBNmH7DKpxRu5 UjZpDuUkUVuPcErr38eYY7rmZLR74XGA2TQmykeEoLJPytUeZvwYmZpHFOb89dwOs07v aX5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=U8oprgtt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m3si6021597iop.20.2021.09.20.18.42.37; Mon, 20 Sep 2021 18:42:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=U8oprgtt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243737AbhITQzx (ORCPT + 99 others); Mon, 20 Sep 2021 12:55:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:39722 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243599AbhITQv6 (ORCPT ); Mon, 20 Sep 2021 12:51:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DA7BF61245; Mon, 20 Sep 2021 16:49:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632156578; bh=JKb5xj6pEm3/ajHDs40qfOjoV8+Jz2PznN0JRk/mzaY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U8oprgtt5Pfe8toyk3LMqnOZGzpI7Gno9i6+eqDOQph+dngNR5RQ/bEKU6rAJ4BAD S9Ks7vbBMF3hcNBL31xp+mC8TIsG/8r7gQLMbrHGPO70o7G8TtfAOFdyDpcMtys8yg lyrfBAeDO+hkWhpygz9cd6Owp0FAUyeTKZJqiQIE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiyu Yang , Xin Xiong , Xin Tan , "David S. Miller" Subject: [PATCH 4.4 122/133] net/l2tp: Fix reference count leak in l2tp_udp_recv_core Date: Mon, 20 Sep 2021 18:43:20 +0200 Message-Id: <20210920163916.611967028@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163912.603434365@linuxfoundation.org> References: <20210920163912.603434365@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiyu Yang commit 9b6ff7eb666415e1558f1ba8a742f5db6a9954de upstream. The reference count leak issue may take place in an error handling path. If both conditions of tunnel->version == L2TP_HDR_VER_3 and the return value of l2tp_v3_ensure_opt_in_linear is nonzero, the function would directly jump to label invalid, without decrementing the reference count of the l2tp_session object session increased earlier by l2tp_tunnel_get_session(). This may result in refcount leaks. Fix this issue by decrease the reference count before jumping to the label invalid. Fixes: 4522a70db7aa ("l2tp: fix reading optional fields of L2TPv3") Signed-off-by: Xiyu Yang Signed-off-by: Xin Xiong Signed-off-by: Xin Tan Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/l2tp/l2tp_core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/net/l2tp/l2tp_core.c +++ b/net/l2tp/l2tp_core.c @@ -990,8 +990,10 @@ static int l2tp_udp_recv_core(struct l2t } if (tunnel->version == L2TP_HDR_VER_3 && - l2tp_v3_ensure_opt_in_linear(session, skb, &ptr, &optr)) + l2tp_v3_ensure_opt_in_linear(session, skb, &ptr, &optr)) { + l2tp_session_dec_refcount(session); goto error; + } l2tp_recv_common(session, skb, ptr, optr, hdrflags, length, payload_hook); l2tp_session_dec_refcount(session);