Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5560797rwd; Mon, 5 Jun 2023 05:37:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7P7rFVokI6Km4rcLYLG5vBpU+XfJrCJe+UPvIItmS9kbnoObpN5gjkZHtF10rmLI7cE7oD X-Received: by 2002:a17:902:8f91:b0:1b1:9272:5610 with SMTP id z17-20020a1709028f9100b001b192725610mr2772979plo.47.1685968662280; Mon, 05 Jun 2023 05:37:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1685968662; cv=pass; d=google.com; s=arc-20160816; b=u4xQRtKXHwngAlD3qkuucPe0JFRCCQFRuSdmcSJzVC6P3eEikbQQA3DhgxILVyRxON /mYl0Me3NAAbLbvLlxM4n/LVnApruZCg2jXF0B0hl7G3QIR7+LUetrw2LW4VkbQaFmUL DBZqvRioCTMk8ABmXuv9XKAGkYiMU52/XTEWUBuwflp5tjsGJldoFItVeDRIqwdPxat2 GMZZjUAyfIRUjyGp8B/L/SfmXyfQLgPB6DzWPO3eYEI/gYaP1Z4yD75GvEC5+8odH1By UpboF9XSfG+KkpZtZLUjpc9a7LvZd9fgft5BLlexpHlIhpl+65lVr7Rov5rsh/dCfIFk VRYw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to:content-disposition :references:message-id:subject:cc:to:from:date:dkim-signature; bh=U3rJmQT2uF6sKRJDtWw461Yw1/3fF+neaCR9O/RzZ8s=; b=gnAEURcoathkY3nYXFfNCmOcczU6+veTGUWcDE3IKSYCSWn6t+fwlvyEslWlM2vzPo By6oMVFSzWuI3yI1lFqXhgjARLFIH/36faiO3ZiPkN5+5YgRMQ2Ffo742bAjYoeqh92b 2dOZiBYSgtG4Ia3zYJ8UYFrdZ2WZYA6xeyhyLIjkB38v/hemNRdabqgPzEfo7qRkLZcg UYzw6BGg79CK7v4HUjgtZLywt5aAQOihSrcDDtL+cCBnM4uWjrWcQpxc62xu6zqDpIpZ A4p+FJA3nGFJX+4UTeXsttC1L6T+48fQ47F1sNcxEyAj/dKelVfzo0VlpEXO5N2ZZfeD iDIg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@corigine.onmicrosoft.com header.s=selector2-corigine-onmicrosoft-com header.b=cGRcRMKa; arc=pass (i=1 spf=pass spfdomain=corigine.com dkim=pass dkdomain=corigine.com dmarc=pass fromdomain=corigine.com); 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=fail (p=NONE sp=NONE dis=NONE) header.from=corigine.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j16-20020a170902da9000b001ac671a8fd3si5579534plx.110.2023.06.05.05.37.30; Mon, 05 Jun 2023 05:37:42 -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=@corigine.onmicrosoft.com header.s=selector2-corigine-onmicrosoft-com header.b=cGRcRMKa; arc=pass (i=1 spf=pass spfdomain=corigine.com dkim=pass dkdomain=corigine.com dmarc=pass fromdomain=corigine.com); 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=fail (p=NONE sp=NONE dis=NONE) header.from=corigine.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233504AbjFEMdh (ORCPT + 99 others); Mon, 5 Jun 2023 08:33:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233516AbjFEMdV (ORCPT ); Mon, 5 Jun 2023 08:33:21 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2122.outbound.protection.outlook.com [40.107.93.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38137E54; Mon, 5 Jun 2023 05:32:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Au9wAX5I+m7OsgPEQ0e+H2q4cZhXb7jI0/c7Q6a0CvFL5wT3DnvcGp5Dd3r+fEPBa8XxWN+/mXHARpsYyzvU298uq/leqi4o70KYwLH8nA9P0tIqCT6QczMpVkV0PDt1qSNCE9iZJ50OykUjOUyoKxZkBfyBxMaADYD1+pD5UidR3sgLkdENJ1L1vEdDDouQCwrrnsutUXZXg2Ew+JaQUtpixHJrlEEmYUV6OrTZPwBkYySmoGXK0OVJ/QievQXaJeJ5Gx0rS7aRl2x14TplKqs0Wb2r78OT+oSmfvhWWiApZCaDXmCJBNBSgAthKAR/yLO/Es62//mFDnwzF8Qvlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=U3rJmQT2uF6sKRJDtWw461Yw1/3fF+neaCR9O/RzZ8s=; b=dzGCMO7mEO0bo2ipeTh0+fPbR8mYc2zASKDWUBpkTEbWHKy60FeJZ6LedRY6g8TY3uB0EUnhEkCKDL6yF6hrUN3Cz1RsG3G759Hj1OE3x4pu7b19CHE0lEHlzTngIC9EkqLIaRJdQOWgDay+b4tMVZIrEKbc4/8jG2kxT4DSW6GlBNABi1Hd/5EvI5OqJ2r5XV8gc58xb9WKEs4v21vEiar7AK9JrdJFWZ6P8with7/ZfCD8SnAyJVN/9iPe58FiZmM4eFRPKT8oXB46Oiyd4DDx2QB/d+IJwufRrhzPGsCkY4xnV+e5sK+WW08KUMKPCXPmP1eHXr1LQhCq5SuaAg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=U3rJmQT2uF6sKRJDtWw461Yw1/3fF+neaCR9O/RzZ8s=; b=cGRcRMKaSmtMlSTBYKEU1vyI+YwudtYctt7VQa6cOVPFO/jnVXY7/AjVAGy+OqUupJPL3eT3nVqADR7UjZn3I1Yv6qac7xzP9gcqZyZ3F4f1sLkvCV3KmhwDq+zGWl3kZhGlK+fNGuyzlw8fZ15drR35B0wsKEYYpVKwvUig9QY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by BY3PR13MB4994.namprd13.prod.outlook.com (2603:10b6:a03:357::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Mon, 5 Jun 2023 12:31:17 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::5e55:9a39:751f:55f6]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::5e55:9a39:751f:55f6%3]) with mapi id 15.20.6455.030; Mon, 5 Jun 2023 12:31:17 +0000 Date: Mon, 5 Jun 2023 14:31:10 +0200 From: Simon Horman To: Hangyu Hua 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 Subject: Re: [PATCH net] net: sched: fix possible refcount leak in tc_chain_tmplt_add() Message-ID: References: <20230605070158.48403-1-hbh25y@gmail.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230605070158.48403-1-hbh25y@gmail.com> X-ClientProxiedBy: AM3PR03CA0058.eurprd03.prod.outlook.com (2603:10a6:207:5::16) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR13MB4842:EE_|BY3PR13MB4994:EE_ X-MS-Office365-Filtering-Correlation-Id: 6935f668-0e19-4874-84e3-08db65c0c230 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: C4lGDlYppWH2pN19/RtwlVfLpgYce3bnHVOX4Uoi4322rdaSqjldzw9KydgfREU9zsVKkjL6n4oufsGW0r+ZPDKAJUXvJiF6kaILqEK34VtRODvOhj97kVJfvliUbqpwWoIfTX70tlqDoI9c9O2HlkQslyxRk2DY1viSc1qkOoVPRca1xqKtXdNLGExKwgXbPb7YzenNo+O00cKBxU2k9o8QkoEmqKkHd+NtrMDa9E74rvkSdB7c8pH63gWxbhKsmZxoidtozw5q+FFbbnb+QtmX80RSH+xKRK/Mha/mpLWg8HVPNJkmYF854Oosa4SDk9aZ5HEfy0rJ7EBKWfAFInbImK8r5MW7Ip2VXADXrsrVy88YcRCxb8yK8u3goDnC7lEEnOZhsYyTIaKbF++dPfW5bz2xCnO2POH5pTggWDuH/wR0jXw8v2u2wghIhZQxWfHCgVoTtQejyquc31zV6oxcOi9WU4mgYEdairTBNTHIPM8oyfXIefq4nzag/2NFXbpZnGUrd5OUuYSgaRVYA9Jky/YB8jT3t8r8O7AJZciyB1GQilUcNwwbMW+Wo+fj X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR13MB4842.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(136003)(366004)(39840400004)(396003)(376002)(346002)(451199021)(6512007)(6506007)(36756003)(86362001)(38100700002)(186003)(2616005)(41300700001)(44832011)(2906002)(478600001)(66946007)(66476007)(6916009)(4326008)(8936002)(8676002)(316002)(66556008)(5660300002)(7416002)(6486002)(6666004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Ftx7E8j6wPNRXQubYYf2d0ZrYRGfE0vwQnsuXV7bI5sLxOh9k8xUdKt8p+Jc?= =?us-ascii?Q?sNzHb5mJFPRGG/wKF0qmvq3duGf/0/s4T05lw+ihsMp0cnSoMeXXzyy52z7F?= =?us-ascii?Q?k2JpwkZx6m7QVyT0EIJWnxnEdWfJ5U4HgbEXY7/8h+FrP+WaUL364holPCFS?= =?us-ascii?Q?Ob4/1NnlvwE8EsF8YIfSnajakpP3QUk28LHzE1QGMo8ewgx/XPStSFkIetk6?= =?us-ascii?Q?V2IHgLWsPSlwFCdlpDUNgbVauaGy+9iK/AWMCfTDfJPaW2kJta4ZY6cM3aek?= =?us-ascii?Q?7QncwGlKP2jnw31MYUBesDlFPwmRR7tI/uS0jY3QrxwhaVnIGD3ahgCyLcH3?= =?us-ascii?Q?mDhUcmSYhRsRd81LwrcrE09dTVuxb1zUVZo1dH324vq9FUf4NNzfYpn9oVz0?= =?us-ascii?Q?0TP4jaQvFmPfEdqDhsqu4+an5xSfnqShSU1RPBJX52NZPeQz7g/q7A3WzGlO?= =?us-ascii?Q?6tj6xgF4YothDPAGiiS+JuHnptUqibcAOmHdnOgiIKGgF3AatQ1FeJrNg2NO?= =?us-ascii?Q?W2DPj3+CkRnId4S9e+mm8ZnGV7lJ8EtOvhofuv7rYXppB7Fs/Ad44NZIvqj6?= =?us-ascii?Q?O6xh52hNcw+FqYvawLFV5oBZbP/d2fKo3nxyZv0wkc+XVPvTOp0A+7cQ9f8y?= =?us-ascii?Q?qi4TXnmEm+6gmGZ8uHk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?Q?tsyHF14li5fL+F766CHqsTVVd8npeJB66VxZW/2lV+5B9SuT1pIZxzq3y/7N?= =?us-ascii?Q?8dVmy1Jy+sSsaRkShFgqs4l/jWdYpk9a9irbagRZTT9v/zLXgAxsy6+30Lje?= =?us-ascii?Q?N0WfdA=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6935f668-0e19-4874-84e3-08db65c0c230 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2023 12:31:17.1282 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: A7Ukbg8pV9xGlP0Rpo3rVvzBMj1y/Op2HLYMKyxpmGU0Ntsw9e9H8mEHNTMiJDDFL8KFp/gdKnjBWO7qjf9W9UZmIU5LF29dElzQqc04RkI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY3PR13MB4994 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 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() ? > 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 > >