Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1o8zRc-0001LM-WA for mharc-grub-devel@gnu.org; Wed, 06 Jul 2022 03:27:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38106) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o8zRU-0001Ex-Ec for grub-devel@gnu.org; Wed, 06 Jul 2022 03:27:30 -0400 Received: from mail-qt1-x836.google.com ([2607:f8b0:4864:20::836]:43852) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o8zRO-0005WE-T0 for grub-devel@gnu.org; Wed, 06 Jul 2022 03:27:22 -0400 Received: by mail-qt1-x836.google.com with SMTP id c13so17078824qtq.10 for ; Wed, 06 Jul 2022 00:27:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=OSn9mrvSZuus1tD1Dw1hE8e8ZAm4cKYF08UAxPpzIaM=; b=XoavBRUmzS5nFCeAl5z1q0lro/HKUmIi7S6OwIWxSCYK0RRuHK/iSjKcbQqTTKns50 gYqyb33zYoQiehO8A7Blj3OBH8j8JZF/H3CMQZ7FUxl2Ztw1toTS4DLh/HoSjXgYxus+ SwA4e5TqiGryAmX4Fm1R0VT+V6ZyuozQSM/uI0Ta8OG6+XAVX1VD9QtwlqOuEheEE0jZ iLtkQ1XNQxJ2T9Gn6pdykT/9cPJy7vUsE3MQa7cg8kofmd7WzjieceV59D1sCuv/T9Gq Dqir5V01wKrxElqWU/AJmJKYRNoCG4lDDLTVfsgH1mwBX4e+c3dO+mcx/Q/mLO/vHNgb NyDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=OSn9mrvSZuus1tD1Dw1hE8e8ZAm4cKYF08UAxPpzIaM=; b=HxE+VzH9xK3aTXEpEAjiWPqNq+rF3FY9u9Pidws9XKBEzsZiekl4HY9NeaJmoF6cD+ SSqUVVl1zAzziD+3utxYnQlFGGylGx/beeMDUr9d3b4XU1WBrD3yWL7rodgOJ/gKyjXS 9znNtQk3hLi89ebzLbY8aiEQKlpKAASIIvxXE+i+aJbWdgFVQd+V74Dznq2b5/F0cVMT 9mrezkzV+41qOYXsmqwojy5eqhfzdcN2Qe9EK7ffi0ZKPVUmUuoxKASw0HNV8piC5Vjo HEsB8UkaHWf6dDPGsCx5Z0k1xGTw2/ywKcPfNC28sRcPGbPw5CacAPpnDp3UajfSeBfT jXvQ== X-Gm-Message-State: AJIora8jlDBbiV1DrDa/V4wSQPNwaJYYkt/uHJaOaIgYvQuj0QTZ79dr 4c1Gt3tCqhnyrfjd5zXqsnoSahRLDVg= X-Google-Smtp-Source: AGRyM1uwdueAIJqoYkc5OV7TDq7Ynb2ulJdxJsS+OoVYwEFj4s9DQzY0B76dma1m/J35UiwEWROo4Q== X-Received: by 2002:ac8:5fc3:0:b0:31d:2637:7ed6 with SMTP id k3-20020ac85fc3000000b0031d26377ed6mr29741708qta.282.1657092436290; Wed, 06 Jul 2022 00:27:16 -0700 (PDT) Received: from localhost.localdomain ([2602:47:d930:400:d1ec:b3d3:71e8:149a]) by smtp.googlemail.com with ESMTPSA id g6-20020a05620a40c600b006a6bb044740sm22268810qko.66.2022.07.06.00.27.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 00:27:15 -0700 (PDT) From: Nicholas Vinson To: grub-devel@gnu.org Cc: Nicholas Vinson Subject: [PATCH v2] configure.ac: warn if stack-protector not allowed Date: Wed, 6 Jul 2022 03:25:58 -0400 Message-Id: <20220706072558.5781-1-nvinson234@gmail.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::836; envelope-from=nvinson234@gmail.com; helo=mail-qt1-x836.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Jul 2022 07:27:30 -0000 Introduce ERROR_PLATFORM_NOT_SUPPORT_SSP environment variable to treat the '--enable-stack-protector is only supported on EFI platforms' message as a warning instead of an error. If ERROR_PLATFORM_NOT_SUPPORT_SSP is set to 'no' (case-insensitive), then the message will be printed as a warning. Otherwise, it prints as an error. The default behavior is to print the message as an error. For any wrapper build script that has some variation of: for p in SELECTED_GRUB_PLATFORMS; do \ configure --enable-stack-protector \ --with-platform${P} ... || die; \ done make GRUB will fail to build if SELECTED_GRUB_PLATFORMS contains a platform that does not support SSP. Such wrapper scripts need to work-around this issue by modifying the above for-loop, so it conditionally passes '--enable-stack-protector' to configure for the proper GRUB platform(s). However, if the above example is modified to have to conditionally pass in --enable-stack-protector, its behavior is effectively the same as the proposed change. Additionally, The list of SSP supported platforms is now in 2 places. One in the configure script and one in the build wrapper script. If the second list is not properly maintained it could mistakenly disable SSP for a platform that later gained support for it. Signed-off-by: Nicholas Vinson --- configure.ac | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 57fb70945..a08f3285e 100644 --- a/configure.ac +++ b/configure.ac @@ -36,6 +36,10 @@ dnl description of the relationships between them. AC_INIT([GRUB],[2.11],[bug-grub@gnu.org]) +AS_CASE(["$ERROR_PLATFORM_NOT_SUPPORT_SSP"], + [n | no | nO | N | No | NO], [ERROR_PLATFORM_NOT_SUPPORT_SSP=no], + [ERROR_PLATFORM_NOT_SUPPORT_SSP=yes]) + # We don't want -g -O2 by default in CFLAGS : ${CFLAGS=""} @@ -1342,6 +1346,7 @@ AC_ARG_ENABLE([stack-protector], [enable the stack protector]), [], [enable_stack_protector=no]) + if test "x$enable_stack_protector" = xno; then if test "x$ssp_possible" = xyes; then # Need that, because some distributions ship compilers that include @@ -1349,7 +1354,12 @@ if test "x$enable_stack_protector" = xno; then TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector" fi elif test "x$platform" != xefi; then - AC_MSG_ERROR([--enable-stack-protector is only supported on EFI platforms]) + if test "$ERROR_PLATFORM_NOT_SUPPORT_SSP" = "yes"; then + AC_MSG_ERROR([--enable-stack-protector is only supported on EFI platforms]) + else + AC_MSG_WARN([--enable-stack-protector is only supported on EFI platforms]) + fi + enable_stack_protector=no elif test "x$ssp_global_possible" != xyes; then AC_MSG_ERROR([--enable-stack-protector is not supported (compiler doesn't support -mstack-protector-guard=global)]) else -- 2.35.1