Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2514786rwb; Mon, 3 Oct 2022 01:43:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7WQxVPirzyYeQs3KtYgNP9FjwJEAaHj/pYEu+Dvvult2zGy0Tx97LWjhjeeWTafIVKpZi/ X-Received: by 2002:a17:90a:6405:b0:203:6eaa:4999 with SMTP id g5-20020a17090a640500b002036eaa4999mr11099274pjj.8.1664786623834; Mon, 03 Oct 2022 01:43:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664786623; cv=none; d=google.com; s=arc-20160816; b=W9qi959i0CEwtNiU6ODKJ1QuhoIXitVTp6iRi54Gl4A6Pl2FPouJssmXCzs9HgJb2F Z1HvNvplIblNZ9sn0+NJrwC1pqHRjg5+HFRHpjR3WbOt3LRic7afYi/5LS8tinLVvxk5 hPcFxQvt85nefWDoFZrUcJhy5/JxdzK+zah5LyJwozwb4+ZXkON+4vyJSxcdX9WXwdjx bTgssLvQ6WUsFnDE3BLeG+QtR+IEowHrTwwaskwGbbKEs+85SvTHik2zUJvrUILgM8xL zErH+TWLbpYnirDsO8XJoQKkfPcK2OPQiwGmTW/ZRnhWOZZARCbThTkFtbldLxR38QDP iFHw== 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=ETKuOxXe6n4UiHRYWULI8Ae+tKJEX0OSF0D/StcvPyc=; b=hjQ/SSxp8eitO/0hHjCtgneBtO1DV3nsbvTZ7ajrVofbIrjWWSlX8TCEDiby8WEKff ML4yAQgR+5kspQC9t0VQv4NS51P5LKzJPMYVoxMhjfBykPD7PY3Zi6Pgl4FTQnBvmVYn 7NaxU3XOQ19wePMG0pPQmbuFN9gYJfLoUBBgEXTGIyHAvufC9WN6Yw6jvEK0WMm2264+ 5FRzYZEWTt9vzE5D0qAdkNGTjwRmd6YY8/+3GAoa9mHtJuIGmkoDWdeUWfBpJ/JjwoVF WOtuM1/b4z2xtgHU50wrUOjN8U5RPfJr1OweAisEsxurbcWgcYWiz7WwTTnR5YttTlo3 C2Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EcGSlxoz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a1-20020a170902900100b001768f32f952si9058455plp.538.2022.10.03.01.43.32; Mon, 03 Oct 2022 01:43:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EcGSlxoz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231668AbiJCHgN (ORCPT + 99 others); Mon, 3 Oct 2022 03:36:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231840AbiJCHel (ORCPT ); Mon, 3 Oct 2022 03:34:41 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B556145989; Mon, 3 Oct 2022 00:22:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3F739B80E72; Mon, 3 Oct 2022 07:20:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ABAACC433D6; Mon, 3 Oct 2022 07:20:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781634; bh=cDa5aTyxPYuYr2/Oz0HIB/2RvObzGfKBYzBTaVPzchs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EcGSlxozDoaFJ7IaXrXt/Np3BJDKgtgCXvY8h5OA40Fj//OdNGOy3T5+HCaYjKIzk KL6Ry6h4xVaMGbiiRn6tmgC7Bq6MjsfU9Tq/FI6igFT0pHYpImMPE9+okap6nFyuKc VhYEZhMC64TW8ey227RJzDdeFH/Qpqq1wVjMyylQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hangyu Hua , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.15 57/83] net: sched: act_ct: fix possible refcount leak in tcf_ct_init() Date: Mon, 3 Oct 2022 09:11:22 +0200 Message-Id: <20221003070723.433246341@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070721.971297651@linuxfoundation.org> References: <20221003070721.971297651@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hangyu Hua [ Upstream commit 6e23ec0ba92d426c77a73a9ccab16346e5e0ef49 ] nf_ct_put need to be called to put the refcount got by tcf_ct_fill_params to avoid possible refcount leak when tcf_ct_flow_table_get fails. Fixes: c34b961a2492 ("net/sched: act_ct: Create nf flow table per zone") Signed-off-by: Hangyu Hua Link: https://lore.kernel.org/r/20220923020046.8021-1-hbh25y@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/sched/act_ct.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c index f4fd584fba08..d85fdefe5730 100644 --- a/net/sched/act_ct.c +++ b/net/sched/act_ct.c @@ -1306,7 +1306,7 @@ static int tcf_ct_init(struct net *net, struct nlattr *nla, err = tcf_ct_flow_table_get(params); if (err) - goto cleanup; + goto cleanup_params; spin_lock_bh(&c->tcf_lock); goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); @@ -1321,6 +1321,9 @@ static int tcf_ct_init(struct net *net, struct nlattr *nla, return res; +cleanup_params: + if (params->tmpl) + nf_ct_put(params->tmpl); cleanup: if (goto_ch) tcf_chain_put_by_act(goto_ch); -- 2.35.1