From patchwork Fri Jun 10 23:34:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sami Tolvanen X-Patchwork-Id: 12878174 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FEC0C43334 for ; Fri, 10 Jun 2022 23:35:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349204AbiFJXfV (ORCPT ); Fri, 10 Jun 2022 19:35:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349224AbiFJXfU (ORCPT ); Fri, 10 Jun 2022 19:35:20 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05398289A1D for ; Fri, 10 Jun 2022 16:35:19 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id a68-20020a25ca47000000b006605f788ff1so533891ybg.16 for ; Fri, 10 Jun 2022 16:35:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=f3tp75L0usvR7/HEBHFbI6zWEipD9O6WfG/DwXt9RxU=; b=CpMvF4+7DFsMpHOaBEWCwgkIhWmhi/au92bxFtbtvPGRHAWy6+tq7ZwZu3TPPp6veI 1/W4RvU4He66Cv/fRAUzOJbwPqP5t/6+n5lMIDjhd1533RUb8ih5FjbIPmGUMeaW8jIf xU7gRrLWGIVRD9KJKZ03AfCUIOIwFJXlqCXEEOrkTVeNd+8a/E4LGyBX3oKhbXxWT5B3 csHoZBf1G2k0NQEQX8j1k2TI/Q9kBr2M2OXzy7ksKoBCKvBOmItjQBca8AAX48N2bG++ S5ZYPEoMCY3S9ogw7q+CbyHd6CRL9UyVEsIUbUiKKnt2MraU/Shg+/CeAMN1ytZR8AGm UbFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=f3tp75L0usvR7/HEBHFbI6zWEipD9O6WfG/DwXt9RxU=; b=Mnv2wKxa1TBTkcyrQYs2zDSjQunzmwbiEGyOU8Bd6kBx3F/vyPCMjzU5j83OUn5w95 ujQpTEPQQL3MAo2UsEDtcxtHR5UaEacyYyenZ7CJ5cYNKqmIRlepkwQ63S8m5s3XxmJi Y95uiTwvkuyxjNhgnTNleV5rhFhfYaett1CopcbRrPB2V2NUbFxJ6RdMkQcye/lkCf3S 7U/F9SEvs6v2yXTq0vmM8A6hmpgw59L7a4GsIe9XobcEzkj/Npk9hsDF76hOV23Axiuz x7wgti15BPW01umUojlKkGpbmpz3CylLxPrOC3f4dcRViMeOmmpe7IHKeboKqcA6+kf6 ncag== X-Gm-Message-State: AOAM533qELwy64y3tJJnyX6ELRJxkCZ0bjwOi57RQY+yYl8zwxNmtlcy 5I7JcNlxKrhnQmTa2Pg+aVoTqL+rS42m18QsfPU= X-Google-Smtp-Source: ABdhPJzufpaPghJca0m6g3l+aiVQwc4NlfpobT2IZhUHkW8s9pNjPsoYzNApitsOwyVnlrXfnO1/LO0AYH7qF3bsPIU= X-Received: from samitolvanen1.mtv.corp.google.com ([2620:15c:201:2:f464:6db6:3d47:ed14]) (user=samitolvanen job=sendgmr) by 2002:a0d:d9d7:0:b0:30c:2ba5:a151 with SMTP id b206-20020a0dd9d7000000b0030c2ba5a151mr51469497ywe.481.1654904118209; Fri, 10 Jun 2022 16:35:18 -0700 (PDT) Date: Fri, 10 Jun 2022 16:34:54 -0700 In-Reply-To: <20220610233513.1798771-1-samitolvanen@google.com> Message-Id: <20220610233513.1798771-2-samitolvanen@google.com> Mime-Version: 1.0 References: <20220610233513.1798771-1-samitolvanen@google.com> X-Developer-Key: i=samitolvanen@google.com; a=openpgp; fpr=35CCFB63B283D6D3AEB783944CB5F6848BBC56EE X-Developer-Signature: v=1; a=openpgp-sha256; l=2980; h=from:subject; bh=D9CF0FusOcHoK9N60QLxjpk1E2xsqSvmemFeS75j5/8=; b=owEB7QES/pANAwAKAUy19oSLvFbuAcsmYgBio9UsuUCdAj7U2+8Hnh3U+7yazPmqBk99zh6vJyhb 4/+cmdSJAbMEAAEKAB0WIQQ1zPtjsoPW0663g5RMtfaEi7xW7gUCYqPVLAAKCRBMtfaEi7xW7nGxC/ oCtMcUeK4KGJm7EoJ262u7jGOh4PjE0kWyNah1Np47MSwS2EpgThwsYg/oyPlMAKsuEiEb3Gv5G2zR spW3AtGXGZ0sI3SfFcZQj6N6iI4JfLIFsFq5+v0uN+ORUESg8JiD9jqja4KXEn8ZRFw37BLsnDIgUz Y40ii2rqHPjLuAijuImAO/uj/jTxUjtOmV0K9nD7YjXMGHCJsdAAAziA2VaAcLxsRuOtBDpD2LUd/X IkSmg3Zyl1mjt7AYMiZMoGZ3opA2HjBB+YTLefQHBJEPPm4Lcadtg6gNYhJfG32QWywx9g6qeJu5yT APfULpxls5FYQmIDIJK+sD/Mnieq4ClX2KzvtsaVStZA5iA5nV9rN3uSbh5eChZot5evyMMb/np5z2 np3oNKfQBlUMXkL7e1W3wyDjgIZ+Y+OSJdYSxXn50RhUc2x4vygGQNzJekBUrEL9rBri4RteAWfFZA 3Avw3bBx1N8qZbR0uS8ging4PqmrIqG68CqQowCZTc6Lw= X-Mailer: git-send-email 2.36.1.476.g0c4daa206d-goog Subject: [RFC PATCH v3 01/20] treewide: Filter out CC_FLAGS_CFI From: Sami Tolvanen To: linux-kernel@vger.kernel.org Cc: Kees Cook , Josh Poimboeuf , Peter Zijlstra , x86@kernel.org, Catalin Marinas , Will Deacon , Mark Rutland , Nathan Chancellor , Nick Desaulniers , Joao Moreira , Sedat Dilek , Steven Rostedt , linux-hardening@vger.kernel.org, linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev, Sami Tolvanen Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org In preparation for removing CC_FLAGS_CFI from CC_FLAGS_LTO, explicitly filter out CC_FLAGS_CFI in all the makefiles where we currently filter out CC_FLAGS_LTO. Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook --- arch/arm64/kernel/vdso/Makefile | 3 ++- arch/x86/entry/vdso/Makefile | 3 ++- drivers/firmware/efi/libstub/Makefile | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/vdso/Makefile b/arch/arm64/kernel/vdso/Makefile index f6e25d7c346a..c7c123ed29cc 100644 --- a/arch/arm64/kernel/vdso/Makefile +++ b/arch/arm64/kernel/vdso/Makefile @@ -34,7 +34,8 @@ ccflags-y += -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO # kernel with CONFIG_WERROR enabled. CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) -Os $(CC_FLAGS_SCS) \ $(RANDSTRUCT_CFLAGS) $(GCC_PLUGINS_CFLAGS) \ - $(CC_FLAGS_LTO) -Wmissing-prototypes -Wmissing-declarations + $(CC_FLAGS_LTO) $(CC_FLAGS_CFI) \ + -Wmissing-prototypes -Wmissing-declarations KASAN_SANITIZE := n KCSAN_SANITIZE := n UBSAN_SANITIZE := n diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile index c2a8b76ae0bc..0148df4f0425 100644 --- a/arch/x86/entry/vdso/Makefile +++ b/arch/x86/entry/vdso/Makefile @@ -91,7 +91,7 @@ ifneq ($(RETPOLINE_VDSO_CFLAGS),) endif endif -$(vobjs): KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_LTO) $(RANDSTRUCT_CFLAGS) $(GCC_PLUGINS_CFLAGS) $(RETPOLINE_CFLAGS),$(KBUILD_CFLAGS)) $(CFL) +$(vobjs): KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_LTO) $(CC_FLAGS_CFI) $(RANDSTRUCT_CFLAGS) $(GCC_PLUGINS_CFLAGS) $(RETPOLINE_CFLAGS),$(KBUILD_CFLAGS)) $(CFL) # # vDSO code runs in userspace and -pg doesn't help with profiling anyway. @@ -152,6 +152,7 @@ KBUILD_CFLAGS_32 := $(filter-out $(RANDSTRUCT_CFLAGS),$(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 := $(filter-out $(CC_FLAGS_LTO),$(KBUILD_CFLAGS_32)) +KBUILD_CFLAGS_32 := $(filter-out $(CC_FLAGS_CFI),$(KBUILD_CFLAGS_32)) KBUILD_CFLAGS_32 += -m32 -msoft-float -mregparm=0 -fpic KBUILD_CFLAGS_32 += -fno-stack-protector KBUILD_CFLAGS_32 += $(call cc-option, -foptimize-sibling-calls) diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile index d0537573501e..234fb2910622 100644 --- a/drivers/firmware/efi/libstub/Makefile +++ b/drivers/firmware/efi/libstub/Makefile @@ -39,6 +39,8 @@ KBUILD_CFLAGS := $(cflags-y) -Os -DDISABLE_BRANCH_PROFILING \ # remove SCS flags from all objects in this directory KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_SCS), $(KBUILD_CFLAGS)) +# disable CFI +KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_CFI), $(KBUILD_CFLAGS)) # disable LTO KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_LTO), $(KBUILD_CFLAGS))