From nobody Mon Feb 9 05:52:11 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5BFCA85953; Mon, 6 May 2024 13:36:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715002587; cv=none; b=IuGERdwaAUYQJdAq0rWaZj7UZyWsJScNSTFZNE4bWnbvSnVx9c4mKsAsr5/Hkt1mdoa1LqVo8A96lw4PW+nh6PZ49Q3kHvMnQftg2Hd1roh54yK4D8rR3pbDUG0oK31ntUbgWIQI4NDNAoct4FfL8kUmHkFgoIj+eILeqJboLJM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715002587; c=relaxed/simple; bh=UJcPiw61xTI0GeGTdwGeKs1FkrZi0wwoWTT0pSrYn+M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Q7PhHZRoE1r+kzlqDLINQOaErh6pRALvsCcVIpa7u7A4QWVyaW0P5w0bK9l67DKOzOqtiqVgcLH8T9Wq7gasos0YcweFRUNEgm6T7X4p9Aa3cwDQNVuLcWV1tEGKsXvJ4gCur8bCWjo7aLl5JVCl7oZS+2ooEPER99Didpv2tfg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qncIOQlu; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qncIOQlu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47029C3277B; Mon, 6 May 2024 13:36:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715002587; bh=UJcPiw61xTI0GeGTdwGeKs1FkrZi0wwoWTT0pSrYn+M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qncIOQluY79Qw/5vK9cuYeOsaeGHZWh5iJhlSkuk0AhFlvx45q904/jFgmewC0dO/ sDlStiO5wtvFfCRPsmb6qFR5cC071gHejIJL3F2J40kGO/nwipqAiPx+/m4MAkNLwc OaG7V6t0ERjpn+D4wekF0Uck7O6G01DVI7lTslvjuWfY+miffm9Vq9EdikZgHyK+6e Z/VOsswwuhyK4HKJXkE4sq75FMe3gRYzZDsuJ1fP4kZ8qvB3/IarrRJi92bHwlPE5f GAvNvqbUOZcMYT5zsaj/A68h9wy1SxFdd7cjqoB2mUCMp55DeUSeWEwOBBssbi9TTi cmyYgz0UKQ6zw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 1/3] kbuild: provide reasonable defaults for tool coverage Date: Mon, 6 May 2024 22:35:42 +0900 Message-Id: <20240506133544.2861555-2-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240506133544.2861555-1-masahiroy@kernel.org> References: <20240506133544.2861555-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The objtool, sanitizers (KASAN, UBSAN, etc.), and profilers (GCOV, etc.) are intended for kernel space objects. To exclude objects from their coverage, you need to set variables such as OBJECT_FILES_NON_STNDARD=3Dy, KASAN_SANITIZE=3Dn, etc. For instance, the following are not kernel objects, and therefore should opt out of coverage: - vDSO - purgatory - bootloader (arch/*/boot/) Kbuild can detect these cases without relying on such variables because objects not directly linked to vmlinux or modules are considered "non-standard objects". Detecting objects linked to vmlinux or modules is straightforward: - objects added to obj-y are linked to vmlinux - objects added to lib-y are linked to vmlinux - objects added to obj-m are linked to modules In the past, there was yet another case: - object paths added to head-y were linked to vmlinux Commit ce697ccee1a8 ("kbuild: remove head-y syntax") eliminated this. There are still some exceptions. For example, arch/s390/boot/Makefile needlessly uses obj-y for the bootloader objects, which can be fixed later. Going forward, objects that are not listed in obj-y, lib-y, or obj-m will opt out of objtool, sanitizers, and profilers by default. You can still override the Kbuild decision by explicitly specifying OBJECT_FILES_NON_STANDARD, KASAN_SANITIZE, etc. but most of such Make variables can be removed. The next commit will clean up redundant variables. Note: The coverage for some objects will be changed: - exclude .vmlinux.export.o from UBSAN, KCOV - exclude arch/csky/kernel/vdso/vgettimeofday.o from UBSAN - exclude arch/parisc/kernel/vdso32/vdso32.so from UBSAN - exclude arch/parisc/kernel/vdso64/vdso64.so from UBSAN - exclude arch/x86/um/vdso/um_vdso.o from UBSAN - exclude drivers/misc/lkdtm/rodata.o from UBSAN, KCOV - exclude init/version-timestamp.o from UBSAN, KCOV - exclude lib/test_fortify/*.o from all santizers and profilers I believe these are positive effects. Signed-off-by: Masahiro Yamada Reviewed-by: Kees Cook Tested-by: Roberto Sassu --- scripts/Makefile.build | 2 +- scripts/Makefile.lib | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index c9c07a6144eb..56bacd992a09 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -214,7 +214,7 @@ endif # CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT # 'OBJECT_FILES_NON_STANDARD_foo.o :=3D 'y': skip objtool checking for a f= ile # 'OBJECT_FILES_NON_STANDARD_foo.o :=3D 'n': override directory skip for a= file =20 -is-standard-object =3D $(if $(filter-out y%, $(OBJECT_FILES_NON_STANDARD_$= (target-stem).o)$(OBJECT_FILES_NON_STANDARD)n),y) +is-standard-object =3D $(if $(filter-out y%, $(OBJECT_FILES_NON_STANDARD_$= (target-stem).o)$(OBJECT_FILES_NON_STANDARD)n),$(is-kernel-object)) =20 $(obj)/%.o: private objtool-enabled =3D $(if $(is-standard-object),$(if $(= delay-objtool),$(is-single-obj-m),y)) =20 diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 5972ec4ee29b..d3180182af47 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -154,7 +154,7 @@ _cpp_flags =3D $(KBUILD_CPPFLAGS) $(cppflags-y) $(C= PPFLAGS_$(target-stem).lds) # ifeq ($(CONFIG_GCOV_KERNEL),y) _c_flags +=3D $(if $(patsubst n%,, \ - $(GCOV_PROFILE_$(target-stem).o)$(GCOV_PROFILE)$(CONFIG_GCOV_PROFILE_ALL= )), \ + $(GCOV_PROFILE_$(target-stem).o)$(GCOV_PROFILE)$(if $(is-kernel-object),= $(CONFIG_GCOV_PROFILE_ALL))), \ $(CFLAGS_GCOV)) endif =20 @@ -165,32 +165,32 @@ endif ifeq ($(CONFIG_KASAN),y) ifneq ($(CONFIG_KASAN_HW_TAGS),y) _c_flags +=3D $(if $(patsubst n%,, \ - $(KASAN_SANITIZE_$(target-stem).o)$(KASAN_SANITIZE)y), \ + $(KASAN_SANITIZE_$(target-stem).o)$(KASAN_SANITIZE)$(is-kernel-object)),= \ $(CFLAGS_KASAN), $(CFLAGS_KASAN_NOSANITIZE)) endif endif =20 ifeq ($(CONFIG_KMSAN),y) _c_flags +=3D $(if $(patsubst n%,, \ - $(KMSAN_SANITIZE_$(target-stem).o)$(KMSAN_SANITIZE)y), \ + $(KMSAN_SANITIZE_$(target-stem).o)$(KMSAN_SANITIZE)$(is-kernel-object)),= \ $(CFLAGS_KMSAN)) _c_flags +=3D $(if $(patsubst n%,, \ - $(KMSAN_ENABLE_CHECKS_$(target-stem).o)$(KMSAN_ENABLE_CHECKS)y), \ + $(KMSAN_ENABLE_CHECKS_$(target-stem).o)$(KMSAN_ENABLE_CHECKS)$(is-kernel= -object)), \ , -mllvm -msan-disable-checks=3D1) endif =20 ifeq ($(CONFIG_UBSAN),y) _c_flags +=3D $(if $(patsubst n%,, \ - $(UBSAN_SANITIZE_$(target-stem).o)$(UBSAN_SANITIZE)y), \ + $(UBSAN_SANITIZE_$(target-stem).o)$(UBSAN_SANITIZE)$(is-kernel-object)),= \ $(CFLAGS_UBSAN)) _c_flags +=3D $(if $(patsubst n%,, \ - $(UBSAN_SIGNED_WRAP_$(target-stem).o)$(UBSAN_SANITIZE_$(target-stem).o)$= (UBSAN_SIGNED_WRAP)$(UBSAN_SANITIZE)y), \ + $(UBSAN_SIGNED_WRAP_$(target-stem).o)$(UBSAN_SANITIZE_$(target-stem).o)$= (UBSAN_SIGNED_WRAP)$(UBSAN_SANITIZE)$(is-kernel-object)), \ $(CFLAGS_UBSAN_SIGNED_WRAP)) endif =20 ifeq ($(CONFIG_KCOV),y) _c_flags +=3D $(if $(patsubst n%,, \ - $(KCOV_INSTRUMENT_$(target-stem).o)$(KCOV_INSTRUMENT)$(CONFIG_KCOV_INSTRU= MENT_ALL)), \ + $(KCOV_INSTRUMENT_$(target-stem).o)$(KCOV_INSTRUMENT)$(if $(is-kernel-obj= ect),$(CONFIG_KCOV_INSTRUMENT_ALL))), \ $(CFLAGS_KCOV)) endif =20 @@ -200,7 +200,7 @@ endif # ifeq ($(CONFIG_KCSAN),y) _c_flags +=3D $(if $(patsubst n%,, \ - $(KCSAN_SANITIZE_$(target-stem).o)$(KCSAN_SANITIZE)y), \ + $(KCSAN_SANITIZE_$(target-stem).o)$(KCSAN_SANITIZE)$(is-kernel-object)), \ $(CFLAGS_KCSAN)) # Some uninstrumented files provide implied barriers required to avoid fal= se # positives: set KCSAN_INSTRUMENT_BARRIERS for barrier instrumentation onl= y. @@ -219,6 +219,10 @@ _cpp_flags +=3D $(addprefix -I, $(src) $(obj)) endif endif =20 +# If $(is-kernel-object) is 'y', this object will be linked to vmlinux or = modules +is-kernel-object =3D $(or $(part-of-builtin),$(part-of-module)) + +part-of-builtin =3D $(if $(filter $(basename $@).o, $(real-obj-y) $(lib-y)= ),y) part-of-module =3D $(if $(filter $(basename $@).o, $(real-obj-m)),y) quiet_modtag =3D $(if $(part-of-module),[M], ) =20 --=20 2.40.1 From nobody Mon Feb 9 05:52:11 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF36D86268; Mon, 6 May 2024 13:36:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715002589; cv=none; b=UE0tEIZoXpNzfCt/OmtDM5fXSSF6o3eiRpd6/6UNoectG3m7a6fzMYDly2Bx7DuctKsCQFOzmqy0/C97vCze0JiWK9ySjBx4DcYZErewwOTa5nLi5Y7zEggM8CBlEwbrr6P5tU5HGFfq/H2Adguy8k0MH3ZwgGSfjfi9RHnO23c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715002589; c=relaxed/simple; bh=CfFp9hEAOPT0198pXbg/EJ6COlQrGk6vxz6F4gVUhA8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HES1myswdR/kjCEeQstD7zunnmvk8qG6NLF3QZjAXywsV3qdliXIB2YmDCraa4gblTOX7oCXL5NR+i0/ewe1/ENG1hwUgaOVjpOY3/oRoIgrnMHeVC0gsP4Mj4AvwPCx0XzvUNzgIC0oEuIhP2MKFb5Gu9AX8lpwjOrUvKIkDOE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QBmws5/F; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QBmws5/F" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B887BC4AF63; Mon, 6 May 2024 13:36:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715002588; bh=CfFp9hEAOPT0198pXbg/EJ6COlQrGk6vxz6F4gVUhA8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QBmws5/Fu1QaGnFhdS0z+pL5Dxyn+pSNliEezIEa2TzN3g/q519ZQM2onPUHfoBMM FvRdVOEra6XOf5+MjpxxJKwaoeSnwzZpIRg8H/BAuQRRVi3dqi936DY2/SqZF7SL2L TfUfFqqI805KgSK4/6HxZUjvdqJX09/BShnZFObXUHUScwAUqTSoCe69BRDTlpOaSe pKBsDoyQp/XTkjQ7sDdDFfercAPzNluWXBcpiKT2V71W8QB+12DFIuHocIe9yO3/LD kUkgrm0AjFmjxRk4rTeiRx9cml2RDZ+NgcO8jo2lz7+fEUKs1h9OamVul9Rq/jmGjE JwonlllCRrqJw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 2/3] Makefile: remove redundant tool coverage variables Date: Mon, 6 May 2024 22:35:43 +0900 Message-Id: <20240506133544.2861555-3-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240506133544.2861555-1-masahiroy@kernel.org> References: <20240506133544.2861555-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Now Kbuild provides reasonable defaults for objtool, sanitizers, and profilers. Remove redundant variables. Note: The coverage for some objects will be changed: - include arch/mips/vdso/vdso-image.o into UBSAN, GCOV, KCOV - include arch/sparc/vdso/vdso-image-*.o into UBSAN - include arch/sparc/vdso/vma.o into UBSAN - include arch/x86/entry/vdso/extable.o into KASAN, KCSAN, UBSAN, GCOV, K= COV - include arch/x86/entry/vdso/vdso-image-*.o into KASAN, KCSAN, UBSAN, GC= OV, KCOV - include arch/x86/entry/vdso/vdso32-setup.o into KASAN, KCSAN, UBSAN, GC= OV, KCOV - include arch/x86/entry/vdso/vma.o into GCOV, KCOV - include arch/x86/um/vdso/vma.o into KASAN, GCOV, KCOV I believe these are positive effects because all of them are kernel space objects. Signed-off-by: Masahiro Yamada Reviewed-by: Kees Cook Tested-by: Roberto Sassu --- arch/arm/boot/bootp/Makefile | 1 - arch/arm/boot/compressed/Makefile | 7 ------- arch/arm/vdso/Makefile | 9 --------- arch/arm64/kernel/pi/Makefile | 6 ------ arch/arm64/kernel/vdso/Makefile | 8 -------- arch/arm64/kvm/hyp/nvhe/Makefile | 13 ------------- arch/csky/kernel/vdso/Makefile | 4 ---- arch/loongarch/vdso/Makefile | 7 ------- arch/mips/boot/compressed/Makefile | 6 ------ arch/mips/vdso/Makefile | 7 ------- arch/parisc/boot/compressed/Makefile | 4 ---- arch/powerpc/kernel/vdso/Makefile | 8 -------- arch/powerpc/purgatory/Makefile | 3 --- arch/riscv/boot/Makefile | 2 -- arch/riscv/kernel/compat_vdso/Makefile | 6 ------ arch/riscv/kernel/pi/Makefile | 6 ------ arch/riscv/kernel/vdso/Makefile | 6 ------ arch/riscv/purgatory/Makefile | 8 -------- arch/s390/boot/Makefile | 2 ++ arch/s390/kernel/vdso32/Makefile | 8 -------- arch/s390/kernel/vdso64/Makefile | 8 -------- arch/s390/purgatory/Makefile | 8 -------- arch/sh/boot/compressed/Makefile | 3 --- arch/sparc/vdso/Makefile | 2 -- arch/x86/boot/Makefile | 15 --------------- arch/x86/boot/compressed/Makefile | 11 ----------- arch/x86/entry/vdso/Makefile | 26 -------------------------- arch/x86/purgatory/Makefile | 9 --------- arch/x86/realmode/rm/Makefile | 11 ----------- arch/x86/um/vdso/Makefile | 7 ------- arch/xtensa/boot/lib/Makefile | 5 ----- drivers/firmware/efi/libstub/Makefile | 11 ----------- drivers/misc/lkdtm/Makefile | 4 ---- init/Makefile | 3 --- scripts/Makefile.vmlinux | 3 --- scripts/mod/Makefile | 1 - 36 files changed, 2 insertions(+), 246 deletions(-) diff --git a/arch/arm/boot/bootp/Makefile b/arch/arm/boot/bootp/Makefile index a2934e6fd89a..f3443f7d7b02 100644 --- a/arch/arm/boot/bootp/Makefile +++ b/arch/arm/boot/bootp/Makefile @@ -5,7 +5,6 @@ # This file is included by the global makefile so that you can add your own # architecture-specific flags and dependencies. # -GCOV_PROFILE :=3D n =20 ifdef PHYS_OFFSET add_hex =3D $(shell printf 0x%x $$(( $(1) + $(2) )) ) diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/M= akefile index 726ecabcef09..6bca03c0c7f0 100644 --- a/arch/arm/boot/compressed/Makefile +++ b/arch/arm/boot/compressed/Makefile @@ -22,13 +22,6 @@ ifeq ($(CONFIG_ARM_VIRT_EXT),y) OBJS +=3D hyp-stub.o endif =20 -GCOV_PROFILE :=3D n -KASAN_SANITIZE :=3D n - -# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in. -KCOV_INSTRUMENT :=3D n -UBSAN_SANITIZE :=3D n - # # Architecture dependencies # diff --git a/arch/arm/vdso/Makefile b/arch/arm/vdso/Makefile index d761bd2e2f40..01067a2bc43b 100644 --- a/arch/arm/vdso/Makefile +++ b/arch/arm/vdso/Makefile @@ -33,15 +33,6 @@ else CFLAGS_vgettimeofday.o =3D -O2 -include $(c-gettimeofday-y) endif =20 -# Disable gcov profiling for VDSO code -GCOV_PROFILE :=3D n -UBSAN_SANITIZE :=3D n - -# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in. -KCOV_INSTRUMENT :=3D n - -KASAN_SANITIZE :=3D n - # Force dependency $(obj)/vdso.o : $(obj)/vdso.so =20 diff --git a/arch/arm64/kernel/pi/Makefile b/arch/arm64/kernel/pi/Makefile index 4393b41f0b71..4d11a8c29181 100644 --- a/arch/arm64/kernel/pi/Makefile +++ b/arch/arm64/kernel/pi/Makefile @@ -19,12 +19,6 @@ KBUILD_CFLAGS :=3D $(filter-out $(CC_FLAGS_SCS), $(KBUIL= D_CFLAGS)) # disable LTO KBUILD_CFLAGS :=3D $(filter-out $(CC_FLAGS_LTO), $(KBUILD_CFLAGS)) =20 -GCOV_PROFILE :=3D n -KASAN_SANITIZE :=3D n -KCSAN_SANITIZE :=3D n -UBSAN_SANITIZE :=3D n -KCOV_INSTRUMENT :=3D n - hostprogs :=3D relacheck =20 quiet_cmd_piobjcopy =3D $(quiet_cmd_objcopy) diff --git a/arch/arm64/kernel/vdso/Makefile b/arch/arm64/kernel/vdso/Makef= ile index 53e86d3bc159..d63930c82839 100644 --- a/arch/arm64/kernel/vdso/Makefile +++ b/arch/arm64/kernel/vdso/Makefile @@ -40,11 +40,6 @@ CFLAGS_REMOVE_vgettimeofday.o =3D $(CC_FLAGS_FTRACE) -Os= $(CC_FLAGS_SCS) \ $(RANDSTRUCT_CFLAGS) $(GCC_PLUGINS_CFLAGS) \ $(CC_FLAGS_LTO) $(CC_FLAGS_CFI) \ -Wmissing-prototypes -Wmissing-declarations -KASAN_SANITIZE :=3D n -KCSAN_SANITIZE :=3D n -UBSAN_SANITIZE :=3D n -OBJECT_FILES_NON_STANDARD :=3D y -KCOV_INSTRUMENT :=3D n =20 CFLAGS_vgettimeofday.o =3D -O2 -mcmodel=3Dtiny -fasynchronous-unwind-tables =20 @@ -52,9 +47,6 @@ ifneq ($(c-gettimeofday-y),) CFLAGS_vgettimeofday.o +=3D -include $(c-gettimeofday-y) endif =20 -# Disable gcov profiling for VDSO code -GCOV_PROFILE :=3D n - targets +=3D vdso.lds CPPFLAGS_vdso.lds +=3D -P -C -U$(ARCH) =20 diff --git a/arch/arm64/kvm/hyp/nvhe/Makefile b/arch/arm64/kvm/hyp/nvhe/Mak= efile index 2250253a6429..50fa0ffb6b7e 100644 --- a/arch/arm64/kvm/hyp/nvhe/Makefile +++ b/arch/arm64/kvm/hyp/nvhe/Makefile @@ -97,16 +97,3 @@ KBUILD_CFLAGS :=3D $(filter-out $(CC_FLAGS_FTRACE) $(CC_= FLAGS_SCS) $(CC_FLAGS_CFI) # causes a build failure. Remove profile optimization flags. KBUILD_CFLAGS :=3D $(filter-out -fprofile-sample-use=3D% -fprofile-use=3D%= , $(KBUILD_CFLAGS)) KBUILD_CFLAGS +=3D -fno-asynchronous-unwind-tables -fno-unwind-tables - -# KVM nVHE code is run at a different exception code with a different map,= so -# compiler instrumentation that inserts callbacks or checks into the code = may -# cause crashes. Just disable it. -GCOV_PROFILE :=3D n -KASAN_SANITIZE :=3D n -KCSAN_SANITIZE :=3D n -UBSAN_SANITIZE :=3D n -KCOV_INSTRUMENT :=3D n - -# Skip objtool checking for this directory because nVHE code is compiled w= ith -# non-standard build rules. -OBJECT_FILES_NON_STANDARD :=3D y diff --git a/arch/csky/kernel/vdso/Makefile b/arch/csky/kernel/vdso/Makefile index e79a725f5075..bc2261f5a8d4 100644 --- a/arch/csky/kernel/vdso/Makefile +++ b/arch/csky/kernel/vdso/Makefile @@ -23,10 +23,6 @@ obj-vdso :=3D $(addprefix $(obj)/, $(obj-vdso)) obj-y +=3D vdso.o vdso-syms.o CPPFLAGS_vdso.lds +=3D -P -C -U$(ARCH) =20 -# Disable gcov profiling for VDSO code -GCOV_PROFILE :=3D n -KCOV_INSTRUMENT :=3D n - # Force dependency $(obj)/vdso.o: $(obj)/vdso.so =20 diff --git a/arch/loongarch/vdso/Makefile b/arch/loongarch/vdso/Makefile index cdfc4c793e2c..d724d46b07c8 100644 --- a/arch/loongarch/vdso/Makefile +++ b/arch/loongarch/vdso/Makefile @@ -1,11 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 # Objects to go into the VDSO. =20 -KASAN_SANITIZE :=3D n -UBSAN_SANITIZE :=3D n -KCOV_INSTRUMENT :=3D n -OBJECT_FILES_NON_STANDARD :=3D y - # Include the generic Makefile to check the built vdso. include $(srctree)/lib/vdso/Makefile =20 @@ -39,8 +34,6 @@ ldflags-y :=3D -Bsymbolic --no-undefined -soname=3Dlinux-= vdso.so.1 \ $(filter -E%,$(KBUILD_CFLAGS)) -nostdlib -shared \ --hash-style=3Dsysv --build-id -T =20 -GCOV_PROFILE :=3D n - # # Shared build commands. # diff --git a/arch/mips/boot/compressed/Makefile b/arch/mips/boot/compressed= /Makefile index 6cc28173bee8..e0b8ec9a9516 100644 --- a/arch/mips/boot/compressed/Makefile +++ b/arch/mips/boot/compressed/Makefile @@ -34,12 +34,6 @@ KBUILD_AFLAGS :=3D $(KBUILD_AFLAGS) -D__ASSEMBLY__ \ -DBOOT_HEAP_SIZE=3D$(BOOT_HEAP_SIZE) \ -DKERNEL_ENTRY=3D$(VMLINUX_ENTRY_ADDRESS) =20 -# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in. -KCOV_INSTRUMENT :=3D n -GCOV_PROFILE :=3D n -UBSAN_SANITIZE :=3D n -KCSAN_SANITIZE :=3D n - # decompressor objects (linked with vmlinuz) vmlinuzobjs-y :=3D $(obj)/head.o $(obj)/decompress.o $(obj)/string.o $(obj= )/bswapsi.o =20 diff --git a/arch/mips/vdso/Makefile b/arch/mips/vdso/Makefile index 40b839e91806..b289b2c1b294 100644 --- a/arch/mips/vdso/Makefile +++ b/arch/mips/vdso/Makefile @@ -1,9 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 # Objects to go into the VDSO. =20 -# Sanitizer runtimes are unavailable and cannot be linked here. - KCSAN_SANITIZE :=3D n - # Include the generic Makefile to check the built vdso. include $(srctree)/lib/vdso/Makefile =20 @@ -60,10 +57,6 @@ ldflags-y :=3D -Bsymbolic --no-undefined -soname=3Dlinux= -vdso.so.1 \ =20 CFLAGS_REMOVE_vdso.o =3D $(CC_FLAGS_FTRACE) =20 -GCOV_PROFILE :=3D n -UBSAN_SANITIZE :=3D n -KCOV_INSTRUMENT :=3D n - # Check that we don't have PIC 'jalr t9' calls left quiet_cmd_vdso_mips_check =3D VDSOCHK $@ cmd_vdso_mips_check =3D if $(OBJDUMP) --disassemble $@ | grep -E -h = "jalr.*t9" > /dev/null; \ diff --git a/arch/parisc/boot/compressed/Makefile b/arch/parisc/boot/compre= ssed/Makefile index a294a1b58ee7..92227fa813dc 100644 --- a/arch/parisc/boot/compressed/Makefile +++ b/arch/parisc/boot/compressed/Makefile @@ -5,10 +5,6 @@ # create a compressed self-extracting vmlinux image from the original vmli= nux # =20 -KCOV_INSTRUMENT :=3D n -GCOV_PROFILE :=3D n -UBSAN_SANITIZE :=3D n - OBJECTS :=3D head.o real2.o firmware.o misc.o piggy.o targets :=3D vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 targets +=3D vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.l= z4 diff --git a/arch/powerpc/kernel/vdso/Makefile b/arch/powerpc/kernel/vdso/M= akefile index 7d66b6e07993..1425b6edc66b 100644 --- a/arch/powerpc/kernel/vdso/Makefile +++ b/arch/powerpc/kernel/vdso/Makefile @@ -47,12 +47,6 @@ obj-vdso32 :=3D $(addprefix $(obj)/, $(obj-vdso32)) targets +=3D $(obj-vdso64) vdso64.so.dbg vgettimeofday-64.o obj-vdso64 :=3D $(addprefix $(obj)/, $(obj-vdso64)) =20 -GCOV_PROFILE :=3D n -KCOV_INSTRUMENT :=3D n -UBSAN_SANITIZE :=3D n -KASAN_SANITIZE :=3D n -KCSAN_SANITIZE :=3D n - ccflags-y :=3D -fno-common -fno-builtin ldflags-y :=3D -Wl,--hash-style=3Dboth -nostdlib -shared -z noexecstack $(= CLANG_FLAGS) ldflags-$(CONFIG_LD_IS_LLD) +=3D $(call cc-option,--ld-path=3D$(LD),-fuse-= ld=3Dlld) @@ -114,5 +108,3 @@ quiet_cmd_vdso64ld_and_check =3D VDSO64L $@ cmd_vdso64ld_and_check =3D $(VDSOCC) $(ldflags-y) $(LD64FLAGS) -o $@= -Wl,-T$(filter %.lds,$^) $(filter %.o,$^); $(cmd_vdso_check) quiet_cmd_vdso64as =3D VDSO64A $@ cmd_vdso64as =3D $(VDSOCC) $(a_flags) $(AS64FLAGS) -c -o $@ $< - -OBJECT_FILES_NON_STANDARD :=3D y diff --git a/arch/powerpc/purgatory/Makefile b/arch/powerpc/purgatory/Makef= ile index 78473d69cd2b..e9890085953e 100644 --- a/arch/powerpc/purgatory/Makefile +++ b/arch/powerpc/purgatory/Makefile @@ -1,8 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 =20 -KASAN_SANITIZE :=3D n -KCSAN_SANITIZE :=3D n - targets +=3D trampoline_$(BITS).o purgatory.ro =20 # When profile-guided optimization is enabled, llvm emits two different diff --git a/arch/riscv/boot/Makefile b/arch/riscv/boot/Makefile index 8e7fc0edf21d..869c0345b908 100644 --- a/arch/riscv/boot/Makefile +++ b/arch/riscv/boot/Makefile @@ -14,8 +14,6 @@ # Based on the ia64 and arm64 boot/Makefile. # =20 -KCOV_INSTRUMENT :=3D n - OBJCOPYFLAGS_Image :=3D-O binary -R .note -R .note.gnu.build-id -R .commen= t -S OBJCOPYFLAGS_loader.bin :=3D-O binary OBJCOPYFLAGS_xipImage :=3D-O binary -R .note -R .note.gnu.build-id -R .com= ment -S diff --git a/arch/riscv/kernel/compat_vdso/Makefile b/arch/riscv/kernel/com= pat_vdso/Makefile index 362208dfa7ee..24e37d1ef7ec 100644 --- a/arch/riscv/kernel/compat_vdso/Makefile +++ b/arch/riscv/kernel/compat_vdso/Makefile @@ -34,12 +34,6 @@ obj-compat_vdso :=3D $(addprefix $(obj)/, $(obj-compat_v= dso)) obj-y +=3D compat_vdso.o CPPFLAGS_compat_vdso.lds +=3D -P -C -DCOMPAT_VDSO -U$(ARCH) =20 -# Disable profiling and instrumentation for VDSO code -GCOV_PROFILE :=3D n -KCOV_INSTRUMENT :=3D n -KASAN_SANITIZE :=3D n -UBSAN_SANITIZE :=3D n - # Force dependency $(obj)/compat_vdso.o: $(obj)/compat_vdso.so =20 diff --git a/arch/riscv/kernel/pi/Makefile b/arch/riscv/kernel/pi/Makefile index b75f150b923d..50bc5ef7dd2f 100644 --- a/arch/riscv/kernel/pi/Makefile +++ b/arch/riscv/kernel/pi/Makefile @@ -17,12 +17,6 @@ KBUILD_CFLAGS +=3D -mcmodel=3Dmedany CFLAGS_cmdline_early.o +=3D -D__NO_FORTIFY CFLAGS_lib-fdt_ro.o +=3D -D__NO_FORTIFY =20 -GCOV_PROFILE :=3D n -KASAN_SANITIZE :=3D n -KCSAN_SANITIZE :=3D n -UBSAN_SANITIZE :=3D n -KCOV_INSTRUMENT :=3D n - $(obj)/%.pi.o: OBJCOPYFLAGS :=3D --prefix-symbols=3D__pi_ \ --remove-section=3D.note.gnu.property \ --prefix-alloc-sections=3D.init.pi diff --git a/arch/riscv/kernel/vdso/Makefile b/arch/riscv/kernel/vdso/Makef= ile index 25f0ee629971..f7ef8ad9b550 100644 --- a/arch/riscv/kernel/vdso/Makefile +++ b/arch/riscv/kernel/vdso/Makefile @@ -39,12 +39,6 @@ endif CFLAGS_REMOVE_vgettimeofday.o =3D $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS) CFLAGS_REMOVE_hwprobe.o =3D $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS) =20 -# Disable profiling and instrumentation for VDSO code -GCOV_PROFILE :=3D n -KCOV_INSTRUMENT :=3D n -KASAN_SANITIZE :=3D n -UBSAN_SANITIZE :=3D n - # Force dependency $(obj)/vdso.o: $(obj)/vdso.so =20 diff --git a/arch/riscv/purgatory/Makefile b/arch/riscv/purgatory/Makefile index 280b0eb352b8..f11945ee2490 100644 --- a/arch/riscv/purgatory/Makefile +++ b/arch/riscv/purgatory/Makefile @@ -1,5 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 -OBJECT_FILES_NON_STANDARD :=3D y =20 purgatory-y :=3D purgatory.o sha256.o entry.o string.o ctype.o memcpy.o me= mset.o purgatory-y +=3D strcmp.o strlen.o strncmp.o @@ -47,13 +46,6 @@ LDFLAGS_purgatory.ro :=3D -r $(PURGATORY_LDFLAGS) LDFLAGS_purgatory.chk :=3D $(PURGATORY_LDFLAGS) targets +=3D purgatory.ro purgatory.chk =20 -# Sanitizer, etc. runtimes are unavailable and cannot be linked here. -GCOV_PROFILE :=3D n -KASAN_SANITIZE :=3D n -UBSAN_SANITIZE :=3D n -KCSAN_SANITIZE :=3D n -KCOV_INSTRUMENT :=3D n - # These are adjustments to the compiler flags used for objects that # make up the standalone purgatory.ro =20 diff --git a/arch/s390/boot/Makefile b/arch/s390/boot/Makefile index 294f08a8811a..5a10c4fa4b24 100644 --- a/arch/s390/boot/Makefile +++ b/arch/s390/boot/Makefile @@ -3,6 +3,8 @@ # Makefile for the linux s390-specific parts of the memory manager. # =20 +# These must be disabled explicitly because this Makefile uses obj-y +# for bootloader objects. KCOV_INSTRUMENT :=3D n GCOV_PROFILE :=3D n UBSAN_SANITIZE :=3D n diff --git a/arch/s390/kernel/vdso32/Makefile b/arch/s390/kernel/vdso32/Mak= efile index c263b91adfb1..df928fee26b5 100644 --- a/arch/s390/kernel/vdso32/Makefile +++ b/arch/s390/kernel/vdso32/Makefile @@ -1,8 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 # List of files in the vdso =20 -KCOV_INSTRUMENT :=3D n - # Include the generic Makefile to check the built vdso. include $(srctree)/lib/vdso/Makefile obj-vdso32 =3D vdso_user_wrapper-32.o note-32.o @@ -32,12 +30,6 @@ obj-y +=3D vdso32_wrapper.o targets +=3D vdso32.lds CPPFLAGS_vdso32.lds +=3D -P -C -U$(ARCH) =20 -# Disable gcov profiling, ubsan and kasan for VDSO code -GCOV_PROFILE :=3D n -UBSAN_SANITIZE :=3D n -KASAN_SANITIZE :=3D n -KCSAN_SANITIZE :=3D n - # Force dependency (incbin is bad) $(obj)/vdso32_wrapper.o : $(obj)/vdso32.so =20 diff --git a/arch/s390/kernel/vdso64/Makefile b/arch/s390/kernel/vdso64/Mak= efile index 9566bed7d5b2..6da1b9ad8ab0 100644 --- a/arch/s390/kernel/vdso64/Makefile +++ b/arch/s390/kernel/vdso64/Makefile @@ -1,8 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 # List of files in the vdso =20 -KCOV_INSTRUMENT :=3D n - # Include the generic Makefile to check the built vdso. include $(srctree)/lib/vdso/Makefile obj-vdso64 =3D vdso_user_wrapper.o note.o @@ -37,12 +35,6 @@ obj-y +=3D vdso64_wrapper.o targets +=3D vdso64.lds CPPFLAGS_vdso64.lds +=3D -P -C -U$(ARCH) =20 -# Disable gcov profiling, ubsan and kasan for VDSO code -GCOV_PROFILE :=3D n -UBSAN_SANITIZE :=3D n -KASAN_SANITIZE :=3D n -KCSAN_SANITIZE :=3D n - # Force dependency (incbin is bad) $(obj)/vdso64_wrapper.o : $(obj)/vdso64.so =20 diff --git a/arch/s390/purgatory/Makefile b/arch/s390/purgatory/Makefile index 4e930f566878..24eccaa29337 100644 --- a/arch/s390/purgatory/Makefile +++ b/arch/s390/purgatory/Makefile @@ -1,7 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 =20 -OBJECT_FILES_NON_STANDARD :=3D y - purgatory-y :=3D head.o purgatory.o string.o sha256.o mem.o =20 targets +=3D $(purgatory-y) purgatory.lds purgatory purgatory.chk purgator= y.ro @@ -15,12 +13,6 @@ CFLAGS_sha256.o :=3D -D__DISABLE_EXPORTS -D__NO_FORTIFY $(obj)/mem.o: $(srctree)/arch/s390/lib/mem.S FORCE $(call if_changed_rule,as_o_S) =20 -KCOV_INSTRUMENT :=3D n -GCOV_PROFILE :=3D n -UBSAN_SANITIZE :=3D n -KASAN_SANITIZE :=3D n -KCSAN_SANITIZE :=3D n - KBUILD_CFLAGS :=3D -fno-strict-aliasing -Wall -Wstrict-prototypes KBUILD_CFLAGS +=3D -Wno-pointer-sign -Wno-sign-compare KBUILD_CFLAGS +=3D -fno-zero-initialized-in-bss -fno-builtin -ffreestanding diff --git a/arch/sh/boot/compressed/Makefile b/arch/sh/boot/compressed/Mak= efile index 6c6c791a1d06..3a46b871463d 100644 --- a/arch/sh/boot/compressed/Makefile +++ b/arch/sh/boot/compressed/Makefile @@ -11,9 +11,6 @@ OBJECTS :=3D head_32.o misc.o cache.o piggy.o \ targets :=3D vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 \ vmlinux.bin.lzma vmlinux.bin.xz vmlinux.bin.lzo $(OBJECTS) =20 -GCOV_PROFILE :=3D n -UBSAN_SANITIZE :=3D n - # # IMAGE_OFFSET is the load offset of the compression loader # diff --git a/arch/sparc/vdso/Makefile b/arch/sparc/vdso/Makefile index 0fe134abbcf1..243dbfc4609d 100644 --- a/arch/sparc/vdso/Makefile +++ b/arch/sparc/vdso/Makefile @@ -2,7 +2,6 @@ # # Building vDSO images for sparc. # -UBSAN_SANITIZE :=3D n =20 # files to link into the vdso vobjs-y :=3D vdso-note.o vclock_gettime.o @@ -106,4 +105,3 @@ quiet_cmd_vdso =3D VDSO $@ sh $(src)/checkundef.sh '$(OBJDUMP)' '$@' =20 VDSO_LDFLAGS =3D -shared --hash-style=3Dboth --build-id=3Dsha1 -Bsymbolic -GCOV_PROFILE :=3D n diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile index 29cda98c65f8..1cf24ff6acac 100644 --- a/arch/x86/boot/Makefile +++ b/arch/x86/boot/Makefile @@ -9,19 +9,6 @@ # Changed by many, many contributors over the years. # =20 -# Sanitizer runtimes are unavailable and cannot be linked for early boot c= ode. -KASAN_SANITIZE :=3D n -KCSAN_SANITIZE :=3D n -KMSAN_SANITIZE :=3D n -OBJECT_FILES_NON_STANDARD :=3D y - -# Kernel does not boot with kcov instrumentation here. -# One of the problems observed was insertion of __sanitizer_cov_trace_pc() -# callback into middle of per-cpu data enabling code. Thus the callback ob= served -# inconsistent state and crashed. We are interested mostly in syscall cove= rage, -# so boot code is not interesting anyway. -KCOV_INSTRUMENT :=3D n - # If you want to preset the SVGA mode, uncomment the next line and # set SVGA_MODE to whatever number you want. # Set it to -DSVGA_MODE=3DNORMAL_VGA if you just want the EGA/VGA mode. @@ -69,8 +56,6 @@ KBUILD_CFLAGS :=3D $(REALMODE_CFLAGS) -D_SETUP KBUILD_AFLAGS :=3D $(KBUILD_CFLAGS) -D__ASSEMBLY__ KBUILD_CFLAGS +=3D $(call cc-option,-fmacro-prefix-map=3D$(srctree)/=3D) KBUILD_CFLAGS +=3D -fno-asynchronous-unwind-tables -GCOV_PROFILE :=3D n -UBSAN_SANITIZE :=3D n =20 $(obj)/bzImage: asflags-y :=3D $(SVGA_MODE) =20 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/M= akefile index e9522c6893be..243ee86cb1b1 100644 --- a/arch/x86/boot/compressed/Makefile +++ b/arch/x86/boot/compressed/Makefile @@ -17,15 +17,6 @@ # (see scripts/Makefile.lib size_append) # compressed vmlinux.bin.all + u32 size of vmlinux.bin.all =20 -# Sanitizer runtimes are unavailable and cannot be linked for early boot c= ode. -KASAN_SANITIZE :=3D n -KCSAN_SANITIZE :=3D n -KMSAN_SANITIZE :=3D n -OBJECT_FILES_NON_STANDARD :=3D y - -# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in. -KCOV_INSTRUMENT :=3D n - targets :=3D vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bi= n.lzma \ vmlinux.bin.xz vmlinux.bin.lzo vmlinux.bin.lz4 vmlinux.bin.zst =20 @@ -59,8 +50,6 @@ KBUILD_CFLAGS +=3D -include $(srctree)/include/linux/hidd= en.h CFLAGS_sev.o +=3D -I$(objtree)/arch/x86/lib/ =20 KBUILD_AFLAGS :=3D $(KBUILD_CFLAGS) -D__ASSEMBLY__ -GCOV_PROFILE :=3D n -UBSAN_SANITIZE :=3Dn =20 KBUILD_LDFLAGS :=3D -m elf_$(UTS_MACHINE) KBUILD_LDFLAGS +=3D $(call ld-option,--no-ld-generated-unwind-info) diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile index c003452dba8c..215a1b202a91 100644 --- a/arch/x86/entry/vdso/Makefile +++ b/arch/x86/entry/vdso/Makefile @@ -6,20 +6,6 @@ # Include the generic Makefile to check the built vDSO: include $(srctree)/lib/vdso/Makefile =20 -# Sanitizer runtimes are unavailable and cannot be linked here. -KASAN_SANITIZE :=3D n -KMSAN_SANITIZE_vclock_gettime.o :=3D n -KMSAN_SANITIZE_vdso32/vclock_gettime.o :=3D n -KMSAN_SANITIZE_vgetcpu.o :=3D n -KMSAN_SANITIZE_vdso32/vgetcpu.o :=3D n - -UBSAN_SANITIZE :=3D n -KCSAN_SANITIZE :=3D n -OBJECT_FILES_NON_STANDARD :=3D y - -# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in. -KCOV_INSTRUMENT :=3D n - # Files to link into the vDSO: vobjs-y :=3D vdso-note.o vclock_gettime.o vgetcpu.o vobjs32-y :=3D vdso32/note.o vdso32/system_call.o vdso32/sigreturn.o @@ -28,23 +14,12 @@ vobjs-$(CONFIG_X86_SGX) +=3D vsgx.o =20 # Files to link into the kernel: obj-y +=3D vma.o extable.o -KASAN_SANITIZE_vma.o :=3D y -UBSAN_SANITIZE_vma.o :=3D y -KCSAN_SANITIZE_vma.o :=3D y - -OBJECT_FILES_NON_STANDARD_vma.o :=3D n -OBJECT_FILES_NON_STANDARD_extable.o :=3D n =20 # vDSO images to build: obj-$(CONFIG_X86_64) +=3D vdso-image-64.o obj-$(CONFIG_X86_X32_ABI) +=3D vdso-image-x32.o obj-$(CONFIG_COMPAT_32) +=3D vdso-image-32.o vdso32-setup.o =20 -OBJECT_FILES_NON_STANDARD_vdso-image-32.o :=3D n -OBJECT_FILES_NON_STANDARD_vdso-image-x32.o :=3D n -OBJECT_FILES_NON_STANDARD_vdso-image-64.o :=3D n -OBJECT_FILES_NON_STANDARD_vdso32-setup.o :=3D n - vobjs :=3D $(addprefix $(obj)/, $(vobjs-y)) vobjs32 :=3D $(addprefix $(obj)/, $(vobjs32-y)) =20 @@ -180,7 +155,6 @@ quiet_cmd_vdso =3D VDSO $@ =20 VDSO_LDFLAGS =3D -shared --hash-style=3Dboth --build-id=3Dsha1 \ $(call ld-option, --eh-frame-hdr) -Bsymbolic -z noexecstack -GCOV_PROFILE :=3D n =20 quiet_cmd_vdso_and_check =3D VDSO $@ cmd_vdso_and_check =3D $(cmd_vdso); $(cmd_vdso_check) diff --git a/arch/x86/purgatory/Makefile b/arch/x86/purgatory/Makefile index bc31863c5ee6..0a16f1373cf5 100644 --- a/arch/x86/purgatory/Makefile +++ b/arch/x86/purgatory/Makefile @@ -1,5 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 -OBJECT_FILES_NON_STANDARD :=3D y =20 purgatory-y :=3D purgatory.o stack.o setup-x86_$(BITS).o sha256.o entry64.= o string.o =20 @@ -30,14 +29,6 @@ LDFLAGS_purgatory.ro :=3D -r $(PURGATORY_LDFLAGS) LDFLAGS_purgatory.chk :=3D $(PURGATORY_LDFLAGS) targets +=3D purgatory.ro purgatory.chk =20 -# Sanitizer, etc. runtimes are unavailable and cannot be linked here. -GCOV_PROFILE :=3D n -KASAN_SANITIZE :=3D n -UBSAN_SANITIZE :=3D n -KCSAN_SANITIZE :=3D n -KMSAN_SANITIZE :=3D n -KCOV_INSTRUMENT :=3D n - # These are adjustments to the compiler flags used for objects that # make up the standalone purgatory.ro =20 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile index f614009d3e4e..a0fb39abc5c8 100644 --- a/arch/x86/realmode/rm/Makefile +++ b/arch/x86/realmode/rm/Makefile @@ -7,15 +7,6 @@ # # =20 -# Sanitizer runtimes are unavailable and cannot be linked here. -KASAN_SANITIZE :=3D n -KCSAN_SANITIZE :=3D n -KMSAN_SANITIZE :=3D n -OBJECT_FILES_NON_STANDARD :=3D y - -# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in. -KCOV_INSTRUMENT :=3D n - always-y :=3D realmode.bin realmode.relocs =20 wakeup-objs :=3D wakeup_asm.o wakemain.o video-mode.o @@ -76,5 +67,3 @@ KBUILD_CFLAGS :=3D $(REALMODE_CFLAGS) -D_SETUP -D_WAKEUP \ -I$(srctree)/arch/x86/boot KBUILD_AFLAGS :=3D $(KBUILD_CFLAGS) -D__ASSEMBLY__ KBUILD_CFLAGS +=3D -fno-asynchronous-unwind-tables -GCOV_PROFILE :=3D n -UBSAN_SANITIZE :=3D n diff --git a/arch/x86/um/vdso/Makefile b/arch/x86/um/vdso/Makefile index 2303fa59971c..6a77ea6434ff 100644 --- a/arch/x86/um/vdso/Makefile +++ b/arch/x86/um/vdso/Makefile @@ -3,12 +3,6 @@ # Building vDSO images for x86. # =20 -# do not instrument on vdso because KASAN is not compatible with user mode -KASAN_SANITIZE :=3D n - -# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in. -KCOV_INSTRUMENT :=3D n - VDSO64-y :=3D y =20 vdso-install-$(VDSO64-y) +=3D vdso.so @@ -66,4 +60,3 @@ quiet_cmd_vdso =3D VDSO $@ sh $(src)/checkundef.sh '$(NM)' '$@' =20 VDSO_LDFLAGS =3D -fPIC -shared -Wl,--hash-style=3Dsysv -z noexecstack -GCOV_PROFILE :=3D n diff --git a/arch/xtensa/boot/lib/Makefile b/arch/xtensa/boot/lib/Makefile index 0378a22a08e3..39e1ef0f9d15 100644 --- a/arch/xtensa/boot/lib/Makefile +++ b/arch/xtensa/boot/lib/Makefile @@ -15,11 +15,6 @@ CFLAGS_REMOVE_inftrees.o =3D -pg CFLAGS_REMOVE_inffast.o =3D -pg endif =20 -KASAN_SANITIZE :=3D n -KCSAN_SANITIZE :=3D n -KCOV_INSTRUMENT :=3D n -GCOV_PROFILE :=3D n - CFLAGS_REMOVE_inflate.o +=3D -fstack-protector -fstack-protector-strong CFLAGS_REMOVE_zmem.o +=3D -fstack-protector -fstack-protector-strong CFLAGS_REMOVE_inftrees.o +=3D -fstack-protector -fstack-protector-strong diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/l= ibstub/Makefile index 31eb1e287ce1..06f0428a723c 100644 --- a/drivers/firmware/efi/libstub/Makefile +++ b/drivers/firmware/efi/libstub/Makefile @@ -56,17 +56,6 @@ KBUILD_CFLAGS :=3D $(filter-out $(CC_FLAGS_CFI), $(KBUIL= D_CFLAGS)) # disable LTO KBUILD_CFLAGS :=3D $(filter-out $(CC_FLAGS_LTO), $(KBUILD_CFLAGS)) =20 -GCOV_PROFILE :=3D n -# Sanitizer runtimes are unavailable and cannot be linked here. -KASAN_SANITIZE :=3D n -KCSAN_SANITIZE :=3D n -KMSAN_SANITIZE :=3D n -UBSAN_SANITIZE :=3D n -OBJECT_FILES_NON_STANDARD :=3D y - -# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in. -KCOV_INSTRUMENT :=3D n - lib-y :=3D efi-stub-helper.o gop.o secureboot.o tpm.o \ file.o mem.o random.o randomalloc.o pci.o \ skip_spaces.o lib-cmdline.o lib-ctype.o \ diff --git a/drivers/misc/lkdtm/Makefile b/drivers/misc/lkdtm/Makefile index 95ef971b5e1c..33fe61152a15 100644 --- a/drivers/misc/lkdtm/Makefile +++ b/drivers/misc/lkdtm/Makefile @@ -15,10 +15,6 @@ lkdtm-$(CONFIG_PPC_64S_HASH_MMU) +=3D powerpc.o =20 KASAN_SANITIZE_stackleak.o :=3D n =20 -KASAN_SANITIZE_rodata.o :=3D n -KCSAN_SANITIZE_rodata.o :=3D n -KCOV_INSTRUMENT_rodata.o :=3D n -OBJECT_FILES_NON_STANDARD_rodata.o :=3D y CFLAGS_REMOVE_rodata.o +=3D $(CC_FLAGS_LTO) $(RETHUNK_CFLAGS) =20 OBJCOPYFLAGS :=3D diff --git a/init/Makefile b/init/Makefile index 3c48d97538c1..ab71cedc5fd6 100644 --- a/init/Makefile +++ b/init/Makefile @@ -59,6 +59,3 @@ include/generated/utsversion.h: FORCE =20 $(obj)/version-timestamp.o: include/generated/utsversion.h CFLAGS_version-timestamp.o :=3D -include include/generated/utsversion.h -KASAN_SANITIZE_version-timestamp.o :=3D n -KCSAN_SANITIZE_version-timestamp.o :=3D n -GCOV_PROFILE_version-timestamp.o :=3D n diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux index c9f3e03124d7..49946cb96844 100644 --- a/scripts/Makefile.vmlinux +++ b/scripts/Makefile.vmlinux @@ -18,9 +18,6 @@ quiet_cmd_cc_o_c =3D CC $@ $(call if_changed_dep,cc_o_c) =20 ifdef CONFIG_MODULES -KASAN_SANITIZE_.vmlinux.export.o :=3D n -KCSAN_SANITIZE_.vmlinux.export.o :=3D n -GCOV_PROFILE_.vmlinux.export.o :=3D n targets +=3D .vmlinux.export.o vmlinux: .vmlinux.export.o endif diff --git a/scripts/mod/Makefile b/scripts/mod/Makefile index 3c54125eb373..c729bc936bae 100644 --- a/scripts/mod/Makefile +++ b/scripts/mod/Makefile @@ -1,5 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 -OBJECT_FILES_NON_STANDARD :=3D y CFLAGS_REMOVE_empty.o +=3D $(CC_FLAGS_LTO) =20 hostprogs-always-y +=3D modpost mk_elfconfig --=20 2.40.1 From nobody Mon Feb 9 05:52:11 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 49F1E86AEE; Mon, 6 May 2024 13:36:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715002590; cv=none; b=jqf3s1uJHLy/xsPldDVJzq5wZH+wU05WOm8ygVQmK752WQpE1AuB75BiRhoCXSd/suAVdVzF1BWwRR3KHw4CIrhLy4OKXDWVPG0ddDvpCpdq3r2oYhnZiWLAAnjUF0o5OPIhB/Fd0vXUroXl+npVoTb5Yw4AFL91CFVN0ZZyHZo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715002590; c=relaxed/simple; bh=IU0butsrYNaU1Rn9/Rhr8P9pxnhR+xc2irmkL7gk71M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Lta+9OJw24Gdg0JRfaLJHcJ8VdkiFNaSK0tqYoRI5qC2N/++EG4KpF7cDwou06sZFxQnEBdn5yOr214iB6f3j/Lu6/0R2Bq3VgrZ1QusOUGmbS10XthpF3BfwoYBo42ldpJKEeaXii4B4PKWn65P5S0wnflyEilnASf4Up5ovqs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Vll13l5h; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Vll13l5h" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 18219C4AF67; Mon, 6 May 2024 13:36:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715002590; bh=IU0butsrYNaU1Rn9/Rhr8P9pxnhR+xc2irmkL7gk71M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vll13l5hMbESecAEa6zpZucFAHqic9XvexGbDayahesEpFFqZbj2iGntS5bPMiCAu PLTrS+W2G+s7awG3XXf+15z9qFQp8svkzgOMHW3Rzoemj2FqhI2ZuGUGqPkrdhbaoN guIRMB95b7pT8PagUJ6pBCPzzox7aTTKkCnnsbTkNFT6+VJye3iNeWq9W3Rtlql91W BWewJpKO8mGpzKVrsignptX2W08263xw6UO86j4hweW7MjKjlN+WR0QNSUjo7qStBt irlPoDWyyy5tbvUcJqKW7IE63gmVc8QHxaIT+hDfCiYRPZ/0EkvciS69rxYucv6MpS kEnTKAsHOfRhA== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 3/3] kbuild: use GCOV_PROFILE and KCSAN_SANITIZE in scripts/Makefile.modfinal Date: Mon, 6 May 2024 22:35:44 +0900 Message-Id: <20240506133544.2861555-4-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240506133544.2861555-1-masahiroy@kernel.org> References: <20240506133544.2861555-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Instead of filtering out the GCOV and KCSAN flags, let's set GCOV_PROFILE and KCSAN_SANITIZE to 'n', as in other Makefiles. Signed-off-by: Masahiro Yamada Reviewed-by: Kees Cook Tested-by: Roberto Sassu --- scripts/Makefile.modfinal | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/Makefile.modfinal b/scripts/Makefile.modfinal index 79fcf2731686..3bec9043e4f3 100644 --- a/scripts/Makefile.modfinal +++ b/scripts/Makefile.modfinal @@ -21,9 +21,11 @@ __modfinal: $(modules:%.o=3D%.ko) # modname and part-of-module are set to make c_flags define proper module = flags modname =3D $(notdir $(@:.mod.o=3D)) part-of-module =3D y +GCOV_PROFILE :=3D n +KCSAN_SANITIZE :=3D n =20 quiet_cmd_cc_o_c =3D CC [M] $@ - cmd_cc_o_c =3D $(CC) $(filter-out $(CC_FLAGS_CFI) $(CFLAGS_GCOV) $(C= FLAGS_KCSAN), $(c_flags)) -c -o $@ $< + cmd_cc_o_c =3D $(CC) $(filter-out $(CC_FLAGS_CFI), $(c_flags)) -c -o= $@ $< =20 %.mod.o: %.mod.c FORCE $(call if_changed_dep,cc_o_c) --=20 2.40.1