Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp1834505imc; Tue, 12 Mar 2019 01:22:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqzsE7bKOuwIanxD6RRytfLWxlDxwoYMrj3uIMoVeIXLoV/asa1YMwdQnSznWnIg8UdpcjA4 X-Received: by 2002:a63:d5f:: with SMTP id 31mr33777613pgn.274.1552378976036; Tue, 12 Mar 2019 01:22:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552378976; cv=none; d=google.com; s=arc-20160816; b=c2rcWCBb4RaBCDuS/JOU/iPBf3qETGaWcS94fNPdHANtoHc4bvNaMXdJ2DycYF4sZy XjrKt+8VBA4E0G7u1c0fJgQvzh9hoP6zFEIY0KcQiZb9fXuGdkGzHdYGfZoV4zitA5iY VWtqEcH+inTdO1BJb9uSqJf3b1zyzt5x9LQ8AYx5v1sWDG8pxp2ajX1GvNHE1wcCXBtz KvBTXPYjOGTG5K2dujefeUHi/haAVCRwMs3Ln8NNHpIGgGqq0SW6xjJNaXhMNm7gitKK +qbV/A/306g+PrTFdKAYleARZqPPGjl1KL8GkB4yX6K05WFSOcoN8XMtZFJMH3CP1s8d QcAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject; bh=NRRvsi/T3rIM7mdr30xH/44ZcdtLZz3erFoR3ibxrV8=; b=GPz2MuxsBBD9sDUfUrcgRfPVfPXn1bzpPCT91/K3imz6N8vlF0MuUZlQ10XmWkBarG BL+0T/t8A2pJfvj69+xSLJpz8PtwCIKE4mb2r4d1bkFzZndvOVP3guxlBtNpR3Q8TPkh 5/xjmwdcWWGIn61RBH4xc44JC1TA/rbwhNuE1zzzXeoAoKdDJDVQbSxRuVUb6rFUWLLW aMxaR9iWq1kXT+o3Tl7t4VYNGSzNrgzpPWQPPCN4FHNUKdydU6OAw6mQ94NiOWeAM3UX WtuhOl6GGUbj4b0OFDhU1ZRhflCWCoW2LBLhpohzgb7TMVgwKqtYFPWfzx1zS7SN7jQa /mDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x8si7287620pll.101.2019.03.12.01.22.40; Tue, 12 Mar 2019 01:22:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727593AbfCLIUq (ORCPT + 99 others); Tue, 12 Mar 2019 04:20:46 -0400 Received: from relay.sw.ru ([185.231.240.75]:53370 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726724AbfCLIUn (ORCPT ); Tue, 12 Mar 2019 04:20:43 -0400 Received: from [172.16.24.21] by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1h3ceO-0003FS-Fi; Tue, 12 Mar 2019 11:20:40 +0300 Subject: Re: [PATCH] notifiers: double register detection To: linux-kernel@vger.kernel.org, Andrew Morton References: <04127e71-4782-9bbb-fe5a-7c01e93a99b0@virtuozzo.com> From: Vasily Averin Message-ID: <70db0274-2dfc-8cd1-9e0b-74e035a089d6@virtuozzo.com> Date: Tue, 12 Mar 2019 11:20:40 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <04127e71-4782-9bbb-fe5a-7c01e93a99b0@virtuozzo.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dear Andrew, could you please pick up this patch? Few years ago I investigated described problem, host was cycled because of notifier's list corruption. I've prepared this patch applied it to OpenVZ kernel and sent this patch first time, but nobody commented it. Later it helped us to detect similar problem on OpenVz kernel. Mistakes with notifiers register can happen for example during subsystem initilazation from different namespaces, or because of lost unregister in roll-back path on initialization failures. Thank you, Vasily Averin On 3/12/19 11:06 AM, Vasily Averin wrote: > By design notifiers can be registerd once only, > 2nd register attempt called by mistake silently corrupts notifiers list. > > Proposed check cannot prevent described problem, > however it allows to detect its reason quickly without coredump analyze. > > 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 6196af8a8223..bfc95b3e4235 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_ONCE(((*nl) == n), "double register detected"); > if (n->priority > (*nl)->priority) > break; > nl = &((*nl)->next); >