Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp176330rwd; Tue, 6 Jun 2023 20:55:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ74VoJMkt8thu8bnoEnUoRfXGahmicsqemrtJwybrbCySoDO++6GAZJBN9t+QNdsM1mEC2K X-Received: by 2002:a92:cad1:0:b0:33d:7ebd:68d6 with SMTP id m17-20020a92cad1000000b0033d7ebd68d6mr5138566ilq.30.1686110139195; Tue, 06 Jun 2023 20:55:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686110139; cv=none; d=google.com; s=arc-20160816; b=L/FfBcmU2F6n1VChfMoErmHAyPRWGyymDBwOAE07DBOajGcbuaU2ckV3IXpgFeDyT3 +T7U5Ho4m0OYXM1kYKW4yGnW/IPs3Q8BvqNfR0bhoyEaDcoFlG6NGrLo1FFUX+dp1RFs iw01xGBIfOrxQOWhg2fznd4c4qISbmDQMzYQ98xFm/TxPLI8E2OQXEwglihFaaE6eAOZ piYTIZo+7GuFmMn2jFSqXjUIdLVZDV06xmnQgXDxMeQNY9zHATIEksCYusCV88OYL5QD q7jsRwDL6nzdMtjYiyyAiTfRJop71fUHI791yqd+WlspCW9eS8xRs3YVUM/HtS90MWsY 22YA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=BKFbnWBQ9QpASxiIB9KMxVKCkkxXRNBDMQ/+Dbfr93o=; b=YAhzpeUismzxaBb0gGXEPg/Fj7vgsR6rrqZ7Z3k9ekCfOeFjMZS9BnpQgTZw+74dII oD08xW3DnCrfWFdHef1IXZPIV41g6EPBmlWg6Kt18HYGD517R5VW/iDVK27FRH5wNKG0 vlaQP6+NzgG0EnU1X97RY+GGgho9/irqq5EzY9SlV4+KA2NiuQMQrZx/sOgfbcl4t4d6 HPerlvzofUBgwAANKsML+btx1DLBv7ctajTaBI9s4YTC24Iicq7wcX1PTlx+Dt4FNbZp kcVXOwxJLAvJwfA6mAPPCB9XmDWNhDsdA2g7QBU0F8yrcIpRB0dmTUwuKojU9ORKZgqc LuTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=bLdnD8t+; 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 o24-20020a637e58000000b0053476becd25si8239095pgn.285.2023.06.06.20.55.24; Tue, 06 Jun 2023 20:55:39 -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=bLdnD8t+; 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 S240728AbjFGCUi (ORCPT + 99 others); Tue, 6 Jun 2023 22:20:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234730AbjFGCUg (ORCPT ); Tue, 6 Jun 2023 22:20:36 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3978A1732; Tue, 6 Jun 2023 19:20:35 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id 41be03b00d2f7-53fbb3398c8so554587a12.1; Tue, 06 Jun 2023 19:20:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686104435; x=1688696435; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=BKFbnWBQ9QpASxiIB9KMxVKCkkxXRNBDMQ/+Dbfr93o=; b=bLdnD8t+AAulFU42EWbzhLFLnbvdsabwOChyzIgJCaKNY781zyWQuuaUXslvOla9py fvYLSooxN6izeXYk0Xp1460TFjGc3W8uEd9cdciEYigkAiVhf8B0lq28mxWnvl3/aSuB YFECfesJxGfkUKWBvYATOTSilomfJ6Qv7NOL81p2/nY6TXmk1N3ADqu7L+BhJ59CkCsD rT3vclse2ncSq5zwdCtmB8xcYxi4N14ht2+9T1WsbALtMjd1OJSwjp0r8CWEV0yDQJbH VQl5tnDHg5fI7xIqmIep/wg7+ki2cZXfbQ13wPDmSWr7YSZtuN9cytH69DQkxdTDfVzZ idpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686104435; x=1688696435; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BKFbnWBQ9QpASxiIB9KMxVKCkkxXRNBDMQ/+Dbfr93o=; b=E22YYT4RL3hriZ/Dn8uOZl+NrR/lY/OyxYqxXJ6FNEqeKQ7+0tfZZjDzXj21+pBw6f GyhyR9MzX8Os4GOee2Oc6CNCVkSKKAo9vqUYiHWdYgZkzcGq9FRSEyQyX8x2EpuGEcOe McrsWxG2Cc3PzaTGLfvOxnNWowJx9aFYdQQM6CKWPDjZL6tcKXhpB2v4J29SntBYle05 BwLRl/7VyAdMLxnrd83OPk/DP2QGwtbZ+H41mdw1T4zrDc9k/8H41fTqAX7R1j39k8ld WgmWaWLd8qX28CajweOaCxxCclrsTOk5vxx05eh8k8LW2JPORz4Aw4838G4NNy4qe0vz Nkkg== X-Gm-Message-State: AC+VfDwzZEwwNR8Od28CzbkyW8NoVnks+IkmjEkwsuOXgWkS3rqGoGq8 Xq3JyArLxurCE7w+C4owQQZYa2gdo0ubXytO X-Received: by 2002:a17:903:32d1:b0:1ac:6b92:a775 with SMTP id i17-20020a17090332d100b001ac6b92a775mr4259202plr.6.1686104434650; Tue, 06 Jun 2023 19:20:34 -0700 (PDT) Received: from [127.0.0.1] ([2404:c140:1f03::caf2]) by smtp.gmail.com with ESMTPSA id z11-20020a1709028f8b00b001b1f991a4e2sm5689684plo.20.2023.06.06.19.20.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 06 Jun 2023 19:20:33 -0700 (PDT) Message-ID: <7a5e7377-4931-36e3-4102-8fcb1f7a81e8@gmail.com> Date: Wed, 7 Jun 2023 10:20:28 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH net] net: sched: fix possible refcount leak in tc_chain_tmplt_add() Content-Language: en-US To: Larysa Zaremba Cc: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <20230605070158.48403-1-hbh25y@gmail.com> From: Hangyu Hua In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, 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 On 6/6/2023 16:53, Larysa Zaremba wrote: > On Mon, Jun 05, 2023 at 03:01:58PM +0800, Hangyu Hua wrote: >> 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. >> > > Code seems reasonable. But commit message is pretty hard to understand. > Please, replace "corresponding" with "required". > Also change the first sentence, do not use "can". From what I see, successful > execution of tcf_proto_lookup_ops always means we now hold reference to module. > > CC me in v2, I'll give you Reviewed-by. > I apologize for my incorrect English expression. I will send a v2 later. Thanks, Hangyu >> 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 >> >>