Received: by 10.223.176.5 with SMTP id f5csp1606986wra; Wed, 31 Jan 2018 08:51:07 -0800 (PST) X-Google-Smtp-Source: AH8x225zGJTtjrMvEwrW3O2/PJz434GszqUryUfgZTjDv3qsT9rubIbZluZMOpHveLN8KqtUeCpI X-Received: by 10.98.0.194 with SMTP id 185mr16706949pfa.63.1517417467340; Wed, 31 Jan 2018 08:51:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517417467; cv=none; d=google.com; s=arc-20160816; b=SZQFV86FsuTHczSLQqgpCMaoZIiXVi26jzUNWxRJMLuM05v5Q0O35WR5jHoFTgMmth iZmKwkl9Ui/G4I//Et7IYunpMWjZqcfNzxUB44zBUfB++PltrumpuOV8SwvXZEiyj4xn 0kCfdqoGnUAF0W+0rx/gVeSObYOQZuCa8GBgU1tQ5PMqvE/AJNgH2yU54zbTeAlPLThH hquJyYkpkV7l1acI4EMsb2e642rQk2prGccUTB1wyQa+ORb5i4/YPWpP3zWu6ONFndIE 1sN6WStkgxqv24BMjAJAkR3lvrp8vl1/bQ4cqMRWpY6IjWrLjxdinU9J5T2bPPQru6js 87YQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=h5891k3uq0qNrW8dfbYq+dSwY1SiqZ1Z5RZMBLN63dM=; b=e6uxLnzJVSUayGrZglhkEcrE12hBc2JjrPqI1MDd9cED6cI8OVz9RUxNnBqkhwZI+h A+Q9F9WW3sc943SkGOq4YAZHoFKYHdEYGm5JKZCbpmTVCNjbI7wgwPh2VHJmP4ZRgHwb 7Ve4xzyCoe9+fF4BCyr6qP0GiyZ5wHv56bvmMHVbn5CMoaw+woE9mS92XzFYOe02KqFA 1vFRvxwG7uogwxWxo/dvSr+YRQd7RIDuXcQqNbrhW3qxV/B5UNN2EJi9s7WDPYVjuWBv Qq0YpMXl7CTLpdFNHyz/JdThibEnEQ97EkbO+xO1Y5Zk1KzQ7XUEfKlrLa2wNDiuzc5F iQMg== 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 n26si3397225pge.266.2018.01.31.08.50.52; Wed, 31 Jan 2018 08:51:07 -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 S932346AbeAaQdW (ORCPT + 99 others); Wed, 31 Jan 2018 11:33:22 -0500 Received: from mail.skyhub.de ([5.9.137.197]:34848 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752811AbeAaQdV (ORCPT ); Wed, 31 Jan 2018 11:33:21 -0500 X-Virus-Scanned: Nedap ESD1 at mail.skyhub.de Received: from mail.skyhub.de ([127.0.0.1]) by localhost (blast.alien8.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id l8fE_6AwREpb; Wed, 31 Jan 2018 17:33:20 +0100 (CET) Received: from pd.tnic (p200300EC2BCE68005D4DFBFD0E3B986B.dip0.t-ipconnect.de [IPv6:2003:ec:2bce:6800:5d4d:fbfd:e3b:986b]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 105EF1EC00FF; Wed, 31 Jan 2018 17:33:20 +0100 (CET) From: Borislav Petkov To: X86 ML Cc: Andy Lutomirski , Jiri Kosina , LKML Subject: [RFC PATCH] x86/vdso: Remove retpoline flags Date: Wed, 31 Jan 2018 17:33:12 +0100 Message-Id: <20180131163312.7144-1-bp@alien8.de> X-Mailer: git-send-email 2.13.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Borislav Petkov So this does not fix an existing problem but a hypothetical one. The below fires on an old Frankenstein distro kernel and I'm sending it only because it is obviously The Right Thing(tm). And in case we change things in the vdso in the future and thus manage to generate an indirect call for whatever reason... So on those older vdsos, the compiler can generate indirect calls to the retpoline thunks, which manifests itself as: /usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: arch/x86/vdso/vclock_gettime.o: \ relocation R_X86_64_PC32 against undefined symbol `__x86_indirect_thunk_rax' can not be used when \ making a shared object; recompile with -fPIC /usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: final link failed: Bad value collect2: error: ld returned 1 exit status nm: 'arch/x86/vdso/vdso.so.dbg': No such file objcopy: 'arch/x86/vdso/vdso.so.dbg': No such file make[2]: *** [arch/x86/vdso/vdso.so] Error 1 make[1]: *** [arch/x86/vdso] Error 2 make[1]: *** Waiting for unfinished jobs.... However, since the vdso is not part of the kernel, it cannot reference kernel symbols so we better not build with with retpoline CFLAGS either. Thus, export RETPOLINE_CFLAGS to the lower level Makefiles so that they can be filtered out in vdso's Makefile. Suggested-by: Jiri Kosina Signed-off-by: Borislav Petkov Cc: Andy Lutomirski --- arch/x86/Makefile | 6 ++++-- arch/x86/entry/vdso/Makefile | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/x86/Makefile b/arch/x86/Makefile index fad55160dcb9..fe7adbc6a380 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -232,9 +232,11 @@ KBUILD_CFLAGS += -fno-asynchronous-unwind-tables # Avoid indirect branches in kernel to deal with Spectre ifdef CONFIG_RETPOLINE - RETPOLINE_CFLAGS += $(call cc-option,-mindirect-branch=thunk-extern -mindirect-branch-register) + RETPOLINE_CFLAGS := $(call cc-option,-mindirect-branch=thunk-extern -mindirect-branch-register) ifneq ($(RETPOLINE_CFLAGS),) - KBUILD_CFLAGS += $(RETPOLINE_CFLAGS) -DRETPOLINE + RETPOLINE_CFLAGS += -DRETPOLINE + KBUILD_CFLAGS += $(RETPOLINE_CFLAGS) + export RETPOLINE_CFLAGS endif endif diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile index 1943aebadede..991ae9af5a00 100644 --- a/arch/x86/entry/vdso/Makefile +++ b/arch/x86/entry/vdso/Makefile @@ -30,6 +30,11 @@ vdso_img-$(VDSO32-y) += 32 obj-$(VDSO32-y) += vdso32-setup.o + +ifdef CONFIG_RETPOLINE + KBUILD_CFLAGS := $(filter-out $(RETPOLINE_CFLAGS),$(KBUILD_CFLAGS)) +endif + vobjs := $(foreach F,$(vobjs-y),$(obj)/$F) $(obj)/vdso.o: $(obj)/vdso.so -- 2.13.0