Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1823435imm; Mon, 3 Sep 2018 10:21:34 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYAROvPQA5UJbqlUWSoY1/I368/u3w3NJf6xpxxaW52O4Fz1vql4AsdoLzkOqjXeMkTiVB4 X-Received: by 2002:a62:ed5:: with SMTP id 82-v6mr30277216pfo.198.1535995294224; Mon, 03 Sep 2018 10:21:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535995294; cv=none; d=google.com; s=arc-20160816; b=CZjEVKYs5Wh5LRWtk8KYcOGvUgzQ4idZg3YVo9OKrfzlw+8fjz3/Y+4rozvk37PJyy Vdyb3bSCM7gy8e/uVxdspygTkAFAXjU80fhwMl9W5mLToWCcO0+X+SCZCM7FHeP2P1OE r0MgpmBzzG4d2QrUWl3GhdEo7M+6jTIJetgUlSzGNIl76D/OfoeAKgNFUC/JXeniViQu NgP/tq4rMEnkYoS20iekl9y+jWOjVtMN0yqeD/HK1UUltDHYiioUgiHPXZFEjstwS/FA ft8wR68fKJjxCbBkylANBXppIBIq7Y/MPOyf4VdY8ffzPK6M7zC/gPWxwnIt2V1UUAUr B/KQ== 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=CQXo0a6qwfwHWQfM2QL3ycAwxOHOTAS2gpJpbGq1I9E=; b=kFJmi3p/r8D6UrPtNnh50LBh+GfZ/xtvTaBxZjVSZu69YKPEmakyNvoQfVQ63PnxEK Ghtn3QXNl548+2Mw7maVpXoMSqpOrZLCDNB5KjKGKutOUmdsX4ZCUJGzpM3gMyo2qkwH YhqIpU11wjnHCjDuvlPOKrMsWmsMRRaZ02mbSV6u/41N9/8PDvBJpe4Plz8D/I9tzXO6 ZN4a/O321zQvXmIwv4U7ixNFDYnmle3TxEyjw2xmhCnDthsoZkkPaQHOPlDBOz2VOQMF c3z3Go8L/438Oa9imS9oJfNJgU88zXc22RrHiKgJS9f34bp6SMezh9EqwR+laiyewfqI zLKw== 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 j9-v6si5703547plk.153.2018.09.03.10.21.19; Mon, 03 Sep 2018 10:21:34 -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 S1730229AbeICViy (ORCPT + 99 others); Mon, 3 Sep 2018 17:38:54 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:42912 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727695AbeICVix (ORCPT ); Mon, 3 Sep 2018 17:38:53 -0400 Received: from localhost (ip-213-127-74-90.ip.prioritytelecom.net [213.127.74.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 239D1D14; Mon, 3 Sep 2018 17:17:47 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kees Cook , Masahiro Yamada , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Sasha Levin Subject: [PATCH 4.14 050/165] x86/boot: Fix if_changed build flip/flop bug Date: Mon, 3 Sep 2018 18:55:36 +0200 Message-Id: <20180903165657.635851130@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180903165655.003605184@linuxfoundation.org> References: <20180903165655.003605184@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: Kees Cook [ Upstream commit 92a4728608a8fd228c572bc8ff50dd98aa0ddf2a ] Dirk Gouders reported that two consecutive "make" invocations on an already compiled tree will show alternating behaviors: $ make CALL scripts/checksyscalls.sh DESCEND objtool CHK include/generated/compile.h DATAREL arch/x86/boot/compressed/vmlinux Kernel: arch/x86/boot/bzImage is ready (#48) Building modules, stage 2. MODPOST 165 modules $ make CALL scripts/checksyscalls.sh DESCEND objtool CHK include/generated/compile.h LD arch/x86/boot/compressed/vmlinux ZOFFSET arch/x86/boot/zoffset.h AS arch/x86/boot/header.o LD arch/x86/boot/setup.elf OBJCOPY arch/x86/boot/setup.bin OBJCOPY arch/x86/boot/vmlinux.bin BUILD arch/x86/boot/bzImage Setup is 15644 bytes (padded to 15872 bytes). System is 6663 kB CRC 3eb90f40 Kernel: arch/x86/boot/bzImage is ready (#48) Building modules, stage 2. MODPOST 165 modules He bisected it back to: commit 98f78525371b ("x86/boot: Refuse to build with data relocations") The root cause was the use of the "if_changed" kbuild function multiple times for the same target. It was designed to only be used once per target, otherwise it will effectively always trigger, flipping back and forth between the two commands getting recorded by "if_changed". Instead, this patch merges the two commands into a single function to get stable build artifacts (i.e. .vmlinux.cmd), and a single build behavior. Bisected-and-Reported-by: Dirk Gouders Fix-Suggested-by: Masahiro Yamada Signed-off-by: Kees Cook Reviewed-by: Masahiro Yamada Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/20180724230827.GA37823@beast Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- arch/x86/boot/compressed/Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/arch/x86/boot/compressed/Makefile +++ b/arch/x86/boot/compressed/Makefile @@ -104,9 +104,13 @@ define cmd_check_data_rel done endef +# We need to run two commands under "if_changed", so merge them into a +# single invocation. +quiet_cmd_check-and-link-vmlinux = LD $@ + cmd_check-and-link-vmlinux = $(cmd_check_data_rel); $(cmd_ld) + $(obj)/vmlinux: $(vmlinux-objs-y) FORCE - $(call if_changed,check_data_rel) - $(call if_changed,ld) + $(call if_changed,check-and-link-vmlinux) OBJCOPYFLAGS_vmlinux.bin := -R .comment -S $(obj)/vmlinux.bin: vmlinux FORCE