Received: by 10.213.65.68 with SMTP id h4csp454680imn; Tue, 13 Mar 2018 09:34:09 -0700 (PDT) X-Google-Smtp-Source: AG47ELskCR/iFqUXi79HMld3/wsz2YzNRhiJacz5ijC4RX1wTVgavPy7Ol6DejigywFdGaWG4QIe X-Received: by 2002:a17:902:2cc1:: with SMTP id n59-v6mr1074880plb.215.1520958849052; Tue, 13 Mar 2018 09:34:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520958849; cv=none; d=google.com; s=arc-20160816; b=nzin/sVw+wV2cRmrzytQVANfx3u8rDh+9i/q7mK29r8GLSAD7NMtVcqnz120rC1mjW LVnhOXzJ+ypvlRWPDuTL8zqINfxKGjMq2Qcd/kyOghMrk6b1BPntuDDaM4FV9bnblATv scNzx//rYX5yrobNyVL9AxOr6t5rn3PaiSeK4CUG4fUUf7DQ9ZmddPa/A7VsMW3gBUJc tR+JOF5kU/uZMottDOV4anXf9UBNpbHTNZXG8LC4s8NXnhaVxgNih6oxohKr3do7t7hD gpTrOmxGrXqC9+wtdeA8Q3h8u1Vw/c4FL6mvEOHUxpG2w77gxsOUUFNRaCSLLZVXcRdS DGuQ== 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=0Zuln8lux42M1TFUCPUul6c/P0aEIcrx6GHxTnBm+cc=; b=ymPMn+wkzJkGbrXJiVuJItMpsyrrLzNWA/F+5kxm5PzTC6wAu9WhEyqB53AK19fZew E4KON99xl3ZrH7iUGE5l48iie/nykyYsUSrrQ/obBVvm9ToKPOMq+kcTIaspyjRRKvpP f+ooxGHuXkZ0/jEA7ECFz4nTLpg0J+3KOS2gbvELgiEKgYT5Zk7Sr0j44ULb9/isgJK/ dU25tJQEXChmbvlhWqvHjaBhGsIKj/8/HKXFOb+HAbmpZcGw5DvIJ0lyXxkz+JiwJrDT 1TARMIDlAWTP1m6sollXoCfZK0EiE4JZE1M1NcuWkXmFVV9//ApHIGKaCfbJLdCMEaYb IsXg== 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 u191si295180pgc.725.2018.03.13.09.33.54; Tue, 13 Mar 2018 09:34:09 -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 S1753014AbeCMQcd (ORCPT + 99 others); Tue, 13 Mar 2018 12:32:33 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59976 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933478AbeCMPdC (ORCPT ); Tue, 13 Mar 2018 11:33:02 -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 17BEB1226; Tue, 13 Mar 2018 15:33:01 +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.15 099/146] objtool: Add module specific retpoline rules Date: Tue, 13 Mar 2018 16:24:26 +0100 Message-Id: <20180313152328.204751220@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180313152320.439085687@linuxfoundation.org> References: <20180313152320.439085687@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.15-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 @@ -256,6 +256,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");