From patchwork Fri Jan 18 10:58:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 155918 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3113256jaa; Fri, 18 Jan 2019 02:58:24 -0800 (PST) X-Google-Smtp-Source: ALg8bN6WBXxsJgsWOsveWB6DS8tZ10HL37o5+Tg4itggZcM1JiDK+aqYFpytV33gx6kntHZDeidO X-Received: by 2002:a62:6cc9:: with SMTP id h192mr18817020pfc.223.1547809104837; Fri, 18 Jan 2019 02:58:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547809104; cv=none; d=google.com; s=arc-20160816; b=XO/cYDhNzl2sToMY/MCCNHF4dkqCWoadDdDSS9DmIRftU7QJ6Wo3pcmNfgo+fPpxkf EETMQnYjdMivB/p/VLP7v53eMPNRfbxDpVXAUY+hArBJBmV/fTx1MbmtV8jGhwrboyfz D7TF3R9Ru9+aoQwMFYRaKF6Ay1LSTfx4uHUfUt2OQ/Th8qN/+DGytB+KPkpokMA9qBN5 9mVMcF5uy8Vo+kL/xHaOTd23sChzg0Ca5Hg/WCZ2A0wICFg1ALReZwk0RSl1FuBfyoAj Kal46VIz/GnmoOukz5rqr0t3qunlsdd9F3NcPqHWSirOmW6yxAt7HXEqFW6zqi/pzi3e GOJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4PBOByBDyORJotrQHfAdkrD3rgX1OelOnufeKqsU2dQ=; b=UPyxLXXC2/fcBYu7jyOKIlxl4SQcFPwDWu87doc7F4h3T60lu7Urg8A084lMbiAUxa loxvNXu4IRvqu5pnBiTOzeleFJslML/pckewgBfnBIX73Ydd4diG5MGWrephThm0kBOX /kBnW21U7vQ9QqOHtj1y00x2cT9XbAuTeRt/CtZX3mfLhuutj1qfZ9P430snzXpBBoTJ napol6k4VWOU3GG1Sa/E112khLII+ZpR+Ln4ZX0nn31RPW4jt61lwkMSL9EXZNQY9lEA oQZGt/TpLFfDBYM/Nxf8MN34qQxdMtknGxqTMw+Mv0lvTPS2ZB6MUPQ3EoK9QElB8MWi /IcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AlrM1972; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r1si4375044plb.330.2019.01.18.02.58.24; Fri, 18 Jan 2019 02:58:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AlrM1972; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727491AbfARK6W (ORCPT + 14 others); Fri, 18 Jan 2019 05:58:22 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:43180 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727332AbfARK6P (ORCPT ); Fri, 18 Jan 2019 05:58:15 -0500 Received: by mail-wr1-f67.google.com with SMTP id r10so14459722wrs.10 for ; Fri, 18 Jan 2019 02:58:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4PBOByBDyORJotrQHfAdkrD3rgX1OelOnufeKqsU2dQ=; b=AlrM1972m+0wXMXOuZvU17EhloZ3TgU+0dIl+cd6pVPtOCjjKqwzIbZ3qrSe2qlVEW Hw9ggdG4YeVmAHafc5+n+akYNC0sXtYESZj6frJhFweaIHa/bj8H8YM6vI5nxTZSygcM 9vR54EMAC2oeYRxIsG4Cmg43eJLzQ9buONYUk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4PBOByBDyORJotrQHfAdkrD3rgX1OelOnufeKqsU2dQ=; b=KbhJ7u4myIq6Qt89y5Ubm+mWpaq4nAC8tXXAz1bMEhYxC7eFh/5ZfC1zxSEE96bp7p WNpYlx5HOWLjrxplYbGGqSC0atQgD/FLuQ/4La9OI+S77tyUqieRu6G2RamIhhYCV0mx qHQLxAOu7OFcaa1lIIsaL5PJC/o8DgmmZGexOLOkP57RxD5riWi3nf/vSP1GOq2T4zZE ril9FTrSsINsT2hdiBLA/1KcqRYkVP7cZaZi2lJk7FKBpadqtiO8J+MHo1qRwiWWzVWU xIdPLBwsIbd9VVc9rsdYjEuMVW0KINtlt8KjDeMVfSxocC3xcdHpegzcCtCE89h6dujQ L5Iw== X-Gm-Message-State: AJcUukcWa4h+oWP/4QgCSaAiH11r0RiuKm0Uq7uL5huX2tyKWzyUwHd7 2BmCnw9jAmxWjli5Ir/XxNDeSA== X-Received: by 2002:adf:f5d1:: with SMTP id k17mr17072968wrp.59.1547809094054; Fri, 18 Jan 2019 02:58:14 -0800 (PST) Received: from localhost.localdomain (aputeaux-684-1-20-152.w90-86.abo.wanadoo.fr. [90.86.223.152]) by smtp.gmail.com with ESMTPSA id y13sm65345467wrn.73.2019.01.18.02.58.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Jan 2019 02:58:13 -0800 (PST) From: Ard Biesheuvel To: keescook@chromium.org Cc: re.emese@gmail.com, kernel-hardening@lists.openwall.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Ard Biesheuvel Subject: [PATCH 2/2] gcc-plugins: arm_ssp_per_task_plugin: fix for GCC 9+ Date: Fri, 18 Jan 2019 11:58:07 +0100 Message-Id: <20190118105807.26425-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190118105807.26425-1-ard.biesheuvel@linaro.org> References: <20190118105807.26425-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org GCC 9 reworks the way the references to the stack canary are emitted, to prevent the value from being spilled to the stack before the final comparison in the epilogue, defeating the purpose, given that the spill slot is under control of the attacker that we are protecting ourselves from. Since our canary value address is obtained without accessing memory (as opposed to pre-v7 code that will obtain it from a literal pool), it is unlikely (although not guaranteed) that the compiler will spill the canary value in the same way, so let's just disable this improvement when building with GCC9+. Signed-off-by: Ard Biesheuvel --- scripts/gcc-plugins/arm_ssp_per_task_plugin.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) -- 2.20.1 diff --git a/scripts/gcc-plugins/arm_ssp_per_task_plugin.c b/scripts/gcc-plugins/arm_ssp_per_task_plugin.c index a65fbefb8501..89c47f57d1ce 100644 --- a/scripts/gcc-plugins/arm_ssp_per_task_plugin.c +++ b/scripts/gcc-plugins/arm_ssp_per_task_plugin.c @@ -53,6 +53,19 @@ static unsigned int arm_pertask_ssp_rtl_execute(void) #define NO_GATE #include "gcc-generate-rtl-pass.h" +#if BUILDING_GCC_VERSION >= 9000 +static bool no(void) +{ + return false; +} + +static void arm_pertask_ssp_start_unit(void *gcc_data, void *user_data) +{ + targetm.have_stack_protect_combined_set = no; + targetm.have_stack_protect_combined_test = no; +} +#endif + __visible int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version) { @@ -100,5 +113,10 @@ __visible int plugin_init(struct plugin_name_args *plugin_info, register_callback(plugin_info->base_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &arm_pertask_ssp_rtl_pass_info); +#if BUILDING_GCC_VERSION >= 9000 + register_callback(plugin_info->base_name, PLUGIN_START_UNIT, + arm_pertask_ssp_start_unit, NULL); +#endif + return 0; }