From patchwork Wed Jul 31 15:23:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 170140 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp4163991ile; Wed, 31 Jul 2019 08:23:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqx7guZXC7+1f9qiw7bOupbwVtSyllb0JLszu5M29l3LEUGzGXy942eIHfn1uoYWMgeem36J X-Received: by 2002:a62:b615:: with SMTP id j21mr46802908pff.190.1564586588614; Wed, 31 Jul 2019 08:23:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564586588; cv=none; d=google.com; s=arc-20160816; b=X7RltD6UTMT0I8rXD7f9UDqt+OmhzcZ317lChJaAxkzyU+bGfoD7d0mu/xhok+5wPF +aw6PUG8lbfIR2omGKMThCidpwWbjkSRSA5ahhYFPLr17mtoc08F2n2URsCOlMxNxP64 /4qEALtxgwWDAfQAJvY4UPdMCcOFJxqgu0EhiZL9BSFFiC8XuEaSJaaz7FMDz5Lxr0Ld Fp1agkCmfjnsFKz7MpfYxTmSUeUAX4n9QDMnxeuDHmgrIH6cZnoeL/kyVhbTWwjmuZIV pgOqPdeSeKZ9wp7txik6Z8yaRA4YYad30t3/7DD6IM/BlLvofDhWDKRvM30dDRFXnhjx Gd8Q== 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:mime-version :message-id:date:subject:cc:to:from; bh=Q7cChAliTnvhbj6r6q3lHkxC923nMhufIvXHZZox4kg=; b=GnXsWluCds+jtqP2YLgrz2n0Wh8WBPMEUCQsKHYW0wnf6wNp7DqC3OJkM+SlPCzzw7 tYqEE4G+z1iwxvx28iBGEloiHeBC40jPDty0/6roO54llfZqvxuOQokcvVjF+lSj/rcd YLAbg/yUq/RfYfzpwAl+bx3RQksGQHOaNoX9x/xu8nLYRxZrKh/m9HEXyXwjrp+PF7ZN rpD5QaUwDeULOit7a1ufwujou9VOlg6vQD5KC2XJ+a6Zm6jw02fLa9+KPnTjVSLxeuXt 8nPvjXD5DdiGuDFX0rHhFnVAnseJuS75AASlxQAOyKEkO5Yv9kub/7E0pyXiSLCM0onV jztg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x66si23897599pfd.156.2019.07.31.08.23.08; Wed, 31 Jul 2019 08:23:08 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728702AbfGaPXH (ORCPT + 29 others); Wed, 31 Jul 2019 11:23:07 -0400 Received: from foss.arm.com ([217.140.110.172]:48920 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727604AbfGaPXG (ORCPT ); Wed, 31 Jul 2019 11:23:06 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 10E4E344; Wed, 31 Jul 2019 08:23:06 -0700 (PDT) Received: from arrakis.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 3A28A3F694; Wed, 31 Jul 2019 08:23:05 -0700 (PDT) From: Catalin Marinas To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Andrew Morton , Qian Cai Subject: [PATCH] mm: kmemleak: Disable early logging in case of error Date: Wed, 31 Jul 2019 16:23:02 +0100 Message-Id: <20190731152302.42073-1-catalin.marinas@arm.com> X-Mailer: git-send-email 2.23.0.rc0 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If an error occurs during kmemleak_init() (e.g. kmem cache cannot be created), kmemleak is disabled but kmemleak_early_log remains enabled. Subsequently, when the .init.text section is freed, the log_early() function no longer exists. To avoid a page fault in such scenario, ensure that kmemleak_disable() also disables early logging. Cc: Andrew Morton Reported-by: Qian Cai Signed-off-by: Catalin Marinas --- mm/kmemleak.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/kmemleak.c b/mm/kmemleak.c index 6e9e8cca663e..f6e602918dac 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -1966,6 +1966,7 @@ static void kmemleak_disable(void) /* stop any memory operation tracing */ kmemleak_enabled = 0; + kmemleak_early_log = 0; /* check whether it is too early for a kernel thread */ if (kmemleak_initialized) @@ -2009,7 +2010,6 @@ void __init kmemleak_init(void) #ifdef CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF if (!kmemleak_skip_disable) { - kmemleak_early_log = 0; kmemleak_disable(); return; }