Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964985AbcJ0OBj (ORCPT ); Thu, 27 Oct 2016 10:01:39 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:31885 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933084AbcJ0OBe (ORCPT ); Thu, 27 Oct 2016 10:01:34 -0400 Subject: Re: [PATCH 2/2] notifiers: double register detection To: linux-kernel@vger.kernel.org, Andrew Morton References: <105a9bce-5539-73f1-2683-e52dba870c04@virtuozzo.com> From: Vasily Averin Message-ID: <702f88ae-1610-48b8-7adf-b43cbfb7f6f9@virtuozzo.com> Date: Thu, 27 Oct 2016 13:44:49 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <105a9bce-5539-73f1-2683-e52dba870c04@virtuozzo.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1001 Lines: 30 Dear Andrew, could you please pick up this patch? It helps to detect double register of the same notifiers. This kind of problem can lead to unexpected failures (some notifiers can be not called), endless cycles, memory corruption or crashes. Initially I've found such cases in OpenVZ kernels in our custom code, then found similar bug in mainline nfsd (commit 1eca45f8) On 21.09.2016 15:33, Vasily Averin wrote: > WARN_ON should help to detect double register of the same notifiers > > Signed-off-by: Vasily Averin > --- > kernel/notifier.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/kernel/notifier.c b/kernel/notifier.c > index fd2c9ac..e02b2f0 100644 > --- a/kernel/notifier.c > +++ b/kernel/notifier.c > @@ -22,6 +22,7 @@ static int notifier_chain_register(struct notifier_block **nl, > struct notifier_block *n) > { > while ((*nl) != NULL) { > + WARN_ON((*nl) == n); > if (n->priority > (*nl)->priority) > break; > nl = &((*nl)->next); >