From nobody Fri May 17 08:15:10 2024 Delivered-To: importer2@patchew.org Received-SPF: pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; envelope-from=linux-kernel-owner@vger.kernel.org; helo=vger.kernel.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1613107063; cv=none; d=zohomail.com; s=zohoarc; b=ir5NLvyf+jk+ATJuehmLk4bXmLPpAH7yaGuEfy3RRtbz5uD4HJeEznUgqdi00cxbEgRoelCMdmkcERngQco9TC9ZBJW0GRA5vlqq562DT9B2ZEwq6985MuS7kz2PiBij6PU8fJFA4v7JshHBDDOdgkM/7O3ABYdoZfjA00DmhwI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613107063; h=Content-Type:Cc:Date:From:List-Id:MIME-Version:Message-ID:Sender:Subject:To; bh=UsZfh0ugYXVBA8yeF7pE4YFwStzOHtAmek3RdORCX+E=; b=TlCEkT+AUjpvIwVDU3ATvwvyKknJVvnMeMy9XPj+Fi+vFMQHrqUepMvxzZMs00qXEhCywK973Nz+rG6A77XmZsGHHfZ/1H9irL9Fd2lbmyuT5SScFRx7IjZovBaFb29OMJXBioOqxnaA4JRlAI4b81+3kMdJCPAyZmULsaL6IaQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx.zohomail.com with SMTP id 1613107062811250.97892963361005; Thu, 11 Feb 2021 21:17:42 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229575AbhBLFP5 (ORCPT ); Fri, 12 Feb 2021 00:15:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbhBLFPq (ORCPT ); Fri, 12 Feb 2021 00:15:46 -0500 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEABEC061574 for ; Thu, 11 Feb 2021 21:15:05 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id f127so8558934ybf.12 for ; Thu, 11 Feb 2021 21:15:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:cc; bh=UsZfh0ugYXVBA8yeF7pE4YFwStzOHtAmek3RdORCX+E=; b=SzJL9vBy8lVTuUNig36qJ5I3eO9VZPL2gttToIRg/rfH0Rl+BdC92sD5+F5r7Z6XPS 7Arqpz65uTK4op7fIZV5M2CrdBGfXqaaSosq+n10YCqivOICp0yUQP6hdB54n5fIw7pe 1Hy+SVqmSBOeUvK4ugcpZHP+89/UvS+cxYhlmLMrNoANYkOwoaGuR7krjBoK7NZjq9zz x0LXWTU0Pq/Ri79FmStfQL4v28EPwr9qbwOD25x6W+CKPf7BwpB6AO8NceInXPHtwGQf lO/RywqfNIpjw86uTffqIHFIHPBUUsSTfvDx7CbnUSXaJ1drDsn1R+To1Mti4LY1JG6W rwNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :cc; bh=UsZfh0ugYXVBA8yeF7pE4YFwStzOHtAmek3RdORCX+E=; b=ibnQyCqc7T7F42uMt/dYxT/RM9WXweU21uONUfo3NStSOx6LLDPmHdR8IOGtqHcarZ drQvxxehi84gdXTP/HF6petYm/zGtOzPrF4f8BjaTX1sxxd+kFXOApKnOqu12KVpa2MQ qychjDmHHSq5F37WnP31njCWByFA2tZU4YhJShDa/o7ePH5ABCG0aO5Alxm+FG/BZmpN LIRmemJibmn323ErRfawbA7NgB2dD1L6doGToG4iCd+2TfHLV6ACfavTsN1fNZUmmswx dB7mvfLk1kfx9UN5mB3Vtas+SI4QTRyAAWtsSFYELYtwmoo4WGw37k2EJ8b36Tzfcv5b siNw== X-Gm-Message-State: AOAM531SZ3Y1VMdiRKuATZt1+UDCb0Wyssxn1tnzMPTC318ncp6jdZyp Ceal48VLhAPH2sHWFMXQqtlqRgDYgjDv X-Google-Smtp-Source: ABdhPJycIY3mywfzpize22XFsRLYY7NYl3ks6OFPoxSO3RoiL0EL5Ir2jRncglUNKqPUXzz6G9tAhg3k4Nay Sender: "jiancai via sendgmr" X-Received: from jiancai.svl.corp.google.com ([2620:15c:2ce:0:9923:3694:46ec:d62]) (user=jiancai job=sendgmr) by 2002:a25:ce51:: with SMTP id x78mr1842451ybe.198.1613106904807; Thu, 11 Feb 2021 21:15:04 -0800 (PST) Date: Thu, 11 Feb 2021 21:14:58 -0800 Message-Id: <20210212051500.943179-1-jiancai@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.30.0.478.g8a0d178c01-goog Subject: [PATCH] ARM: Implement Clang's SLS mitigation From: Jian Cai Cc: ndesaulniers@google.com, manojgupta@google.com, llozano@google.com, clang-built-linux@googlegroups.com, Jian Cai , Russell King , Catalin Marinas , Will Deacon , James Morris , "Serge E. Hallyn" , Nathan Chancellor , Arnd Bergmann , Masahiro Yamada , Kees Cook , Ard Biesheuvel , Daniel Palmer , "=?UTF-8?q?Andreas=20F=C3=A4rber?=" , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-ZohoMail-DKIM: pass (identity @google.com) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This patch adds a config CONFIG_HARDEN_SLS_ALL that can be used to turn on -mharden-sls=3Dall, which mitigates the straight-line speculation vulnerability, or more commonly known as Spectre, Meldown. Notice -mharden-sls=3D has other options as below, and this config turns on the strongest option. all: enable all mitigations against Straight Line Speculation that are impl= emented. none: disable all mitigations against Straight Line Speculation. retbr: enable the mitigation against Straight Line Speculation for RET and = BR instructions. blr: enable the mitigation against Straight Line Speculation for BLR instru= ctions. Link: https://reviews.llvm.org/D93221 Link: https://reviews.llvm.org/D81404 Link: https://developer.arm.com/support/arm-security-updates/speculative-pr= ocessor-vulnerability/downloads/straight-line-speculation Link: https://crbug.com/1171521 Suggested-by: Manoj Gupta Signed-off-by: Jian Cai --- arch/arm/Makefile | 4 ++++ arch/arm64/Makefile | 5 +++++ security/Kconfig.hardening | 11 +++++++++++ 3 files changed, 20 insertions(+) diff --git a/arch/arm/Makefile b/arch/arm/Makefile index 4aaec9599e8a..11d89ef32da9 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -48,6 +48,10 @@ CHECKFLAGS +=3D -D__ARMEL__ KBUILD_LDFLAGS +=3D -EL endif =20 +ifeq ($(CONFIG_HARDEN_SLS_ALL), y) +KBUILD_CFLAGS +=3D -mharden-sls=3Dall +endif + # # The Scalar Replacement of Aggregates (SRA) optimization pass in GCC 4.9 = and # later may result in code being generated that handles signed short and s= igned diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index 90309208bb28..8fd0ccd87eca 100644 --- a/arch/arm64/Makefile +++ b/arch/arm64/Makefile @@ -34,6 +34,11 @@ $(warning LSE atomics not supported by binutils) endif endif =20 +ifeq ($(CONFIG_HARDEN_SLS_ALL), y) +KBUILD_CFLAGS +=3D -mharden-sls=3Dall +endif + + cc_has_k_constraint :=3D $(call try-run,echo \ 'int main(void) { \ asm volatile("and w0, w0, %w0" :: "K" (4294967295)); \ diff --git a/security/Kconfig.hardening b/security/Kconfig.hardening index 269967c4fc1b..d83c406c81a3 100644 --- a/security/Kconfig.hardening +++ b/security/Kconfig.hardening @@ -121,6 +121,17 @@ choice =20 endchoice =20 + +config CC_HAS_HARDEN_SLS_ALL + def_bool $(cc-option,-mharden-sls=3Dall) + + config HARDEN_SLS_ALL + bool "enable SLS vulnerability hardening" + depends on CC_HAS_HARDEN_SLS_ALL + help + Enables straight-line speculation vulnerability hardening + at highest level. + config GCC_PLUGIN_STRUCTLEAK_VERBOSE bool "Report forcefully initialized variables" depends on GCC_PLUGIN_STRUCTLEAK --=20 2.30.0.478.g8a0d178c01-goog