Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp2127366rwi; Tue, 1 Nov 2022 04:17:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6ope49cxKT04Rye05usIzR4CUB9GAEotcVv70xGOzSmK84DUdF/HJS+E7EtfplJsmNh3mR X-Received: by 2002:a05:6402:42cf:b0:457:ae6f:e443 with SMTP id i15-20020a05640242cf00b00457ae6fe443mr18931760edc.299.1667301460642; Tue, 01 Nov 2022 04:17:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667301460; cv=none; d=google.com; s=arc-20160816; b=CBp6FspQKJ3LRFzgd7eDp0ZC6P4jbzdmYhWcrmmKaX2q5o5iqQjmOrL1QmsF9CgrTd lIM1I07pnAGxegNZITrR9sUI2OxfP6aE4VSPfZWcGkySkObxumxV48J2ktjPFwwKK/hz IZD9kdgdYyHGTr1BjPQecfqSVEOGcAa/oMlyzGm0Ac1ZGNKHFJM86Q6ITajJvTLTnhdi YV4NuivBrXmxMzvmRHRJhw42hUwZ5Za91BveE4JB5RtDCFu1UHi+b9M3NKSyyO2w2fUg 2VMb3W1liASth586+a73zQtYsl9YnTI6ponY5g9w2c4X0KkCydFJ7s3A+GIH5G5XOGg5 dDaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date; bh=65lB0E+dFmTRMLQdsgBE53wrWmYartPOG9PG5oIxkFE=; b=FCBpBNgQiV44wjNcBnAlU5LSikNUf3WdiNyC5qg2X2slMIy2FWO0Z+YuFyJdK6pj2+ YO1qx33kYCLxnUQWVzxMmALKqusdLr0dYSkHCexw2CJUiBHjpWiA2WOKaARidzjRm4BS jhxuZzQuZDbmmooIIZv+FSYUN5Wt9JuNC6cpJ2teU93qN4mQLKHGqS7kNHy9SEiHTTa1 EA8e7CfyK1sgsaTJyypTsJEC7JJQP2aHjp/4LPzLYSdfAd/KE0b2xQIDnnFuzcGqO3Dk SYMtN2MCKVvG4DAHZt2axmACIKNsaMMHquMqvzb8a0Ot/l5//2LUWJ319lENUeubkbi2 Nzmg== 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=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id he16-20020a1709073d9000b00782161b3422si13026791ejc.914.2022.11.01.04.17.17; Tue, 01 Nov 2022 04:17:40 -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=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230048AbiKALAa (ORCPT + 97 others); Tue, 1 Nov 2022 07:00:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230037AbiKALAX (ORCPT ); Tue, 1 Nov 2022 07:00:23 -0400 Received: from out30-133.freemail.mail.aliyun.com (out30-133.freemail.mail.aliyun.com [115.124.30.133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF4BE18E01; Tue, 1 Nov 2022 04:00:21 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045192;MF=tonylu@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0VThdbr7_1667300417; Received: from localhost(mailfrom:tonylu@linux.alibaba.com fp:SMTPD_---0VThdbr7_1667300417) by smtp.aliyun-inc.com; Tue, 01 Nov 2022 19:00:19 +0800 Date: Tue, 1 Nov 2022 19:00:14 +0800 From: Tony Lu To: Chen Zhongjin Cc: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, netdev@vger.kernel.org, kgraul@linux.ibm.com, wenjia@linux.ibm.com, jaka@linux.ibm.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, guvenc@linux.ibm.com Subject: Re: [PATCH] net/smc: Fix possible leaked pernet namespace in smc_init() Message-ID: Reply-To: Tony Lu References: <20221101093722.127223-1-chenzhongjin@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221101093722.127223-1-chenzhongjin@huawei.com> X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL 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 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. 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