From patchwork Fri Jan 18 10:58:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 155917 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3113192jaa; Fri, 18 Jan 2019 02:58:20 -0800 (PST) X-Google-Smtp-Source: ALg8bN6hdbYFik4ShhOLmLkomLnSekdv0FrpE+uDXJ10rPLwqu4vVLWEnBZ1Jm2Z/sRzkFhKSyMk X-Received: by 2002:a63:dc54:: with SMTP id f20mr17332687pgj.410.1547809100231; Fri, 18 Jan 2019 02:58:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547809100; cv=none; d=google.com; s=arc-20160816; b=NIXRTD+TPTDk4oLdP/pUJveos7ZM+5qmxro9REfRYl3+H3Ckk6WHQBnnyxaxJWyGb5 o88RpSRVmCoO9EGn9f2KmZws73XXJg390OocyCPuKmHVP1t94fRk9+7bWWkZXrHQMi24 NsOR5v0k6ZUTG5gO9STx160VOtO/SbXsudr5+XRMqwxFS7orvdqfKy22mljsRmjlwTaW IGUWb7fAm8dVNVdHqYrihr5yALhQhPi72ayT2D6U7J1sMRscE02n9hiDvHt9dc+v04VA GlNv1c9N0M0KpMlcKXU8gFaRlxij6rL6bd597LEu8HMZBbmcofMZQEF9nkLsn9Tdgnfc YM4w== 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=KEDamF1G6iG0yJARiV0f8WcLBjigYpz1ziosX686/wc=; b=idb+HajPMLyGsYeE9HBOHMsn0CHWcjPbXhE0ptftGIbWdKz/mJ4gR8rGRXYxBuJ1wT cQi3p5I3XJjlFlJ6Le+lVyE7qIw7Uugr6E/M+WacUHzcuY/VdjboTlYakkoBxuaZGdPG qBkl+z65fmllOKJFiq0eWhqN77KOYhXhkFZ1GvLJJ48W9UKnC/10OI2munKG2KFgY8fK ywyf6GEUijgENN9+4daQyD4bBFyBOR6mbTrvnNNJrWcur1VBLMTYe630iTFfcwNTCS1X yratVsP+cMBleLyYcbohybVIjipsZnLN1nzqiswsx/y0dw7nst8hL1SSNsZVuXCAB4dQ k7YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B5is7oZM; 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.19; Fri, 18 Jan 2019 02:58:20 -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=B5is7oZM; 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 S1727436AbfARK6R (ORCPT + 14 others); Fri, 18 Jan 2019 05:58:17 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:37032 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726927AbfARK6O (ORCPT ); Fri, 18 Jan 2019 05:58:14 -0500 Received: by mail-wm1-f68.google.com with SMTP id g67so4058984wmd.2 for ; Fri, 18 Jan 2019 02:58:13 -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=KEDamF1G6iG0yJARiV0f8WcLBjigYpz1ziosX686/wc=; b=B5is7oZMBWOvsBwStWjLCig5yDrvlpDdrOQaVttA4OM8lJLR8PUJgLQJuSn3uOAbM+ zfoXjGMTFKVFLsSR/uyYRuHpLI6LaXCt0F2x2foHcdKCMAKbVas/ppLo3H1u0lyBb8lB 5+hBoZaZERPR79NwjidOakjyX/n+JWU0dD5xI= 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=KEDamF1G6iG0yJARiV0f8WcLBjigYpz1ziosX686/wc=; b=rnpWctY/BjGZyzEXs03ICSvHOLeZrKBuZunzJMcyfYm4Q4KgMFhnsS5Qqk/6kEJih1 rF1CynTwLoa5it+JCBVXsPQB9qw+KsrCpZeWr5O4vNhsiOvOAGwmmtjSSfLsUsc0PBYU qpoQVUCc8jTGHPDeOnqHQKxJkyPPlXyLQ8rHyKKb8/ebr1ofT41J23+C2fevPIgBs2Fa Si7qNeJowXZqGirz/fXRJxKObDae49eLzIzotPNESjGHoUc8nVCl35MHoKZ/8qcpTKC5 Jfsmk58TYaAz0xMdfQrELhI2+oGjCm5okyENqX3wqD7lRIeATZ3TgysCq+m0khZ6L/x5 8i8w== X-Gm-Message-State: AJcUukcfCe9oLrdoWz+iw3rGD75oRETfod8NtwNvhTNorsPfgyYMk8od 9DcV71GsYicOBbQax7fg4RT1BDTNympNvA== X-Received: by 2002:a1c:a104:: with SMTP id k4mr14994971wme.54.1547809092789; Fri, 18 Jan 2019 02:58:12 -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.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Jan 2019 02:58:12 -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 , Kugan Vivekanandarajah Subject: [PATCH 1/2] gcc-plugins: arm_ssp_per_task_plugin: sign extend the SP mask Date: Fri, 18 Jan 2019 11:58:06 +0100 Message-Id: <20190118105807.26425-2-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 The ARM per-task stack protector GCC plugin hits an assert in the compiler in some case, due to the fact the the SP mask expression is not sign-extended as it should be. So fix that. Suggested-by: Kugan Vivekanandarajah Signed-off-by: Ard Biesheuvel --- scripts/gcc-plugins/arm_ssp_per_task_plugin.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) -- 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 de70b8470971..a65fbefb8501 100644 --- a/scripts/gcc-plugins/arm_ssp_per_task_plugin.c +++ b/scripts/gcc-plugins/arm_ssp_per_task_plugin.c @@ -13,7 +13,7 @@ static unsigned int arm_pertask_ssp_rtl_execute(void) for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) { const char *sym; rtx body; - rtx masked_sp; + rtx mask, masked_sp; /* * Find a SET insn involving a SYMBOL_REF to __stack_chk_guard @@ -33,12 +33,13 @@ static unsigned int arm_pertask_ssp_rtl_execute(void) * produces the address of the copy of the stack canary value * stored in struct thread_info */ + mask = GEN_INT(sext_hwi(sp_mask, GET_MODE_PRECISION(Pmode))); masked_sp = gen_reg_rtx(Pmode); emit_insn_before(gen_rtx_SET(masked_sp, gen_rtx_AND(Pmode, stack_pointer_rtx, - GEN_INT(sp_mask))), + mask)), insn); SET_SRC(body) = gen_rtx_PLUS(Pmode, masked_sp,