Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5248921rwd; Mon, 5 Jun 2023 00:12:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7xyjbhrSWJDpIqjK0EZ4aeJjw7yqF+ArvIQq4y6sWLoIuBHqvC+NE0YDamgrEonsNcuZLk X-Received: by 2002:a17:90a:880f:b0:256:93bf:c731 with SMTP id s15-20020a17090a880f00b0025693bfc731mr6448981pjn.13.1685949141299; Mon, 05 Jun 2023 00:12:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685949141; cv=none; d=google.com; s=arc-20160816; b=yxBlkTwsKRJBCZewM4ycmZqG0ZNkRjqOfivDtKdLveaAsQL3ag0X9+Sc34Q7XKFQKQ XfVFjE2OzBac8G9SBudpyd1GnNytU1euN2K/y8cdr8OXOofi9DgBIw4XjLkUHFBMKxiy 2ADHyzsyINBh5jf62KNw50WOuJ8pn6NRBSq1ChMkNVRNW/1vmYM2EPRdJN4KzmYJHowU yaThCzwnABkMG+5fqhJ3ktjZTeS0lm02wDyAzEUipeRX04aFFR9K3RFbP93A7sxOcVRO SGOMDYRZmlqO2FWkJ1jiNKKsduFUuyD2QSeXrDVMvfFwhWG0ZvCSqGnwK+ddh4IMK9lP IrIQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=dJT/sRF5KYka/O8wMeQ1HTIrVd4xnv3bYNT/8zFnrPA=; b=uOgHalsPUQ6kf5ASkGvXHIU7o+GA3LeiLlbIlVQQZsvj71l4XZudIVj/I+BrJ42G1C 6bWmrb0FeifDlLFyLgqjVJ8Z1RrberVtz/MZWqN43qrYpOtTxXAJM7+7iBRsOFuDEPO2 B6NZzTfLOYV38oDFuEd3/dtPxRnO1EY3zOI7B2UXUDj4BFP7rH5xXztwgN//LsBwnFWm rHA0hTtwyb/aOBRyyyPnv+0czUUxkkLNNiWhaA3Fdnrhs1fMc8LJNsEdRJF3BdM0wlv8 W5zqSL7oBlYuyPgvlmLNBQsBtjqGnFe1uHyQqqzX/9LkWRXjzr82fBkVWcZJfOMSWOz6 HCsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=qYWmyp7k; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u13-20020a17090a5e4d00b002562fce8178si6860979pji.25.2023.06.05.00.12.09; Mon, 05 Jun 2023 00:12:21 -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=@gmail.com header.s=20221208 header.b=qYWmyp7k; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230045AbjFEHDL (ORCPT + 99 others); Mon, 5 Jun 2023 03:03:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230419AbjFEHCm (ORCPT ); Mon, 5 Jun 2023 03:02:42 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14D9FD3; Mon, 5 Jun 2023 00:02:12 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id 41be03b00d2f7-52c84543902so279391a12.0; Mon, 05 Jun 2023 00:02:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685948530; x=1688540530; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=dJT/sRF5KYka/O8wMeQ1HTIrVd4xnv3bYNT/8zFnrPA=; b=qYWmyp7ksT4pI/yXswqnzosuyVhYy6HFFYgDQLcsACELE49rnNkCn88df8p0KR7ck0 2YptChW2qB3FhvPO2b7Ox81ZE0XQXH5W0y7ei2GHouls1kW1LpOBBlUIUYqhVTK8x9b6 FYixgWUPnMLj6lsibNkgZbHj+bhSgfUbFjSXqc1Igf6ve+f2s9w/UB3E0JCGAXNhoCXV 01JnuBAT8dzQpPAUnYLc26CuOmD2MKqYy2FYoOPvbhwbc6YbQ+aKj72PkZZeMUcoIRCG S98VuOULel93hNXJSbp+Qp2n8l3pqzkq55QXGvmbAW7RMeRAEOj341V8kEH7aX+Crmsw Kx/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685948530; x=1688540530; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=dJT/sRF5KYka/O8wMeQ1HTIrVd4xnv3bYNT/8zFnrPA=; b=D5+ib7K2e6wboPVG6uY2SXnMZRIfWsDQ+D/s0yN9e2Tt90q5bQ4M5/Ok4cjjgkOncM 9XgyffntOaqtk2OuaKAVyFeRXHRByX/2eTm0gZLAZ6i2rhNNTefoI1OP4JwZshal2ctV CcSwbh7q2XIA1s6lELjcvgNl8EOk/VBL7N+IxizwglvF3bFQTMhTWROnMnmrK+IFaZWD /3NmmbNdOUnNCmLJUZ0H/LDzP4+vEwbOFeFKdZrnEzGOKwI3MLOO8lebi6Ph3CaP1yPa GC2+FrX4fQsxYnTsV2Vr6Liqb8PvCdpRQaGIADL32RTjEQEgsVzusSemPzfyEcST+r2D IISg== X-Gm-Message-State: AC+VfDzxz4g5Ed1L64xMogJg8jr3oGoUNsTnH0vmLVgKg4aiBWqOELrw 8/JUSSCCdCXAMmiGeCB9ch8= X-Received: by 2002:a17:90b:4f47:b0:255:c3a3:43a with SMTP id pj7-20020a17090b4f4700b00255c3a3043amr17351826pjb.4.1685948529855; Mon, 05 Jun 2023 00:02:09 -0700 (PDT) Received: from hbh25y.mshome.net ([103.114.158.1]) by smtp.gmail.com with ESMTPSA id hg12-20020a17090b300c00b002562cfb81dfsm7004534pjb.28.2023.06.05.00.02.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jun 2023 00:02:09 -0700 (PDT) From: Hangyu Hua To: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Hangyu Hua Subject: [PATCH net] net: sched: fix possible refcount leak in tc_chain_tmplt_add() Date: Mon, 5 Jun 2023 15:01:58 +0800 Message-Id: <20230605070158.48403-1-hbh25y@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 try_module_get can be called in tcf_proto_lookup_ops. So if ops don't implement the corresponding function we should call module_put to drop the refcount. Fixes: 9f407f1768d3 ("net: sched: introduce chain templates") Signed-off-by: Hangyu Hua --- net/sched/cls_api.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 2621550bfddc..92bfb892e638 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -2952,6 +2952,7 @@ static int tc_chain_tmplt_add(struct tcf_chain *chain, struct net *net, return PTR_ERR(ops); if (!ops->tmplt_create || !ops->tmplt_destroy || !ops->tmplt_dump) { NL_SET_ERR_MSG(extack, "Chain templates are not supported with specified classifier"); + module_put(ops->owner); return -EOPNOTSUPP; } -- 2.34.1