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=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS 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 566DDC43381 for ; Fri, 15 Feb 2019 23:06:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 229782192D for ; Fri, 15 Feb 2019 23:06:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394091AbfBOXGv (ORCPT ); Fri, 15 Feb 2019 18:06:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34410 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393996AbfBOXGv (ORCPT ); Fri, 15 Feb 2019 18:06:51 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D4AF2300ADB; Fri, 15 Feb 2019 23:06:50 +0000 (UTC) Received: from new-host.redhat.com (ovpn-204-38.brq.redhat.com [10.40.204.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id EFBC460C69; Fri, 15 Feb 2019 23:06:48 +0000 (UTC) From: Davide Caratti To: Jamal Hadi Salim , Cong Wang , Jiri Pirko Cc: "David S. Miller" , Vlad Buslov , Paolo Abeni , netdev@vger.kernel.org Subject: [PATCH RFC 1/5] net/sched: fix refcount leak when 'goto_chain' is used Date: Sat, 16 Feb 2019 00:06:27 +0100 Message-Id: <4bb07d66c377864996d5e53356026e339b0b28d4.1550271080.git.dcaratti@redhat.com> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 15 Feb 2019 23:06:51 +0000 (UTC) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org when replacing valid 'goto chain' actions with another valid 'goto chain' action, the kernel leaks chain->action_refcnt and chain->refcnt. Since we unconditionally take the refcount again, if the control action is a 'goto chain', we can just drop them after ->init() has ended successfully. Fixes: db50514f9a9c ("net: sched: add termination action to allow goto chain") Signed-off-by: Davide Caratti --- net/sched/act_api.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/sched/act_api.c b/net/sched/act_api.c index d4b8355737d8..91d79fac8cb2 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -907,6 +907,11 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, if (err != ACT_P_CREATED) module_put(a_o->owner); + if (a->goto_chain) { + tcf_action_goto_chain_fini(a); + a->goto_chain = NULL; + } + if (TC_ACT_EXT_CMP(a->tcfa_action, TC_ACT_GOTO_CHAIN)) { err = tcf_action_goto_chain_init(a, tp); if (err) { -- 2.20.1