Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6508028rwd; Mon, 5 Jun 2023 20:17:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7z3RXnn5rqHbRQSEx6RFvKNYKpOliaJsavBK8Vr4V+Z+axVdY4hgVOrAlejtMH+ppfuyJX X-Received: by 2002:a05:6a20:12c5:b0:111:c8a6:88ca with SMTP id v5-20020a056a2012c500b00111c8a688camr594426pzg.58.1686021444310; Mon, 05 Jun 2023 20:17:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686021444; cv=none; d=google.com; s=arc-20160816; b=IBZaYXahDjrF+lRc3Y0p6avAjX2dPLPYOagz+Mp54fRjpuF4yJzwRAVLjxZglJeZw7 T81k32g8DJcvRzpoPDZ57Fay8qwclnWYGOzkermTzx2zuRDnBTmd2Hu32MOWJ2hMkT+i rfC+JP1KsVYjIgGz/c9dP70Lp1Q/xtf8joppnWEMEYxPBBXIfVugZf3Etj6cYupZ1UbD 5ieM4deyM8LHjNxowmrx9Rg8w6j6SFxRVFR4BWeKfb4gE08mQODxmPj6NpWpqMM53wmf zyZmozqul7gADLmqQzn+D/Bs7ebROVhlTKot1rPM1zWPZAl/F3XkdTkWY1Gy+IsZuGv7 2X3Q== 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 :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=GK3SH+ZRgMM3hnQg2lJiFOx+Ehf48Mzwt4h/2p4dLtA=; b=HSomAalGcTmmPT00leQEzpGvEPxC3QA2/6AhcJF1pI/jw0Pa3BuILKFD3ieSu1VH8D U54NSRE0dZ1bKT4akNdU86Q3v6ubSCTk7kumuU6UAF/y0NJZJTadQJA8DJTvyRO8L8L3 K9XoQbgDUD26uRQ9hlZy4BrHNjzTwf472aosxmiI42dC09xxigf4RRnncnOCbVDfI1Xh J/iMVNAvo/Osy40YAYHCMaYILJ0RZk4apC7ueFUE2nBe92R1FFKGAQNTgRtVJNwhDV7r KEnFLKlzHwI+UhTPGRvMOqNJy2xFWNXPxrt63LflBe9gJzEeInplg0vX0ln3YHysDr4q Fg+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=od6j8MHi; 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 j17-20020a170902da9100b001a6e98a5f21si6701881plx.586.2023.06.05.20.17.10; Mon, 05 Jun 2023 20:17:24 -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=od6j8MHi; 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 S230212AbjFFCOG (ORCPT + 99 others); Mon, 5 Jun 2023 22:14:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231836AbjFFCOC (ORCPT ); Mon, 5 Jun 2023 22:14:02 -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 85EBC11D; Mon, 5 Jun 2023 19:13:53 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id 41be03b00d2f7-5429d91efc2so549757a12.0; Mon, 05 Jun 2023 19:13:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686017633; x=1688609633; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=GK3SH+ZRgMM3hnQg2lJiFOx+Ehf48Mzwt4h/2p4dLtA=; b=od6j8MHiM34MxiAmu/7VpTdynYLAAW+dMGjCcMBFWgPNRZKANQ64sDInmd3TM8FHX+ +aHwrfDrm9mPt/VGJRnjKe7u2zonavLCUhZbuVWdov5BnAQ7TbpmNLsHx7UIOLtu9edy Wj80xJuJFpWQYKsb6uYiZRiCuS3I/vgYSoofBRhbc0rgfxnxO2XEwBaMaXVhhz81jQZv ZEXgNe1cu/QI77ritG/hM3R2Ict2mRyzes1QZ4MFg5m8rSPpzv4D7DdRHG79h22eczGN FTAHrig4R6hA5Fwu+fRuQHGm5n6E0ie0drKGfFmTIr+4dQ1zuhOX2bSxC5+JF+babEI/ XL+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686017633; x=1688609633; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GK3SH+ZRgMM3hnQg2lJiFOx+Ehf48Mzwt4h/2p4dLtA=; b=Z1Tbr5dbaYKWS0nwpqHtzpLDK6/DnJyFUP0kJtia9gJDh1mAkFfSScQnNXOKpGanyb kvt4E1PqyXZo7o7j6A87ywCnYpQW9ZN4X1Z8cb4qJ1KVOg8HsvedbMyYJs18ZSiabT3v YAbIeAV1ITSTEQ9K+/ljRwmeoGd4h0wt+T8xovmWnXgPknPjl5TM2CboxVuCrTBIqvux pzHuT7Ly2ooD0lVVc/S4PDupGf4xVhpJSXtDEE0DBqDLKxK8gN1O3VHUyYLyF/IEK4kk /X8M0fDgx3KWnHzlJYrlDCCspQDxYlUwb3lS9AdqToTKe8LtZuE17v2l90eTvhG+jix0 NSOw== X-Gm-Message-State: AC+VfDyVbRF8DmNx5wxOECP4FDaMo0MQ+nY4xpm4ELq5mpFixflqu2j6 1y1yU6BF3YgGkg91Y53NwJg= X-Received: by 2002:a17:902:e751:b0:1ae:1364:6086 with SMTP id p17-20020a170902e75100b001ae13646086mr923553plf.2.1686017632804; Mon, 05 Jun 2023 19:13:52 -0700 (PDT) Received: from [127.0.0.1] ([2404:c140:1f03::caf2]) by smtp.gmail.com with ESMTPSA id u10-20020a170902e80a00b001aadd0d7364sm7225788plg.83.2023.06.05.19.13.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Jun 2023 19:13:52 -0700 (PDT) Message-ID: <1626a8b8-ae7a-a110-44a1-24c8f600822a@gmail.com> Date: Tue, 6 Jun 2023 10:13:44 +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() To: Simon Horman 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> Content-Language: en-US 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 5/6/2023 20:31, Simon Horman 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. > > Hi Hangyu Hua, > > Is this correct even if try_module_get() is > not called via tcf_proto_lookup_ops() ? > tcf_proto_lookup_ops will return error if try_module_get() is not called in tcf_proto_lookup_ops(). I am not sure what you mean? 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 >> >>