Received: by 10.213.65.68 with SMTP id h4csp428318imn; Tue, 13 Mar 2018 08:45:29 -0700 (PDT) X-Google-Smtp-Source: AG47ELtPu/uqKu6vPNqqfqHOtDV6FKB2GH/MPMHvp+yaWlESH8q4cRz7LOXNQshjNsqlaXM1kt1Q X-Received: by 10.99.120.138 with SMTP id t132mr875964pgc.54.1520955929762; Tue, 13 Mar 2018 08:45:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520955929; cv=none; d=google.com; s=arc-20160816; b=y3V7OycUmusAoInChECPFEDgOCaTH2mOsEMvK+ODRa8aksUvDDV72vz3IZblr9S14S 7ztu343IEU0ZtNg3XFruFzHCwrMz956/qu4BDm1+8vl6hh8Zhe9IAq+2wCj+NbZDyk6F p1S6r6TX4e/vtEbpIFlsE9YP34bOqgllft6snzKz3UvOGZeIo1wG6Iqp0m2RUzXhv4ny DwVY4MSfnAF5q/KY/iWPcYLO/Gj58eI33K/Gl+dxK4mZ6/IWFpJcaStTddjV35REhmY/ YYRR52DSheOosavXGR4rZxS6j1GOGIdntaMVWw/OZ9BObFnb26zxDgHvEizAqH9LHADg 4ArA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=ZscA2Q52z+JnHfWFW2JtZtQZNVPlOTrGs+8sZ4uvGGU=; b=JcqDE311NikTlaz/iSyueGxtAKPAyT60wUFWTLjSNPu4Jvg9LTNlIft5Tp4xj55mYt 7w+iDr+i7yKx5ePYSNtIMCe30XhNNTTHurETinb017kMgXpsq9GRcADLDMGdroYLkNzR OpXQg6UGDm9GV3TQWmxtt9xmfouofQDLP2Ri0hisD1bGOoSR0b12BsgrU385lAI4Wqae qMF/bjaliMCVhPtRWCLlUHz4J9MegjURNf4JOmqn5ywSQv068tE35fQ8+18gxf3AbUwb qiXkoeScMBkZplnVVnN3Yipfa2c3ZWhKkUt+PMzBC/cZfT3nM3oMI0RBn6uLqcFOdjmU +2GQ== 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 q24-v6si293109pls.600.2018.03.13.08.45.15; Tue, 13 Mar 2018 08:45:29 -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 S935061AbeCMPnt (ORCPT + 99 others); Tue, 13 Mar 2018 11:43:49 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:37072 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935016AbeCMPlj (ORCPT ); Tue, 13 Mar 2018 11:41:39 -0400 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 958BD1047; Tue, 13 Mar 2018 15:41:29 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Woodhouse , "Peter Zijlstra (Intel)" , Thomas Gleixner , Josh Poimboeuf , Andy Lutomirski , Arjan van de Ven , Borislav Petkov , Dan Williams , Dave Hansen , Linus Torvalds , Ingo Molnar Subject: [PATCH 4.14 136/140] objtool: Add module specific retpoline rules Date: Tue, 13 Mar 2018 16:25:39 +0100 Message-Id: <20180313152507.316611450@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180313152458.201155692@linuxfoundation.org> References: <20180313152458.201155692@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Peter Zijlstra commit ca41b97ed9124fd62323a162de5852f6e28f94b8 upstream. David allowed retpolines in .init.text, except for modules, which will trip up objtool retpoline validation, fix that. Requested-by: David Woodhouse Signed-off-by: Peter Zijlstra (Intel) Acked-by: Thomas Gleixner Acked-by: Josh Poimboeuf Cc: Andy Lutomirski Cc: Arjan van de Ven Cc: Borislav Petkov Cc: Dan Williams Cc: Dave Hansen Cc: David Woodhouse Cc: Greg Kroah-Hartman Cc: Linus Torvalds Cc: Peter Zijlstra Signed-off-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman --- scripts/Makefile.build | 2 ++ tools/objtool/builtin-check.c | 3 ++- tools/objtool/builtin.h | 2 +- tools/objtool/check.c | 9 +++++++++ 4 files changed, 14 insertions(+), 2 deletions(-) --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -261,6 +261,8 @@ __objtool_obj := $(objtree)/tools/objtoo objtool_args = $(if $(CONFIG_UNWINDER_ORC),orc generate,check) +objtool_args += $(if $(part-of-module), --module,) + ifndef CONFIG_FRAME_POINTER objtool_args += --no-fp endif --- a/tools/objtool/builtin-check.c +++ b/tools/objtool/builtin-check.c @@ -29,7 +29,7 @@ #include "builtin.h" #include "check.h" -bool no_fp, no_unreachable, retpoline; +bool no_fp, no_unreachable, retpoline, module; static const char * const check_usage[] = { "objtool check [] file.o", @@ -40,6 +40,7 @@ const struct option check_options[] = { OPT_BOOLEAN('f', "no-fp", &no_fp, "Skip frame pointer validation"), OPT_BOOLEAN('u', "no-unreachable", &no_unreachable, "Skip 'unreachable instruction' warnings"), OPT_BOOLEAN('r', "retpoline", &retpoline, "Validate retpoline assumptions"), + OPT_BOOLEAN('m', "module", &module, "Indicates the object will be part of a kernel module"), OPT_END(), }; --- a/tools/objtool/builtin.h +++ b/tools/objtool/builtin.h @@ -20,7 +20,7 @@ #include extern const struct option check_options[]; -extern bool no_fp, no_unreachable, retpoline; +extern bool no_fp, no_unreachable, retpoline, module; extern int cmd_check(int argc, const char **argv); extern int cmd_orc(int argc, const char **argv); --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1957,6 +1957,15 @@ static int validate_retpoline(struct obj if (insn->retpoline_safe) continue; + /* + * .init.text code is ran before userspace and thus doesn't + * strictly need retpolines, except for modules which are + * loaded late, they very much do need retpoline in their + * .init.text + */ + if (!strcmp(insn->sec->name, ".init.text") && !module) + continue; + WARN_FUNC("indirect %s found in RETPOLINE build", insn->sec, insn->offset, insn->type == INSN_JUMP_DYNAMIC ? "jump" : "call");