Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp1824409imc; Tue, 12 Mar 2019 01:07:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqxoamYwsGjeXwVVOawyjDjoyXqFzmI3ttNgyH4Optedjjv8JDTsw1unCwUPlUSeRFhiEVXR X-Received: by 2002:a63:f556:: with SMTP id e22mr33991346pgk.321.1552378041206; Tue, 12 Mar 2019 01:07:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552378041; cv=none; d=google.com; s=arc-20160816; b=UnB9XcapAQPLGiwlUOvoL44L5T8n0OhGQaoFF3BVxg40DXlVx1/1sYI8XtW1coidz2 i/GdT2pkhGZ3oK68PjWwpGDz+yj4FgQqJRWLKx20JJWPGGfUgBjfNPwXTVa25SVlGQGg PxHJE0ldKEK8/juO52aV5i1H05pFwjSyVFADiRvi86X5YrVFpxes78iDhPOQ+5B6UIG3 +39mpZlMUeAjH8HAyRP8DkzvRdAiOThPqQD4fcMcXl7uI3jHIPiahY4fEZ+XpinpG0uW sHJWVAc2Tn97BS9g7fhz/tO7r+lYmjrL59lFfPPZo4N9L+EcUGCye1nTWtLRpGKti5e3 ijyg== 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:mime-version:user-agent:date:message-id:to:subject :from; bh=bbxzPixULBnGKkgfKpIZFmKWPRqjVIIq3RnmMiVrix4=; b=Ifi8JaC4ZgtQuO9SEk4y3HNc0jgwGm3HIgrPtrzRbW1yupKc2A8cX19rZ3UBesRIcV UzyQSAm1DpuPxmtFoVHHhGn6jLirKyMONu2HjUKoVl2TjQSK5YgUI7/kW8tootJbg8sq hGRfUb/3BPxOWt88coAMaFzY9SIsJqttJLgqASZP5eOkG+fzEwEjXrr9+jdExpnoKFU0 u613SgubJp6V47wZk8m33yQQyDsRnpCStZxCKprIrYy+fyy3KS5ExwYUttd2dWik4ljf sBKq0iqjCFkfY9TT6SUOOFTyOXYbvkDqaX4KCuvcGWZXdVTFba5ZTTGA34zW+JH42xUw G6bA== 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 e5si7686051plb.426.2019.03.12.01.07.05; Tue, 12 Mar 2019 01:07:21 -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 S1727246AbfCLIGj (ORCPT + 99 others); Tue, 12 Mar 2019 04:06:39 -0400 Received: from relay.sw.ru ([185.231.240.75]:52928 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726633AbfCLIGj (ORCPT ); Tue, 12 Mar 2019 04:06:39 -0400 Received: from [172.16.24.21] by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1h3cQj-0003BY-8R; Tue, 12 Mar 2019 11:06:33 +0300 From: Vasily Averin Subject: [PATCH] notifiers: double register detection To: linux-kernel@vger.kernel.org, Andrew Morton Message-ID: <04127e71-4782-9bbb-fe5a-7c01e93a99b0@virtuozzo.com> Date: Tue, 12 Mar 2019 11:06:32 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 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 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); -- 2.17.1