Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1833187imm; Mon, 3 Sep 2018 10:36:16 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdat85zMw12MQTtEFHVd6fdkhIrfLZhxPOQGv3+oPgraw2jVFvoovtkHjSHiFfnOXtwlXlJi X-Received: by 2002:a65:5304:: with SMTP id m4-v6mr27889854pgq.250.1535996176335; Mon, 03 Sep 2018 10:36:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535996176; cv=none; d=google.com; s=arc-20160816; b=PIGm2s0lCxxUg8kRzMKuoHrEIa/qO7I36STq7dSujxF4s0wa4CXHmVcp0A0f2YgMG1 dHt/+BXa2BWhVYitFTYT6bbioBughO+iDQKQzcFh8SQjdnzLPLxTVDxvlGul8wsk5bSD IjVvUJBxLF+VRnBLAqaM+hhSMuhJLvtsv1zwy4vdtBFLH5ctdcgBKQHy8iIlBrPKnIwL UmKJrCjxaaH51MvlQRIugUmIsKEC5uhOTS1i1DYkFw7vC8x138U6GZxQ4LNlf48SsaLN 2rxrpF+bqlVU6I0ylhLSMMkk2LESplPW4iFxDd06Ka//C3LKOd36k9cAW3jvmDfz+wq1 g3jA== 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=epc5U7OtWHcNnufJZdSqrTAWkM5nZSxgOCkNxLpboI8=; b=tvaGkBi9N25/Su0YSO61u5FnIxPUmtLxpuuZ2E0zod8C1YpiokqtbfE4ubPS0SUCyU ghSqTJqVmI3vNLPDlfWLbpWWdGI7TiwqB/eKAwUE/iYwtgvVqnwdElwflhTy+vj4C7r6 I1d+lbzWWIJ/mU3kv1brqQCifz3PlVE1K1P3psxsZWINmfsrnsJ1Nk9pp6g8nfA58KnH pM9mx184oVgdcHp0+CAZ3fb/IE3jdmnFbP0DRJennvNAmAJrRocJrYb9ROMpr/ETzcAz Ha3/EihxPCK9xn8BUHEzeoThnNaKo8janLEd53uVnoqLfxnHj08+DRgRh6FhysKJn7NY 7MOg== 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 c18-v6si18005279pgh.530.2018.09.03.10.36.01; Mon, 03 Sep 2018 10:36:16 -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 S1731450AbeICV4I (ORCPT + 99 others); Mon, 3 Sep 2018 17:56:08 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47908 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730976AbeICV4H (ORCPT ); Mon, 3 Sep 2018 17:56:07 -0400 Received: from localhost (ip-213-127-74-90.ip.prioritytelecom.net [213.127.74.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id CF55AD24; Mon, 3 Sep 2018 17:34:56 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andy Lutomirski , Thomas Gleixner , Matt Rickard , Borislav Petkov , Jason Vas Dias , David Woodhouse , Peter Zijlstra , Andi Kleen Subject: [PATCH 4.18 054/123] x86/vdso: Fix vDSO build if a retpoline is emitted Date: Mon, 3 Sep 2018 18:56:38 +0200 Message-Id: <20180903165721.731635398@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180903165719.499675257@linuxfoundation.org> References: <20180903165719.499675257@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.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Andy Lutomirski commit 2e549b2ee0e358bc758480e716b881f9cabedb6a upstream. Currently, if the vDSO ends up containing an indirect branch or call, GCC will emit the "external thunk" style of retpoline, and it will fail to link. Fix it by building the vDSO with inline retpoline thunks. I haven't seen any reports of this triggering on an unpatched kernel. Fixes: commit 76b043848fd2 ("x86/retpoline: Add initial retpoline support") Signed-off-by: Andy Lutomirski Signed-off-by: Thomas Gleixner Acked-by: Matt Rickard Cc: Borislav Petkov Cc: Jason Vas Dias Cc: David Woodhouse Cc: Peter Zijlstra Cc: Andi Kleen Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/c76538cd3afbe19c6246c2d1715bc6a60bd63985.1534448381.git.luto@kernel.org Signed-off-by: Greg Kroah-Hartman --- Makefile | 4 ++++ arch/x86/entry/vdso/Makefile | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) --- a/Makefile +++ b/Makefile @@ -493,9 +493,13 @@ KBUILD_AFLAGS += $(call cc-option, -no-i endif RETPOLINE_CFLAGS_GCC := -mindirect-branch=thunk-extern -mindirect-branch-register +RETPOLINE_VDSO_CFLAGS_GCC := -mindirect-branch=thunk-inline -mindirect-branch-register RETPOLINE_CFLAGS_CLANG := -mretpoline-external-thunk +RETPOLINE_VDSO_CFLAGS_CLANG := -mretpoline RETPOLINE_CFLAGS := $(call cc-option,$(RETPOLINE_CFLAGS_GCC),$(call cc-option,$(RETPOLINE_CFLAGS_CLANG))) +RETPOLINE_VDSO_CFLAGS := $(call cc-option,$(RETPOLINE_VDSO_CFLAGS_GCC),$(call cc-option,$(RETPOLINE_VDSO_CFLAGS_CLANG))) export RETPOLINE_CFLAGS +export RETPOLINE_VDSO_CFLAGS KBUILD_CFLAGS += $(call cc-option,-fno-PIE) KBUILD_AFLAGS += $(call cc-option,-fno-PIE) --- a/arch/x86/entry/vdso/Makefile +++ b/arch/x86/entry/vdso/Makefile @@ -72,9 +72,9 @@ $(obj)/vdso-image-%.c: $(obj)/vdso%.so.d CFL := $(PROFILING) -mcmodel=small -fPIC -O2 -fasynchronous-unwind-tables -m64 \ $(filter -g%,$(KBUILD_CFLAGS)) $(call cc-option, -fno-stack-protector) \ -fno-omit-frame-pointer -foptimize-sibling-calls \ - -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO + -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO $(RETPOLINE_VDSO_CFLAGS) -$(vobjs): KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS)) $(CFL) +$(vobjs): KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS) $(RETPOLINE_CFLAGS),$(KBUILD_CFLAGS)) $(CFL) # # vDSO code runs in userspace and -pg doesn't help with profiling anyway. @@ -138,11 +138,13 @@ KBUILD_CFLAGS_32 := $(filter-out -mcmode KBUILD_CFLAGS_32 := $(filter-out -fno-pic,$(KBUILD_CFLAGS_32)) KBUILD_CFLAGS_32 := $(filter-out -mfentry,$(KBUILD_CFLAGS_32)) KBUILD_CFLAGS_32 := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS_32)) +KBUILD_CFLAGS_32 := $(filter-out $(RETPOLINE_CFLAGS),$(KBUILD_CFLAGS_32)) KBUILD_CFLAGS_32 += -m32 -msoft-float -mregparm=0 -fpic KBUILD_CFLAGS_32 += $(call cc-option, -fno-stack-protector) KBUILD_CFLAGS_32 += $(call cc-option, -foptimize-sibling-calls) KBUILD_CFLAGS_32 += -fno-omit-frame-pointer KBUILD_CFLAGS_32 += -DDISABLE_BRANCH_PROFILING +KBUILD_CFLAGS_32 += $(RETPOLINE_VDSO_CFLAGS) $(obj)/vdso32.so.dbg: KBUILD_CFLAGS = $(KBUILD_CFLAGS_32) $(obj)/vdso32.so.dbg: FORCE \