Message ID | 20240912231650.3740732-28-debug@rivosinc.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5314AEEE272 for <linux-mm@archiver.kernel.org>; Thu, 12 Sep 2024 23:19:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D1DE46B00C0; Thu, 12 Sep 2024 19:19:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CA5D58D0003; Thu, 12 Sep 2024 19:19:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AA9EB6B00C3; Thu, 12 Sep 2024 19:19:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 872B36B00C0 for <linux-mm@kvack.org>; Thu, 12 Sep 2024 19:19:07 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 3A0D040E84 for <linux-mm@kvack.org>; Thu, 12 Sep 2024 23:19:07 +0000 (UTC) X-FDA: 82557653934.24.A3E8EA8 Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by imf05.hostedemail.com (Postfix) with ESMTP id 6C68C10000B for <linux-mm@kvack.org>; Thu, 12 Sep 2024 23:19:05 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=HQYNVKBs; dmarc=none; spf=pass (imf05.hostedemail.com: domain of debug@rivosinc.com designates 209.85.216.46 as permitted sender) smtp.mailfrom=debug@rivosinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726183116; a=rsa-sha256; cv=none; b=YcAQQUUsx+18X46EtD4dB8151r0SeJMGKlDY6ERfSzFL8yK3Nf4cBK0Df5VrK/iNYghDj5 SturpxJ+vSQmYKqd42P7uFWFquUdU4rpiU6tm7YYLb+f+pF1iBaUNRwkBTqZ9jEGSOT35A CDRw+zXG+LvoCAC5J2/qN4K5BWWuB4I= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=HQYNVKBs; dmarc=none; spf=pass (imf05.hostedemail.com: domain of debug@rivosinc.com designates 209.85.216.46 as permitted sender) smtp.mailfrom=debug@rivosinc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1726183116; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=CbpKVNKRMfAtkqYXzA8w+8eVro8K48y9vmHyffj7Qao=; b=mYchrT0fmigd5ha/EctZa7HIoo4mnB3CdcVj6IDzNWy2FTZbn2nQRQ8Y/ygT0XmiZ2y3Vl KZtbiJEd43fSbZH7t7prmiX+Khub2Wpgc7M0D5i3XzbEsHC3mYCeBLjvy1MQXnz/w/6Z+B f82qkwKTZH2wI3TaSCLguPNL8KF3zGU= Received: by mail-pj1-f46.google.com with SMTP id 98e67ed59e1d1-2d86f71353dso1108836a91.2 for <linux-mm@kvack.org>; Thu, 12 Sep 2024 16:19:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1726183144; x=1726787944; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CbpKVNKRMfAtkqYXzA8w+8eVro8K48y9vmHyffj7Qao=; b=HQYNVKBs+J/oE1N/Mn0EtGfY0NLDMWeEHcGelFoZoBcKHBeD9yH+XiXPRILCtWAL+F 57PqJOpahbeFgOxYi5O0icnxyN9mYwgwXihkI2lRy7Bg0nKnaeO+uG3He6sidd17mtjh +kCHBveIWP1t8bRjX/GEEq1W1n8Ld0xbMatMQP0bzkseHHaCQZV69r3QxrhZPJclS4SI vqanOdUwMoYNqn+dD8owxj2GpZI7UcXxYFJbnKx5N5ojiByC5inZtcJmVjxwgNZKjNjm PKbw20sNkFevwj1JD5V4SORdYwTjqaD3gNBOhPfcxVcs5J+kWOZLZis/Mb/9G2FY2AST n2OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726183144; x=1726787944; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CbpKVNKRMfAtkqYXzA8w+8eVro8K48y9vmHyffj7Qao=; b=SNi0lxmQgJZvCcuAli4RiT0OR2JbixbUezM0mCXluxuJ8Tct77yEGzWEBvBSIYkCFK fVGMr7JDhpBGJ4G+O7n4DJni4eq3QBgjoEHUxWUEId9fUiQ5qUFeH6GPm0bBoL6AsvQM GdcQZrS+IVSzT2GnPvqKT1VhC3XRKEZWAAuLvj9ocWSQFhCEJOiK6YelnYiFSEBZVy+J dok5WZBmKzd2QvYm6rG0Fb3OrTXxnp+rfyoYYj2ompXt/7ZAQuCdjrSiGqUl4urVFqNc h3qW4SGVqJ56RevUlhAQeM3I5MSoGSIIoRQkmTSKL91pqGlqhi3v0xaV6V9AoSosJku/ Vo9w== X-Forwarded-Encrypted: i=1; AJvYcCWOgA0a6PheC/AFf9iPvsF4uBeWA9M398jqfqVn+Y1iNfG7oUhS4mUiJIonW79lyWLhKcJ9M+VxfA==@kvack.org X-Gm-Message-State: AOJu0Yw0uGTSq0NHQ1kXkjqkTkjPXck3+k78WMcJwtP4zdb2czLO9ciQ 7AMs+l7AYHV+Vgo47oxa53ARk9OS3bpNjshsO2zcpAFcFulkQxMAADrS0k/AbhY= X-Google-Smtp-Source: AGHT+IERJQSRxOQYUrcoeWqKKFDuWvirFZC93eScxDPtDLfWGyU08Qp8o+SGLVlkTYVlfOG74jZpnw== X-Received: by 2002:a17:90b:1043:b0:2d3:da6d:8330 with SMTP id 98e67ed59e1d1-2db9ff79ba2mr4907026a91.4.1726183144244; Thu, 12 Sep 2024 16:19:04 -0700 (PDT) Received: from debug.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2db6c1ac69asm3157591a91.0.2024.09.12.16.19.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 16:19:03 -0700 (PDT) From: Deepak Gupta <debug@rivosinc.com> To: paul.walmsley@sifive.com, palmer@sifive.com, conor@kernel.org, linux-doc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: corbet@lwn.net, palmer@dabbelt.com, aou@eecs.berkeley.edu, robh@kernel.org, krzk+dt@kernel.org, oleg@redhat.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, peterz@infradead.org, akpm@linux-foundation.org, arnd@arndb.de, ebiederm@xmission.com, kees@kernel.org, Liam.Howlett@oracle.com, vbabka@suse.cz, lorenzo.stoakes@oracle.com, shuah@kernel.org, brauner@kernel.org, samuel.holland@sifive.com, debug@rivosinc.com, andy.chiu@sifive.com, jerry.shih@sifive.com, greentime.hu@sifive.com, charlie@rivosinc.com, evan@rivosinc.com, cleger@rivosinc.com, xiao.w.wang@intel.com, ajones@ventanamicro.com, anup@brainfault.org, mchitale@ventanamicro.com, atishp@rivosinc.com, sameo@rivosinc.com, bjorn@rivosinc.com, alexghiti@rivosinc.com, david@redhat.com, libang.li@antgroup.com, jszhang@kernel.org, leobras@redhat.com, guoren@kernel.org, samitolvanen@google.com, songshuaishuai@tinylab.org, costa.shul@redhat.com, bhe@redhat.com, zong.li@sifive.com, puranjay@kernel.org, namcaov@gmail.com, antonb@tenstorrent.com, sorear@fastmail.com, quic_bjorande@quicinc.com, ancientmodern4@gmail.com, ben.dooks@codethink.co.uk, quic_zhonhan@quicinc.com, cuiyunhui@bytedance.com, yang.lee@linux.alibaba.com, ke.zhao@shingroup.cn, sunilvl@ventanamicro.com, tanzhasanwork@gmail.com, schwab@suse.de, dawei.li@shingroup.cn, rppt@kernel.org, willy@infradead.org, usama.anjum@collabora.com, osalvador@suse.de, ryan.roberts@arm.com, andrii@kernel.org, alx@kernel.org, catalin.marinas@arm.com, broonie@kernel.org, revest@chromium.org, bgray@linux.ibm.com, deller@gmx.de, zev@bewilderbeest.net Subject: [PATCH v4 27/30] riscv: create a config for shadow stack and landing pad instr support Date: Thu, 12 Sep 2024 16:16:46 -0700 Message-ID: <20240912231650.3740732-28-debug@rivosinc.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240912231650.3740732-1-debug@rivosinc.com> References: <20240912231650.3740732-1-debug@rivosinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Queue-Id: 6C68C10000B X-Rspamd-Server: rspam01 X-Stat-Signature: 1znf1bau1or18g1b17ty7raj9hdf7zz6 X-HE-Tag: 1726183145-532798 X-HE-Meta: U2FsdGVkX1/RWZGj9WuS+5a2aSrD0ZuHB7Nmy6j9Am8L3UX54f9EwnoQ3jt84pQjYXXDEFCrxsP+cypT+9mh+RaXZE+QwXDClRKyqEysIc2WYAwuS7GLmOXzD3Pc2n84/w9uqAiqsbFXnehzn/mDjTxyPdBdNNmqtW865zUYs29BUqPDn0dJfxIZW87x0g2FHiUjF+nH5fYLUMqumXU84AzwD9Y2IT2KImTCwAtjMkiz/7L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bDh/d40b5TEmz3u6XSOWNJNol6V8YnAFxqDeV0WZWzDFECvYFbNTIZgWfD5QUeEJ+WVZ6tWchqsu19rtiN6eMb9j7jJBmjg6DsrecU8Qx/8bOaMruoJi4ihPNRgnwfIzE6BZ8kycxkp0e8SVdFNlYTdNHt4yfY7bqwUQA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.024304, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
riscv control-flow integrity for usermode
|
expand
|
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index d1d629a3eb91..24bf08c905d2 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -231,6 +231,25 @@ config ARCH_HAS_BROKEN_DWARF5 # https://github.com/llvm/llvm-project/commit/7ffabb61a5569444b5ac9322e22e5471cc5e4a77 depends on LD_IS_LLD && LLD_VERSION < 180000 +config RISCV_USER_CFI + def_bool y + bool "riscv userspace control flow integrity" + depends on 64BIT && $(cc-option,-mabi=lp64 -march=rv64ima_zicfiss) + depends on RISCV_ALTERNATIVE + select ARCH_HAS_USER_SHADOW_STACK + select ARCH_USES_HIGH_VMA_FLAGS + help + Provides CPU assisted control flow integrity to userspace tasks. + Control flow integrity is provided by implementing shadow stack for + backward edge and indirect branch tracking for forward edge in program. + Shadow stack protection is a hardware feature that detects function + return address corruption. This helps mitigate ROP attacks. + Indirect branch tracking enforces that all indirect branches must land + on a landing pad instruction else CPU will fault. This mitigates against + JOP / COP attacks. Applications must be enabled to use it, and old user- + space does not get protection "for free". + default y + config ARCH_MMAP_RND_BITS_MIN default 18 if 64BIT default 8
This patch creates a config for shadow stack support and landing pad instr support. Shadow stack support and landing instr support can be enabled by selecting `CONFIG_RISCV_USER_CFI`. Selecting `CONFIG_RISCV_USER_CFI` wires up path to enumerate CPU support and if cpu support exists, kernel will support cpu assisted user mode cfi. If CONFIG_RISCV_USER_CFI is selected, select `ARCH_USES_HIGH_VMA_FLAGS` and `ARCH_HAS_USER_SHADOW_STACK` for riscv. Signed-off-by: Deepak Gupta <debug@rivosinc.com> --- arch/riscv/Kconfig | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)