Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp613339ybe; Thu, 19 Sep 2019 00:34:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqyvLpP3Qoq/ZinSdNfdGJ99Bm9i6v6Rm3PQjOJQzmYOAlzPjSbziLQ2rcwkj5p/An0fvTow X-Received: by 2002:aa7:d1d3:: with SMTP id g19mr14306009edp.150.1568878477350; Thu, 19 Sep 2019 00:34:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568878477; cv=none; d=google.com; s=arc-20160816; b=OktMsh3KZZa/Advpz0/xR+3x7YNqbwNtxJTYSgT/f7dE4lBEZKhub56j4eDdBD+VIj VggwOyDvAVrsTJnAUBZ0p7oGVyYyADfiV4P8gkCxS5vvA3g+VwtwKEMZpkbSUwkB4XFU Jy3OwoMvLL5TQnuD8HE0A31ZgcfXxRooUsTr72c1xwb2risVtgu3zS6Vh0Tn/4xLeFfN M+Ppi+LJwFDzif49RxS1IU373XZqdSV8+JIBRx7x+FjA0EOqx+ecai3upWU8BU7flCLv rVZtCremUqJGHUw2f/SFCdO65GzAIAyuA6Z4OSKZmcu/evL0NtVPKKqaBDROmzxrb4sw Ollw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=K0Pdm19h+WxJBAb41zrOGHo7jie6MAl/vBdIbrxvfzA=; b=uYImTfh0hi637vmVc9IORQ1GQRCYLqIcHEuVXMwnwLd9705U3FlP0jYM1DM/IQIxjg YfTP4INd2Yr+7teVPzKXkxIITNubVpAnRLTEEBP760X1LNYG6hRDCNfJcnkxD78vQj3i IOTUBum8IFW6/MvNkekN0/hq1pmV+mOAFlUcLUr7f8pELk2KOWoYPygJwrBLOV6L666O GmRHWRKUp2rNA+x1MetyC9uWde/wO68G6OO520MrC/uOUQf0PtZmXsOP8EHmTp3a3nS3 4wrcUKByzGb3lfvKNMqB1wX1wR3gRzn7mlvwy+SKVMkp6drPkoIrX7VFBQs+d2j2Bodo cNvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MBj1OhUS; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o49si4897631edc.261.2019.09.19.00.34.01; Thu, 19 Sep 2019 00:34:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MBj1OhUS; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387468AbfISGgT (ORCPT + 99 others); Thu, 19 Sep 2019 02:36:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:35370 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725320AbfISGgS (ORCPT ); Thu, 19 Sep 2019 02:36:18 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 840D0218AF; Thu, 19 Sep 2019 06:36:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568874978; bh=kLqycoBe8uV8E2knqmFJ1o58JmJlygAiwWJwYCZe3u4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MBj1OhUSqRr3IZoLYSeHbj1Qf6DNpVP0GFMSepJmowWR/fpbYu+KDjGnM8GDDFTwT C2wlqJBLS12ZilvPdqSYpw/TpurkUrYrG9oTs+V1gQ691DjUUdUPbQSBM+ZbNzA0NC 3jOV/vXTS9pdhd4wf6ILs7cuvS20g5fiiHPm20xw= Date: Thu, 19 Sep 2019 08:36:15 +0200 From: Greg KH To: Xiaoming Ni Cc: akpm@linux-foundation.org, vvs@virtuozzo.com, torvalds@linux-foundation.org, adobriyan@gmail.com, anna.schumaker@netapp.com, arjan@linux.intel.com, bfields@fieldses.org, chuck.lever@oracle.com, davem@davemloft.net, jlayton@kernel.org, luto@kernel.org, mingo@kernel.org, Nadia.Derbey@bull.net, paulmck@linux.vnet.ibm.com, semen.protsenko@linaro.org, stern@rowland.harvard.edu, tglx@linutronix.de, trond.myklebust@hammerspace.com, viresh.kumar@linaro.org, stable@kernel.org, dylix.dailei@huawei.com, yuehaibing@huawei.com, linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH v4 1/3] kernel/notifier.c: intercepting duplicate registrations to avoid infinite loops Message-ID: <20190919063615.GA2069346@kroah.com> References: <1568861888-34045-1-git-send-email-nixiaoming@huawei.com> <1568861888-34045-2-git-send-email-nixiaoming@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1568861888-34045-2-git-send-email-nixiaoming@huawei.com> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Thu, Sep 19, 2019 at 10:58:06AM +0800, Xiaoming Ni wrote: > Registering the same notifier to a hook repeatedly can cause the hook > list to form a ring or lose other members of the list. > > case1: An infinite loop in notifier_chain_register() can cause soft lockup > atomic_notifier_chain_register(&test_notifier_list, &test1); > atomic_notifier_chain_register(&test_notifier_list, &test1); > atomic_notifier_chain_register(&test_notifier_list, &test2); > > case2: An infinite loop in notifier_chain_register() can cause soft lockup > atomic_notifier_chain_register(&test_notifier_list, &test1); > atomic_notifier_chain_register(&test_notifier_list, &test1); > atomic_notifier_call_chain(&test_notifier_list, 0, NULL); > > case3: lose other hook test2 > atomic_notifier_chain_register(&test_notifier_list, &test1); > atomic_notifier_chain_register(&test_notifier_list, &test2); > atomic_notifier_chain_register(&test_notifier_list, &test1); > > case4: Unregister returns 0, but the hook is still in the linked list, > and it is not really registered. If you call notifier_call_chain > after ko is unloaded, it will trigger oops. > > If the system is configured with softlockup_panic and the same > hook is repeatedly registered on the panic_notifier_list, it > will cause a loop panic. > > Add a check in notifier_chain_register(), > Intercepting duplicate registrations to avoid infinite loops > > Signed-off-by: Xiaoming Ni > Reviewed-by: Vasily Averin > --- > kernel/notifier.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read: https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html for how to do this properly. Same thing goes for all of the patches in this series. thanks, greg k-h