Received: by 10.223.176.5 with SMTP id f5csp2823548wra; Mon, 5 Feb 2018 10:26:35 -0800 (PST) X-Google-Smtp-Source: AH8x224QIB4M+LaI/bjo43rCEq5XWhlZ+mK6c8MXSIhZiijvTmxe/6waJlju2aMbYqKHu9+mJIv2 X-Received: by 10.98.152.11 with SMTP id q11mr11573788pfd.131.1517855195825; Mon, 05 Feb 2018 10:26:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517855195; cv=none; d=google.com; s=arc-20160816; b=yD96n75T6A1o/FpbbvLOaX5kLWW/Ys/TIcO+gVc1XMOmSgmUNIZYW45mrX72a+bdxU 9zgND/V3BmnUdagS8gDmSi34jkF+dM2vBqtRqP1LyRTaPerzmh/afo26Wy81X3BEV8N2 s6tHWZC73HheETKDM0EAO5jTanZ9JdJWqqxv4j+uLZtZU6zgp1YcUec1sL4QbW5/Qfst 4MrMZytGWVo302tkZCjCdvwwBap8vgFpASPgNoaL3zdAqbjkqCng9/sjLmo5Zb8APbEm k8e81Aj1IfPNmKPVgedYmqNgJOzJ/dvFXdPtaJT+wUgjq34h2UxZ6J/qcetAWMsI8nGy gG/Q== 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=M6JIMZM3X26rEuK1qZn9Q4TCQjtT6ZozRvtYjkCLvW4=; b=H1Cvxno7tuDz/A0TuTToswNAt7T/juHoGYempRuLY4ZDZ1nkJ3cE47l5um2XSBBJ9G YE0Ec5jsSD7FNbr1hf+77RNIU5XkR41eEtxgeNzE67rXMvnovSC3HsQdevbiPNk+dl2k KdCU+pqilpas7bCxVw5PhDk1kydwHObLlhPFOoh8H5igkrybu/UTOXkJ59i2wmjZiA6j yJBYLigZrCakuF+mGCuXwPcwo5mkjPYwyhm/Jzx1bjmGmzNTvMbSvNWSBzZjBNNbYwDr vNIkJwVGHsuMZQ1EPQJjyo0IVkRcEbBkBMSI90dBMNe+ZP/wL98bga2VRv76giut/oQA T/JA== 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 o11si4019958pgn.796.2018.02.05.10.26.21; Mon, 05 Feb 2018 10:26:35 -0800 (PST) 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 S1753742AbeBESZW (ORCPT + 99 others); Mon, 5 Feb 2018 13:25:22 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:51100 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753459AbeBESXu (ORCPT ); Mon, 5 Feb 2018 13:23:50 -0500 Received: from localhost (unknown [104.132.1.108]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 416CCFEF; Mon, 5 Feb 2018 18:23:49 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Josh Poimboeuf , Andy Lutomirski , Borislav Petkov , Dave Hansen , David Woodhouse , Guenter Roeck , "H. Peter Anvin" , Juergen Gross , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , Ingo Molnar Subject: [PATCH 4.14 29/64] objtool: Add support for alternatives at the end of a section Date: Mon, 5 Feb 2018 10:22:48 -0800 Message-Id: <20180205182139.777435102@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180205182138.571333346@linuxfoundation.org> References: <20180205182138.571333346@linuxfoundation.org> User-Agent: quilt/0.65 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: Josh Poimboeuf jpoimboe@redhat.com commit 17bc33914bcc98ba3c6b426fd1c49587a25c0597 Now that the previous patch gave objtool the ability to read retpoline alternatives, it shows a new warning: arch/x86/entry/entry_64.o: warning: objtool: .entry_trampoline: don't know how to handle alternatives at end of section This is due to the JMP_NOSPEC in entry_SYSCALL_64_trampoline(). Previously, objtool ignored this situation because it wasn't needed, and it would have required a bit of extra code. Now that this case exists, add proper support for it. Signed-off-by: Josh Poimboeuf Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Dave Hansen Cc: David Woodhouse Cc: Greg Kroah-Hartman Cc: Guenter Roeck Cc: H. Peter Anvin Cc: Juergen Gross Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/2a30a3c2158af47d891a76e69bb1ef347e0443fd.1517284349.git.jpoimboe@redhat.com Signed-off-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman --- tools/objtool/check.c | 53 +++++++++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 22 deletions(-) --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -594,7 +594,7 @@ static int handle_group_alt(struct objto struct instruction *orig_insn, struct instruction **new_insn) { - struct instruction *last_orig_insn, *last_new_insn, *insn, *fake_jump; + struct instruction *last_orig_insn, *last_new_insn, *insn, *fake_jump = NULL; unsigned long dest_off; last_orig_insn = NULL; @@ -610,28 +610,30 @@ static int handle_group_alt(struct objto last_orig_insn = insn; } - if (!next_insn_same_sec(file, last_orig_insn)) { - WARN("%s: don't know how to handle alternatives at end of section", - special_alt->orig_sec->name); - return -1; - } - - fake_jump = malloc(sizeof(*fake_jump)); - if (!fake_jump) { - WARN("malloc failed"); - return -1; + if (next_insn_same_sec(file, last_orig_insn)) { + fake_jump = malloc(sizeof(*fake_jump)); + if (!fake_jump) { + WARN("malloc failed"); + return -1; + } + memset(fake_jump, 0, sizeof(*fake_jump)); + INIT_LIST_HEAD(&fake_jump->alts); + clear_insn_state(&fake_jump->state); + + fake_jump->sec = special_alt->new_sec; + fake_jump->offset = -1; + fake_jump->type = INSN_JUMP_UNCONDITIONAL; + fake_jump->jump_dest = list_next_entry(last_orig_insn, list); + fake_jump->ignore = true; } - memset(fake_jump, 0, sizeof(*fake_jump)); - INIT_LIST_HEAD(&fake_jump->alts); - clear_insn_state(&fake_jump->state); - - fake_jump->sec = special_alt->new_sec; - fake_jump->offset = -1; - fake_jump->type = INSN_JUMP_UNCONDITIONAL; - fake_jump->jump_dest = list_next_entry(last_orig_insn, list); - fake_jump->ignore = true; if (!special_alt->new_len) { + if (!fake_jump) { + WARN("%s: empty alternative at end of section", + special_alt->orig_sec->name); + return -1; + } + *new_insn = fake_jump; return 0; } @@ -654,8 +656,14 @@ static int handle_group_alt(struct objto continue; dest_off = insn->offset + insn->len + insn->immediate; - if (dest_off == special_alt->new_off + special_alt->new_len) + if (dest_off == special_alt->new_off + special_alt->new_len) { + if (!fake_jump) { + WARN("%s: alternative jump to end of section", + special_alt->orig_sec->name); + return -1; + } insn->jump_dest = fake_jump; + } if (!insn->jump_dest) { WARN_FUNC("can't find alternative jump destination", @@ -670,7 +678,8 @@ static int handle_group_alt(struct objto return -1; } - list_add(&fake_jump->list, &last_new_insn->list); + if (fake_jump) + list_add(&fake_jump->list, &last_new_insn->list); return 0; }