Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp436062yba; Wed, 15 May 2019 04:04:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqxZW47Wq53iabHXzF8QO2pTeE8iOcafUhawD5dZpF8SH1M5uHcHRQZloMmnA1C8oP3sGSex X-Received: by 2002:a17:902:56a:: with SMTP id 97mr4490249plf.20.1557918290982; Wed, 15 May 2019 04:04:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557918290; cv=none; d=google.com; s=arc-20160816; b=lg34IOOmoouOD4zWEpKv1f0qaWP63j5Cy1Oaezi/6wpifcxx8nsmv4t2WHpneqAFkI y9+VNd0pRZsRcj1p2VZNHLdrRcKB138o+T+K/FRCvPJDsuNnmPae/eZUeNVnICC597WK AOTMJxOV/HIx2vma2sfjSRjE6Hxlr7DptspVr8oEi0vOCuLsjJAz2DW9S0ozJPk7R6DQ YDFu8B9CkO4y3ahedYZtPxZ4TZlY+gBrQ805gXLYbM3pyWU0lMlTVCcKYsvrgUQ5Pr1k e6MU4dgM3gIxBcbupuVChlSDHqpkVamzfjmkrAJTfDs6ZfeQXuFS0fPNmgg/EapJyf5j wqbQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hd0Et9p0vTu2V4hiN1IDqoyHjt9xWduimxOBer2Zc50=; b=ufB2jG8Ird/FoGo1C9By5GOi15QxdmjCxITjlj4oTpyDLoonglfRIT0SdCWJ1JnKnL 5x4gD2V2RachQ3ElVR8lIS3dvEz46w1PNDMluOqXzMA609sFLH1qrjCbTY+7x2ZZ4fLv 6wD+kf27+3sg/Qi+BBYjPLMN+O5DbLnwR2u8h1kE9fXdkgcUmSK6g/m6wCI7vmyTfgIH nxJGK93vJy9aIq0AD3zISqvGbv41Vz0QFDFDLQlwEZDnHjgeddwRt2jLETo1zPUepgu3 0a2xzoVZxUmfCpy+Ta3kjIAXS23zBfp+yOevQ8iELz/w4p8ZmOG8ecqLLjP20Cd5jIRq GnXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Vkpv7EDu; 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 j22si1799865pfi.167.2019.05.15.04.04.33; Wed, 15 May 2019 04:04:50 -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; dkim=pass header.i=@kernel.org header.s=default header.b=Vkpv7EDu; 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 S1727532AbfEOLAu (ORCPT + 99 others); Wed, 15 May 2019 07:00:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:57580 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727487AbfEOLAn (ORCPT ); Wed, 15 May 2019 07:00:43 -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 40EA320881; Wed, 15 May 2019 11:00:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557918042; bh=Py9I6eQV1WsszAm3z4cf6ZYKS+uIuYiVEL4igMOc+eQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vkpv7EDuzlGo7x8UVNOl3MOGzl4Lg9EI+nBpLJCsN5KtiGfmsyT/OHglSEkcTBSAO u9rngvH9kvKOMszfVsfhDaAUWr7P8CDm1zoZ2mSaCdp3mk9fIAGm9iKexmuyMa48A2 Lq5efS6efJCx2ussIubtJO2fYkNyNplTSIChAoTc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Williams , Guenter Roeck , Kees Cook , Mathieu Desnoyers , Thomas Gleixner , Mike Rapoport , Russell King , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 3.18 71/86] init: initialize jump labels before command line option parsing Date: Wed, 15 May 2019 12:55:48 +0200 Message-Id: <20190515090655.063670192@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190515090642.339346723@linuxfoundation.org> References: <20190515090642.339346723@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 6041186a32585fc7a1d0f6cfe2f138b05fdc3c82 ] When a module option, or core kernel argument, toggles a static-key it requires jump labels to be initialized early. While x86, PowerPC, and ARM64 arrange for jump_label_init() to be called before parse_args(), ARM does not. Kernel command line: rdinit=/sbin/init page_alloc.shuffle=1 panic=-1 console=ttyAMA0,115200 page_alloc.shuffle=1 ------------[ cut here ]------------ WARNING: CPU: 0 PID: 0 at ./include/linux/jump_label.h:303 page_alloc_shuffle+0x12c/0x1ac static_key_enable(): static key 'page_alloc_shuffle_key+0x0/0x4' used before call to jump_label_init() Modules linked in: CPU: 0 PID: 0 Comm: swapper Not tainted 5.1.0-rc4-next-20190410-00003-g3367c36ce744 #1 Hardware name: ARM Integrator/CP (Device Tree) [] (unwind_backtrace) from [] (show_stack+0x10/0x18) [] (show_stack) from [] (dump_stack+0x18/0x24) [] (dump_stack) from [] (__warn+0xe0/0x108) [] (__warn) from [] (warn_slowpath_fmt+0x44/0x6c) [] (warn_slowpath_fmt) from [] (page_alloc_shuffle+0x12c/0x1ac) [] (page_alloc_shuffle) from [] (shuffle_store+0x28/0x48) [] (shuffle_store) from [] (parse_args+0x1f4/0x350) [] (parse_args) from [] (start_kernel+0x1c0/0x488) Move the fallback call to jump_label_init() to occur before parse_args(). The redundant calls to jump_label_init() in other archs are left intact in case they have static key toggling use cases that are even earlier than option parsing. Link: http://lkml.kernel.org/r/155544804466.1032396.13418949511615676665.stgit@dwillia2-desk3.amr.corp.intel.com Signed-off-by: Dan Williams Reported-by: Guenter Roeck Reviewed-by: Kees Cook Cc: Mathieu Desnoyers Cc: Thomas Gleixner Cc: Mike Rapoport Cc: Russell King Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- init/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init/main.c b/init/main.c index 32940a68ea484..6235c0bed3da2 100644 --- a/init/main.c +++ b/init/main.c @@ -539,6 +539,8 @@ asmlinkage __visible void __init start_kernel(void) page_alloc_init(); pr_notice("Kernel command line: %s\n", boot_command_line); + /* parameters may set static keys */ + jump_label_init(); parse_early_param(); after_dashes = parse_args("Booting kernel", static_command_line, __start___param, @@ -548,8 +550,6 @@ asmlinkage __visible void __init start_kernel(void) parse_args("Setting init args", after_dashes, NULL, 0, -1, -1, set_init_arg); - jump_label_init(); - /* * These use large bootmem allocations and must precede * kmem_cache_init() -- 2.20.1