From patchwork Tue Mar 12 15:03:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13590135 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 C639E7BAEC; Tue, 12 Mar 2024 15:03:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710255816; cv=none; b=iMVEm7ofiEFYx6QIqOTsBzGqFKJbmt+l1sU8XKGw2Eev8NNymNk4o9IefRxYesJykNENi3zq5zMzGZ9Qil8e7BTIf82evZY+z/UsS1a2DOCYF8MBn60xkjxLJjffqfZZ5XDtDeRvI0Q2g68vc5E6DwxmcDF1claQK2Z5LSeEHb4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710255816; c=relaxed/simple; bh=KnOxVm6KbqEFVEhejvOeQmbi9cQqkGesnu7vYq0PmMQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=J19OeesRgxSEQdFaqZDjYQa6hvj2+qGyGEn5A0DrJZejdS4PUvDcbQBluSuaUWOUd2ZKWG4XOaHLga8BjvuhZF6UxdWNRZ6fT3WXkV/w/sqEjnNOe9fU4j2wjXKoV3U36adilQaZeo3oWZ3XcGZfHlPmiGyUdnljGOPHhhRdhS0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=A1TfcKMx; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=ro1FAR2o; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="A1TfcKMx"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ro1FAR2o" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1710255812; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WZWEEViQLUdKD5a393nUrHRyZIMhZZB3yU82rz2cbw4=; b=A1TfcKMxjIg/tNlC4y0cISDvknIoHkORMtgmRxJDR9rQulMWesPdJa1DJ3uX+IIjWi0g+R ZCkl4KPG4Ch7DofE/Ye3IKfNJTjhA2A2BvzBAXgYJKm6YD4cRT2WgmTIZ+/dk4Q0oV4o9O XgS0OkJi09S0Quwa4a1hUEfoDd14fJUV7ct80+tzeMd1s4pZTUdR3Kc6KLy2vSwPMbJqMG 0AMDNh8yvpOsGQEYqh7hs+vCuJCLVjo3Esj0o7iyMpoeBCowC182+d3praSynsiS5EsUK8 6FfbUGI2l03pR6ipVOTCrb6YNLRcEP3oDiIpK6E7ef31lFsNoNViYU0UsNVVBw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1710255812; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WZWEEViQLUdKD5a393nUrHRyZIMhZZB3yU82rz2cbw4=; b=ro1FAR2oU08rea8XXXYmZuiv2HBp5XzR5NP3zB7CwvlGR9xcyIZqxODA6bIhSQ6JGGr8AE pjzZhP7APc+58TBQ== Date: Tue, 12 Mar 2024 16:03:29 +0100 Subject: [PATCH 1/2] kbuild: add host-cc-option helper Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240312-gcc-plugins-gmp-v1-1-c5e082437b9e@linutronix.de> References: <20240312-gcc-plugins-gmp-v1-0-c5e082437b9e@linutronix.de> In-Reply-To: <20240312-gcc-plugins-gmp-v1-0-c5e082437b9e@linutronix.de> To: Kees Cook , Masahiro Yamada Cc: linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1710255811; l=1088; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=KnOxVm6KbqEFVEhejvOeQmbi9cQqkGesnu7vYq0PmMQ=; b=tvbjzwBgHMA+r+to3wpCuLHallidb62UnQ2iFbuGJrbyjfaCiShxCmChYObFcjA9XIIuux2vk L+gNh1MLCSbAGDXnoJZ0KskCAh8PCVOCQbfGB3FpfMFco/DTQHYB/v/ X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= This helper works the same as cc-option but for the host compiler. It will be used by the gcc-plugins configuration to check for the gmp.h header. Signed-off-by: Thomas Weißschuh --- scripts/Kconfig.include | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/Kconfig.include b/scripts/Kconfig.include index 3ee8ecfb8c04..84368e23b072 100644 --- a/scripts/Kconfig.include +++ b/scripts/Kconfig.include @@ -27,6 +27,10 @@ failure = $(if-success,$(1),n,y) # Return y if the compiler supports , n otherwise cc-option = $(success,trap "rm -rf .tmp_$$" EXIT; mkdir .tmp_$$; $(CC) -Werror $(CLANG_FLAGS) $(1) -c -x c /dev/null -o .tmp_$$/tmp.o) +# $(host-cc-option,) +# Return y if the host compiler supports , n otherwise +host-cc-option = $(success,trap "rm -rf .tmp_$$" EXIT; mkdir .tmp_$$; $(HOSTCC) -Werror $(HOSTCFLAGS) $(1) -c -x c /dev/null -o .tmp_$$/tmp.o) + # $(ld-option,) # Return y if the linker supports , n otherwise ld-option = $(success,$(LD) -v $(1)) From patchwork Tue Mar 12 15:03:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13590136 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 E72E97BAF6; Tue, 12 Mar 2024 15:03:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710255816; cv=none; b=R77IOLwNMD1rjnQylgUu87CfKYnI03/ReVJlQ8PBiXSBnFwcx5PMebedR1BQ6Jn4AtmIQ43N96/S3rUO+OHHuTnfieEnFuFFvMomjSPTiVImHLzhB+mQivLUXDZgg4aAl6vBQAPrxuHCKmnAb03iDUGnSjrUaJo1NkvGkMvUbCk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710255816; c=relaxed/simple; bh=TcxH0jrVy0D6HM+7vL6WapyAgd3uVKWanz7kOcNypZo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ro5CqJwfdOxs9UJwMtmaGh12sKJNacO/Z84Mvh3DmqSniky7L9ZXWJHelBuXtCHkOhD0LJgbAJ2VhuH5b8rIv9eWvKdvZarmS7NVOegEpZia3cnOEALu+YAcm/FdNvceWoHB/+Ac/fdi804XfzctLMJrYl4GvyW5YdG9cE6xImQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=vTVRBIBj; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=1X+np/yD; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="vTVRBIBj"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="1X+np/yD" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1710255813; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=E+iYqjfIE0bdUlAp8TcPV24ADFNBzMPbm85EoHAvJgM=; b=vTVRBIBjycadCGKN6Yf8fQHPzs1MvhF9heom8D/ADl+k5nud17hDLuobNWMwfKv9gQjJtq izHD3z+5B/f0Oh4OGhIv9YilHzmO/cUmdWwhBwYnSl5yzTCXthtiWTMehVEHm1Pq6oIMLw AjQTJEnJFcdlrbChriPb3sRb6jgclY9hJ/hNOA/b16FGmSejqCQzasmjk4KxYV7g5yns62 NO6llYamDd8dLose3SzzFMgDTrUBTtxnXZhk28UfX43rSkF3eU4UK3yO/5SZvNgRNNlcwI VqOb/SFttAXsQq+FqHuF+xWNZCtD/r2SNEWK2w+c/3a+96XnAb1WHGpdhbh4dA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1710255813; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=E+iYqjfIE0bdUlAp8TcPV24ADFNBzMPbm85EoHAvJgM=; b=1X+np/yDR5nn5cZS6MzyrGrwsOngCcGR6nrQSBj+ketGVJgMuiiARZP2bXpnboAFuEfaAM q7bE+D8HMQOoirDA== Date: Tue, 12 Mar 2024 16:03:30 +0100 Subject: [PATCH 2/2] gcc-plugins: disable plugins when gmp.h is unavailable Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240312-gcc-plugins-gmp-v1-2-c5e082437b9e@linutronix.de> References: <20240312-gcc-plugins-gmp-v1-0-c5e082437b9e@linutronix.de> In-Reply-To: <20240312-gcc-plugins-gmp-v1-0-c5e082437b9e@linutronix.de> To: Kees Cook , Masahiro Yamada Cc: linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1710255811; l=1265; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=TcxH0jrVy0D6HM+7vL6WapyAgd3uVKWanz7kOcNypZo=; b=7RerVu3xGGXTy2AlyLsvG1WEgFjAlA8jBCMVP3Or/JPpdSYWiEw70aOLifyuYqexe+BQn/R4X 36UlLDa55SzDQQpaYEtq+YGL+rBCixy/vCgfFmbNaeZwrKwUWvQ0FfX X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= The header gmp.h is meant to be picked up from the host system. When it is unavailable the plugin build fails: In file included from ../crosstools/gcc-13.2.0-nolibc/i386-linux/bin/../lib/gcc/i386-linux/13.2.0/plugin/include/gcc-plugin.h:28, from ../scripts/gcc-plugins/gcc-common.h:7, from ../scripts/gcc-plugins/stackleak_plugin.c:30: ../crosstools/gcc-13.2.0-nolibc/i386-linux/bin/../lib/gcc/i386-linux/13.2.0/plugin/include/system.h:703:10: fatal error: gmp.h: No such file or directory 703 | #include | ^~~~~~~ Signed-off-by: Thomas Weißschuh --- scripts/gcc-plugins/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/gcc-plugins/Kconfig b/scripts/gcc-plugins/Kconfig index e383cda05367..a664fb5cdde5 100644 --- a/scripts/gcc-plugins/Kconfig +++ b/scripts/gcc-plugins/Kconfig @@ -10,6 +10,7 @@ menuconfig GCC_PLUGINS depends on HAVE_GCC_PLUGINS depends on CC_IS_GCC depends on $(success,test -e $(shell,$(CC) -print-file-name=plugin)/include/plugin-version.h) + depends on $(host-cc-option,-include gmp.h) default y help GCC plugins are loadable modules that provide extra features to the