Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp2175820rwi; Tue, 1 Nov 2022 04:56:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4rasV3Wln90tSqpSUb8FXplsX9+boFg9BSs7RcJnmWyKpEXMKzeuzTvk6b8q0W76RAisls X-Received: by 2002:a17:907:d22:b0:78e:2788:51ae with SMTP id gn34-20020a1709070d2200b0078e278851aemr17306067ejc.689.1667303775789; Tue, 01 Nov 2022 04:56:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667303775; cv=none; d=google.com; s=arc-20160816; b=EpRFmwcNPv2oDLuTVWdcvFBAaV08P0ZU3qX7JYt/yNrvxqAdGSaOkqFsWol3jZQgjA dYyR1rl92yR1Mpn4CVqwv+JPu76yvEml82ZsRetMv79yHPwGJGkUkJUFMVvN7kSmob3u oH3whjyOVKHL+M614LnwGUE18Kcbw4ek+AAyC7i16BcpdWuxR6vELD+Dt5GU/pM0a0+Y KdbzVl/nv+qlDU/G6DUVX9N+gk4a0VCa9W+l+eR/oq+JA4/u+HDGNIyW88ecel7dDIPa pssAiUonRoJ6tLQLkO0DcTnhQknA/ar0ERP0+48QZ8qhPD9xVU3T5hL50M8YgZu4+ERE x/Jw== 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; bh=mJnBwIIXSIHt8ZCT1Ujyp9a0srOWOfAIz3yibqJj+3U=; b=XAaqeo2biXkHHJ91EU1SikYlzniAJSgOLJIzwZSmrOT6tW8TsbYAhTy1UHxGyUE0lD UdCz9iLzOLjaxuiRfozJHRXxuYRSRN1T+lPJEGYJ+95YA+eexrx1iJYKS+1QTL0RF7wI THeNjTBXhNZ7wZXoD2ydWXXtmJf3lZcTg4bEHagoGcMfOzkKADvUY0rsTmQTjKsbOuB0 z+8+XsFFqoNDHtxEsWolOMiW4hkfI84MA4BKSudyVI2J96Y8iQGgcEkmA9jJ//SgExO6 O+xc3FQUuv3Y/8pvDoH/brefTpV53t/QYKY5JbbVHRb/oD35tN01w5Ivq0jvhostepGv m5kQ== ARC-Authentication-Results: i=1; mx.google.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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o7-20020a056402038700b0045cc36d6d8fsi8883613edv.336.2022.11.01.04.55.52; Tue, 01 Nov 2022 04:56:15 -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; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230086AbiKALHW (ORCPT + 97 others); Tue, 1 Nov 2022 07:07:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229475AbiKALHU (ORCPT ); Tue, 1 Nov 2022 07:07:20 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E71DC18E23; Tue, 1 Nov 2022 04:07:14 -0700 (PDT) Received: from dggpemm500023.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4N1nKT3ccCzmVZB; Tue, 1 Nov 2022 19:07:09 +0800 (CST) Received: from dggpemm500013.china.huawei.com (7.185.36.172) by dggpemm500023.china.huawei.com (7.185.36.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 1 Nov 2022 19:07:12 +0800 Received: from [10.67.108.67] (10.67.108.67) by dggpemm500013.china.huawei.com (7.185.36.172) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 1 Nov 2022 19:07:11 +0800 Message-ID: <210a2edd-8238-173f-9733-6f92289b7e09@huawei.com> Date: Tue, 1 Nov 2022 19:07:11 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.0 Subject: Re: [PATCH] net/smc: Fix possible leaked pernet namespace in smc_init() Content-Language: en-US To: Tony Lu CC: , , , , , , , , , , References: <20221101093722.127223-1-chenzhongjin@huawei.com> From: Chen Zhongjin In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.108.67] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500013.china.huawei.com (7.185.36.172) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS 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 Hi, On 2022/11/1 19:00, Tony Lu wrote: > On Tue, Nov 01, 2022 at 05:37:22PM +0800, Chen Zhongjin wrote: >> In smc_init(), register_pernet_subsys(&smc_net_stat_ops) is called >> without any error handling. >> If it fails, registering of &smc_net_ops won't be reverted. >> And if smc_nl_init() fails, &smc_net_stat_ops itself won't be reverted. >> >> This leaves wild ops in subsystem linkedlist and when another module >> tries to call register_pernet_operations() it triggers page fault: >> >> BUG: unable to handle page fault for address: fffffbfff81b964c >> RIP: 0010:register_pernet_operations+0x1b9/0x5f0 >> Call Trace: >> >> register_pernet_subsys+0x29/0x40 >> ebtables_init+0x58/0x1000 [ebtables] >> ... >> >> Fixes: 194730a9beb5 ("net/smc: Make SMC statistics network namespace aware") >> Signed-off-by: Chen Zhongjin > This patch looks good to me. > > The subject of this patch should be in net, the prefix tag is missed. Thanks for review and remind! I will add net tag for the next time I send patch to netdev. Best, Chen > > Reviewed-by: Tony Lu > >> --- >> net/smc/af_smc.c | 6 ++++-- >> 1 file changed, 4 insertions(+), 2 deletions(-) >> >> diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c >> index 3ccbf3c201cd..e12d4fa5aece 100644 >> --- a/net/smc/af_smc.c >> +++ b/net/smc/af_smc.c >> @@ -3380,14 +3380,14 @@ static int __init smc_init(void) >> >> rc = register_pernet_subsys(&smc_net_stat_ops); >> if (rc) >> - return rc; >> + goto out_pernet_subsys; >> >> smc_ism_init(); >> smc_clc_init(); >> >> rc = smc_nl_init(); >> if (rc) >> - goto out_pernet_subsys; >> + goto out_pernet_subsys_stat; >> >> rc = smc_pnet_init(); >> if (rc) >> @@ -3480,6 +3480,8 @@ static int __init smc_init(void) >> smc_pnet_exit(); >> out_nl: >> smc_nl_exit(); >> +out_pernet_subsys_stat: >> + unregister_pernet_subsys(&smc_net_stat_ops); >> out_pernet_subsys: >> unregister_pernet_subsys(&smc_net_ops); >> >> -- >> 2.17.1