From nobody Sat Feb 7 23:12:37 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 EE2526EB79; Fri, 2 May 2025 22:54:19 +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=1746226460; cv=none; b=Cl0C1Fc/yNv77o5+WKvyhvB+ZkIGtiglpibvZbmyZIrPdgIBIkIC9XWDhFlo60FzGu8rW1YRPAZ5mA5BpzZOyB/tX4BuYN7NDlNi9IAGm0fq0pz2MH85ttkrjy1XcS3CXt3/oyMGQsodHbWQlIe4SGBhRfwGohs4yfH6NFkC/xU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746226460; c=relaxed/simple; bh=p3LCBG41fA+N9OOg7h+A3NTLbRHrJjxplvYJ9i2fjRY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=D/jQ2i9VO2sAV+mTr8bQpn8VfLPpVkCMbuF7qeCEWSt5Ry9JD7DksQdnM1TMqKHJqxupsX9/JBWR0gbC/CooIMPS1LFII1Qza6uNb1yiw+pKCuzWN+yHhpN7yhlT27+Nykmk5chEgQ5NDtSWtCyeJrIvVTMkTc6Z07dKnV2IaaQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ssm7w/5O; 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="ssm7w/5O" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6EC5C4AF0C; Fri, 2 May 2025 22:54:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1746226459; bh=p3LCBG41fA+N9OOg7h+A3NTLbRHrJjxplvYJ9i2fjRY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ssm7w/5OZHMhxTzwMP4B4UgKSyqDS49B4LzQoeqpM6gq8fFj67ZCjSc9HH7u9EGhG D5p6tcYMU1FvQqDasRC4ueS8g3cJQLabkV4DBDMSf01s2i9Hqb+fvrMZz/vhZiCjbl q59u9hK4c9qNtDCDZ/PpSnmg/qgPvpx/tJl0NjdeXCX7d1aZedvHwOSQpBvN8Ot1RM MZhVSvW4V7VSJzDtAz9K89UvV2KYeqFIRjRnRE7Wm5dT3nPJxX49BpoHcA+33YS0tT zEUc00UOuVESsiTC5v26JvoMPHZwyD+mRB4CfW5ctFR+Wkhez7Dx3Pynf+GjMni1S1 fSpRGPEgXylIg== From: Kees Cook To: Masahiro Yamada Cc: Kees Cook , Nathan Chancellor , Nicolas Schier , linux-hardening@vger.kernel.org, linux-kbuild@vger.kernel.org, Petr Pavlu , Sebastian Andrzej Siewior , Justin Stitt , Marco Elver , Andrey Konovalov , Andrey Ryabinin , Richard Weinberger , Anton Ivanov , Johannes Berg , linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-um@lists.infradead.org Subject: [PATCH v2 1/3] gcc-plugins: Force full rebuild when plugins change Date: Fri, 2 May 2025 15:54:13 -0700 Message-Id: <20250502225416.708936-1-kees@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250502224512.it.706-kees@kernel.org> References: <20250502224512.it.706-kees@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3599; i=kees@kernel.org; h=from:subject; bh=p3LCBG41fA+N9OOg7h+A3NTLbRHrJjxplvYJ9i2fjRY=; b=owGbwMvMwCVmps19z/KJym7G02pJDBmivmJ2fLZvdZtuL3ln0FN9zyeba4Wj2k17D3nRxQXrd vdMr2PqKGVhEONikBVTZAmyc49z8XjbHu4+VxFmDisTyBAGLk4BmEjGNEaG31vtb+Y+u61978cH qSv9Qt/MA2r2XlX+dImj81RrVk9POMP/KOPbz/fsmLXErj3kugvzgqC892Eblgc1Mnx9/1GLbac cJwA= X-Developer-Key: i=kees@kernel.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There was no dependency between the plugins changing and the rest of the kernel being built. Enforce this by including a synthetic header file when using plugins, that is regenerated any time the plugins are built. This cannot be included via '-include ...' because Makefiles use the "filter-out" string function, which removes individual words. Removing all instances of "-include" from the CFLAGS will cause a lot of problems. :) Instead, use -I to include the gcc-plugins directory, and depend on the new -DGCC_PLUGINS_ENABLED flag to include the generated header file via include/linux/compiler-version.h, which is already being used to control full rebuilds. The UM build requires that the -I be explicitly added. Signed-off-by: Kees Cook --- Cc: Masahiro Yamada Cc: Nathan Chancellor Cc: Nicolas Schier Cc: Cc: --- arch/um/Makefile | 1 + include/linux/compiler-version.h | 4 ++++ scripts/Makefile.gcc-plugins | 2 +- scripts/gcc-plugins/Makefile | 8 ++++++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/arch/um/Makefile b/arch/um/Makefile index 1d36a613aad8..8cc0f22ebefa 100644 --- a/arch/um/Makefile +++ b/arch/um/Makefile @@ -72,6 +72,7 @@ USER_CFLAGS =3D $(patsubst $(KERNEL_DEFINES),,$(patsubst = -I%,,$(KBUILD_CFLAGS))) \ $(ARCH_INCLUDE) $(MODE_INCLUDE) $(filter -I%,$(CFLAGS)) \ -D_FILE_OFFSET_BITS=3D64 -idirafter $(srctree)/include \ -idirafter $(objtree)/include -D__KERNEL__ -D__UM_HOST__ \ + -I$(objtree)/scripts/gcc-plugins \ -include $(srctree)/include/linux/compiler-version.h \ -include $(srctree)/include/linux/kconfig.h =20 diff --git a/include/linux/compiler-version.h b/include/linux/compiler-vers= ion.h index 573fa85b6c0c..08943df04ebb 100644 --- a/include/linux/compiler-version.h +++ b/include/linux/compiler-version.h @@ -12,3 +12,7 @@ * and add dependency on include/config/CC_VERSION_TEXT, which is touched * by Kconfig when the version string from the compiler changes. */ + +#ifdef GCC_PLUGINS_ENABLED +#include "gcc-plugins-deps.h" +#endif diff --git a/scripts/Makefile.gcc-plugins b/scripts/Makefile.gcc-plugins index 5b8a8378ca8a..468bb8faa9d1 100644 --- a/scripts/Makefile.gcc-plugins +++ b/scripts/Makefile.gcc-plugins @@ -38,7 +38,7 @@ export DISABLE_STACKLEAK_PLUGIN =20 # All the plugin CFLAGS are collected here in case a build target needs to # filter them out of the KBUILD_CFLAGS. -GCC_PLUGINS_CFLAGS :=3D $(strip $(addprefix -fplugin=3D$(objtree)/scripts/= gcc-plugins/, $(gcc-plugin-y)) $(gcc-plugin-cflags-y)) +GCC_PLUGINS_CFLAGS :=3D $(strip $(addprefix -fplugin=3D$(objtree)/scripts/= gcc-plugins/, $(gcc-plugin-y)) $(gcc-plugin-cflags-y)) -I$(objtree)/scripts= /gcc-plugins -DGCC_PLUGINS_ENABLED export GCC_PLUGINS_CFLAGS =20 # Add the flags to the build! diff --git a/scripts/gcc-plugins/Makefile b/scripts/gcc-plugins/Makefile index 320afd3cf8e8..24671d39ec90 100644 --- a/scripts/gcc-plugins/Makefile +++ b/scripts/gcc-plugins/Makefile @@ -66,3 +66,11 @@ quiet_cmd_plugin_cxx_o_c =3D HOSTCXX $@ =20 $(plugin-objs): $(obj)/%.o: $(src)/%.c FORCE $(call if_changed_dep,plugin_cxx_o_c) + +quiet_cmd_gcc_plugins_updated =3D UPDATE $@ + cmd_gcc_plugins_updated =3D echo '/* $^ */' > $(obj)/gcc-plugins-dep= s.h + +$(obj)/gcc-plugins-deps.h: $(plugin-single) $(plugin-multi) FORCE + $(call if_changed,gcc_plugins_updated) + +always-y +=3D gcc-plugins-deps.h --=20 2.34.1 From nobody Sat Feb 7 23:12:37 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 3F36C20B81D; Fri, 2 May 2025 22:54:19 +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=1746226460; cv=none; b=Fbz/2VKsFS2fH0UqpDjKGGD5TSoXiENE/sw3XdsNJHvTIKv5sNV3kCzyaeuNrqJlJZWT2xbFtA+wHcwXas1EcGPazEqDP5qDEWLMiy5oSppzoMSBm95xsT0whfvWThjE5cddwavk9E8Pw9bAfcTPkUn7UQ0hVhmGaAYclPbqta8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746226460; c=relaxed/simple; bh=DfqvdRUqMtoPlZKLyvJpYf94EQda+fM9+VWU2/V8MOI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hNNNnIzw2LVcXYYwRRT3l98ctovxjNBujUCe7BfCGJAmnzmQk3YFkNOC9e6YCYekWxIwUyx1I8NxvFGdsB1VxCMkMuc6lkHK+628DNkin8wokqeMACk4iV5HZYf5RZ13UGdC+5fPZsduYPdKaeihJIyaqvcbAZ9+r2L6kiw01wk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NDqh/s/n; 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="NDqh/s/n" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B870EC4CEE4; Fri, 2 May 2025 22:54:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1746226459; bh=DfqvdRUqMtoPlZKLyvJpYf94EQda+fM9+VWU2/V8MOI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NDqh/s/npud+DxyezNo2V3cx/EXrexw/NGPCMFNHfnLgFP2OqinV903Hwwj6IynEC 3YAJsctoGZOPsxtOnkB1v5YE+jMS1btQXiMdWcuaQaerLLnCm7Am6TwiFqFeL90mHq g6D/+Fi7r+qqHUyl5TgTfUX5prdgtcPwMoSiLNL3qkgfchhEblwLZ1TNOHlFrGumOi n3VxtZwwbu4S0oInkhlv9N2MJrTlYeIEDBjCqDwT3BBDCPqjL33G3PUd2fykBO8Qf/ yGFRxBGD62CysC3IElFiDPqcCyAnSfl2GiwTu9lrmoWLOy+E1RdZTvozjkcACeo6kM Gj8/tJiaPFP+w== From: Kees Cook To: Masahiro Yamada Cc: Kees Cook , Nathan Chancellor , Nicolas Schier , Petr Pavlu , Sebastian Andrzej Siewior , linux-kbuild@vger.kernel.org, Justin Stitt , Marco Elver , Andrey Konovalov , Andrey Ryabinin , Richard Weinberger , Anton Ivanov , Johannes Berg , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, kasan-dev@googlegroups.com, linux-um@lists.infradead.org Subject: [PATCH v2 2/3] randstruct: Force full rebuild when seed changes Date: Fri, 2 May 2025 15:54:14 -0700 Message-Id: <20250502225416.708936-2-kees@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250502224512.it.706-kees@kernel.org> References: <20250502224512.it.706-kees@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3831; i=kees@kernel.org; h=from:subject; bh=DfqvdRUqMtoPlZKLyvJpYf94EQda+fM9+VWU2/V8MOI=; b=owGbwMvMwCVmps19z/KJym7G02pJDBmivuI9R04dk2ibbdtp1zKpQ7LSSvR1fcOVTCGHVTVSs 7hClrh2lLIwiHExyIopsgTZuce5eLxtD3efqwgzh5UJZAgDF6cATGR1LsM//UwLUVHWmxW3D1qc Fs1VWStoVtv7Oe1YqM/m400zpl4NYvgf5HireJpv0ySRbQE3u5vW5VX9ulEkyZo3597GFA2nrdc 5AA== X-Developer-Key: i=kees@kernel.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" While the randstruct GCC plugin was being rebuilt if the randstruct seed changed, Clangs build did not notice the change. Include the hash header directly so that it becomes a universal build dependency and full rebuilds will happen if it changes. Since we cannot use "-include ..." as the randstruct flags are removed via "filter-out" (which would cause all instances of "-include" to be removed), use the existing -DRANDSTRUCT to control the header inclusion via include/linux/compiler-version.h. Universally add a -I for the scripts/basic directory, where header exists. The UM build requires that the -I be explicitly added. Signed-off-by: Kees Cook --- Cc: Masahiro Yamada Cc: Nathan Chancellor Cc: Nicolas Schier Cc: Petr Pavlu Cc: Sebastian Andrzej Siewior Cc: --- Makefile | 1 + arch/um/Makefile | 1 + include/linux/compiler-version.h | 3 +++ include/linux/vermagic.h | 1 - scripts/basic/Makefile | 11 ++++++----- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 5aa9ee52a765..cef652227843 100644 --- a/Makefile +++ b/Makefile @@ -567,6 +567,7 @@ LINUXINCLUDE :=3D \ -I$(objtree)/arch/$(SRCARCH)/include/generated \ -I$(srctree)/include \ -I$(objtree)/include \ + -I$(objtree)/scripts/basic \ $(USERINCLUDE) =20 KBUILD_AFLAGS :=3D -D__ASSEMBLY__ -fno-PIE diff --git a/arch/um/Makefile b/arch/um/Makefile index 8cc0f22ebefa..38f6024e75d7 100644 --- a/arch/um/Makefile +++ b/arch/um/Makefile @@ -73,6 +73,7 @@ USER_CFLAGS =3D $(patsubst $(KERNEL_DEFINES),,$(patsubst = -I%,,$(KBUILD_CFLAGS))) \ -D_FILE_OFFSET_BITS=3D64 -idirafter $(srctree)/include \ -idirafter $(objtree)/include -D__KERNEL__ -D__UM_HOST__ \ -I$(objtree)/scripts/gcc-plugins \ + -I$(objtree)/scripts/basic \ -include $(srctree)/include/linux/compiler-version.h \ -include $(srctree)/include/linux/kconfig.h =20 diff --git a/include/linux/compiler-version.h b/include/linux/compiler-vers= ion.h index 08943df04ebb..05d555320a0f 100644 --- a/include/linux/compiler-version.h +++ b/include/linux/compiler-version.h @@ -16,3 +16,6 @@ #ifdef GCC_PLUGINS_ENABLED #include "gcc-plugins-deps.h" #endif +#ifdef RANDSTRUCT +#include "randstruct_hash.h" +#endif diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h index 939ceabcaf06..335c360d4f9b 100644 --- a/include/linux/vermagic.h +++ b/include/linux/vermagic.h @@ -33,7 +33,6 @@ #define MODULE_VERMAGIC_MODVERSIONS "" #endif #ifdef RANDSTRUCT -#include #define MODULE_RANDSTRUCT "RANDSTRUCT_" RANDSTRUCT_HASHED_SEED #else #define MODULE_RANDSTRUCT diff --git a/scripts/basic/Makefile b/scripts/basic/Makefile index dd289a6725ac..31637ce4dc5c 100644 --- a/scripts/basic/Makefile +++ b/scripts/basic/Makefile @@ -8,9 +8,10 @@ hostprogs-always-y +=3D fixdep # before running a Clang kernel build. gen-randstruct-seed :=3D $(srctree)/scripts/gen-randstruct-seed.sh quiet_cmd_create_randstruct_seed =3D GENSEED $@ -cmd_create_randstruct_seed =3D \ - $(CONFIG_SHELL) $(gen-randstruct-seed) \ - $@ $(objtree)/include/generated/randstruct_hash.h -$(obj)/randstruct.seed: $(gen-randstruct-seed) FORCE + cmd_create_randstruct_seed =3D $(CONFIG_SHELL) $(gen-randstruct-seed= ) \ + $(obj)/randstruct.seed $(obj)/randstruct_hash.h + +$(obj)/randstruct_hash.h $(obj)/randstruct.seed: $(gen-randstruct-seed) FO= RCE $(call if_changed,create_randstruct_seed) -always-$(CONFIG_RANDSTRUCT) +=3D randstruct.seed + +always-$(CONFIG_RANDSTRUCT) +=3D randstruct.seed randstruct_hash.h --=20 2.34.1 From nobody Sat Feb 7 23:12:37 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 3F3E5215184; Fri, 2 May 2025 22:54:19 +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=1746226460; cv=none; b=pZUwj7IdhNRwShe/KgRvFWbD29EMTUppEEBPM3N3XqkhjXZY2XtpkrZtR/A4tlKwNENWHFRfgov45QRomT4+ykGKjT05D7fgHy9Itzzt1ZCwKmitBS9pwWDJJ5DlBlA7RODYPZasSU/JJy32zlM07Px3dxi3N3E53rsfxOUp48E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746226460; c=relaxed/simple; bh=xF83aDmqFbvCUaXo7mxg1j7TWAuDRl3V3C44XfenCBQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Q02cxiq9AOvHy7XT7siU1EpcaNv/EBHZmEifs16N7763LJFH40FkcY8aDpXdaZaA4+WqoHtjMgyWKTJcxteTFFX+PlStNmDSkGahEmTC2XuY8VuQUyulqxPmbH0L697+D9adAwTYZdQxYf9NVOyukMFghJwEPMjIMnxQJafqMYA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Xw/kqnMW; 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="Xw/kqnMW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C102AC4CEED; Fri, 2 May 2025 22:54:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1746226459; bh=xF83aDmqFbvCUaXo7mxg1j7TWAuDRl3V3C44XfenCBQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xw/kqnMW6X6itgZQY+XZPyclDOFFHHd8zTcRSpSXNYBwrE9OZ2KcpgeEfhKZl8tOo FYKUq+zupdEyqBix8779gWxG4RAbnlavrlqvDUPUGKM00xhBFQIBW+xCmYpzL+W9U3 9CaqJKqoDlE+Cn54ROrdFpjPGzxKRKgFqNqDlE8ca0WobLkdrMzm2oSh1wDhcVzf1B tt6IzOSg/sc1HqEb2M5+E5q6eqnGT4h19iwKAkicM4le5S+cg0KbPO16J9WBCWFqAa CP4scwfEGTvyjdR1OJVN+T3ceAYiKZpQ7ZHShrouGxIbZmOov/r3W9SVSrdB/GvLn7 nqnlCB9Oq2/Vw== From: Kees Cook To: Masahiro Yamada Cc: Kees Cook , Justin Stitt , Nathan Chancellor , Nicolas Schier , Marco Elver , Andrey Konovalov , Andrey Ryabinin , linux-kbuild@vger.kernel.org, kasan-dev@googlegroups.com, linux-hardening@vger.kernel.org, Petr Pavlu , Sebastian Andrzej Siewior , Richard Weinberger , Anton Ivanov , Johannes Berg , linux-kernel@vger.kernel.org, linux-um@lists.infradead.org Subject: [PATCH v2 3/3] integer-wrap: Force full rebuild when .scl file changes Date: Fri, 2 May 2025 15:54:15 -0700 Message-Id: <20250502225416.708936-3-kees@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250502224512.it.706-kees@kernel.org> References: <20250502224512.it.706-kees@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2695; i=kees@kernel.org; h=from:subject; bh=xF83aDmqFbvCUaXo7mxg1j7TWAuDRl3V3C44XfenCBQ=; b=owGbwMvMwCVmps19z/KJym7G02pJDBmivuI85U7N/WzzlN9cqLGqVdC53L/oHwfbLf9DF++mi ConLW/pKGVhEONikBVTZAmyc49z8XjbHu4+VxFmDisTyBAGLk4BmMj1P4wMPZc1RZaLnRXVX3on RnbKtpciUZ2agRuunHxVXLxk+rfnpxkZXieL9fE5qE4+yfT1wdwJO8OkNG0SBQw4Ojzm3NpT65j BCQA= X-Developer-Key: i=kees@kernel.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since the integer wrapping sanitizer's behavior depends on its associated .scl file, we must force a full rebuild if the file changes. Universally include a synthetic header file that is rebuilt when the .scl file changes, via compiler-version.h, since using "-include ..." is not possible in the case of having compiler flags removed via "filter-out" (which would remove all instances of "-include"). Signed-off-by: Kees Cook --- Cc: Masahiro Yamada Cc: Justin Stitt Cc: Nathan Chancellor Cc: Nicolas Schier Cc: Marco Elver Cc: Andrey Konovalov Cc: Andrey Ryabinin Cc: Cc: Cc: --- include/linux/compiler-version.h | 3 +++ scripts/Makefile.ubsan | 1 + scripts/basic/Makefile | 9 +++++++++ 3 files changed, 13 insertions(+) diff --git a/include/linux/compiler-version.h b/include/linux/compiler-vers= ion.h index 05d555320a0f..9d6b1890ffc7 100644 --- a/include/linux/compiler-version.h +++ b/include/linux/compiler-version.h @@ -19,3 +19,6 @@ #ifdef RANDSTRUCT #include "randstruct_hash.h" #endif +#ifdef INTEGER_WRAP +#include "integer-wrap.h" +#endif diff --git a/scripts/Makefile.ubsan b/scripts/Makefile.ubsan index 9e35198edbf0..653f7117819c 100644 --- a/scripts/Makefile.ubsan +++ b/scripts/Makefile.ubsan @@ -15,6 +15,7 @@ ubsan-cflags-$(CONFIG_UBSAN_TRAP) +=3D $(call cc-option,= -fsanitize-trap=3Dundefined export CFLAGS_UBSAN :=3D $(ubsan-cflags-y) =20 ubsan-integer-wrap-cflags-$(CONFIG_UBSAN_INTEGER_WRAP) +=3D \ + -DINTEGER_WRAP \ -fsanitize-undefined-ignore-overflow-pattern=3Dall \ -fsanitize=3Dsigned-integer-overflow \ -fsanitize=3Dunsigned-integer-overflow \ diff --git a/scripts/basic/Makefile b/scripts/basic/Makefile index 31637ce4dc5c..04f5620a3f8b 100644 --- a/scripts/basic/Makefile +++ b/scripts/basic/Makefile @@ -15,3 +15,12 @@ $(obj)/randstruct_hash.h $(obj)/randstruct.seed: $(gen-r= andstruct-seed) FORCE $(call if_changed,create_randstruct_seed) =20 always-$(CONFIG_RANDSTRUCT) +=3D randstruct.seed randstruct_hash.h + +# integer-wrap: if the .scl file changes, we need to do a full rebuild. +quiet_cmd_integer_wrap_updated =3D UPDATE $@ + cmd_integer_wrap_updated =3D echo '/* $^ */' > $(obj)/integer-wrap.h + +$(obj)/integer-wrap.h: $(srctree)/scripts/integer-wrap-ignore.scl FORCE + $(call if_changed,integer_wrap_updated) + +always-$(CONFIG_UBSAN_INTEGER_WRAP) +=3D integer-wrap.h --=20 2.34.1