Message ID | 20241111-v5_user_cfi_series-v8-25-dce14aa30207@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 79E47D3ABF5 for <linux-mm@archiver.kernel.org>; Mon, 11 Nov 2024 20:55:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B6DC08D000D; Mon, 11 Nov 2024 15:55:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B1F618D0001; Mon, 11 Nov 2024 15:55:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8D36D8D000D; Mon, 11 Nov 2024 15:55:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 6AABB8D0001 for <linux-mm@kvack.org>; Mon, 11 Nov 2024 15:55:06 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 35264160D74 for <linux-mm@kvack.org>; Mon, 11 Nov 2024 20:55:06 +0000 (UTC) X-FDA: 82775018130.18.4A58411 Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) by imf09.hostedemail.com (Postfix) with ESMTP id EF52C140009 for <linux-mm@kvack.org>; Mon, 11 Nov 2024 20:54:35 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=Dhr4uZGJ; dmarc=none; spf=pass (imf09.hostedemail.com: domain of debug@rivosinc.com designates 209.85.215.174 as permitted sender) smtp.mailfrom=debug@rivosinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731358442; a=rsa-sha256; cv=none; b=TFKHcfemj06ZVuuYfxG7yEVMccqu6dQs+BzjnyEStomYJBC1oA75/r6TUonl3EG5rvUEM3 8/PgezYQnCPI9n038KrQGscXIHBw7/VaBXb8GclW/r5mHwQxNfNFRyhT/WKwBY8+cSzOE0 3/ULF8ZYADsN5+MXrk9lZY3MDNC4SBs= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=Dhr4uZGJ; dmarc=none; spf=pass (imf09.hostedemail.com: domain of debug@rivosinc.com designates 209.85.215.174 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=1731358442; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=v87E2FN7teOOU1wWTBhK9gVAN0VjVVh/KdbYNd+fh68=; b=vdJcyR/1xT7RJzL0pa3vAa6LbaTzzv7oO/z7JKPUfJg+4D5KfLgkGPWCJGCFeX6WQRJcvK oc0AAyiWS/MfV/rpjTPC9n2uK/hCMieXYZ7oCmFQ/2U2BHrYC+DiAZ/FoGkXzU/53NfGHQ bJvbhq3C/ZsS5FA7sAsyg2tMqr3UAO4= Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-7ee020ec76dso3825232a12.3 for <linux-mm@kvack.org>; Mon, 11 Nov 2024 12:55:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1731358503; x=1731963303; darn=kvack.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=v87E2FN7teOOU1wWTBhK9gVAN0VjVVh/KdbYNd+fh68=; b=Dhr4uZGJE1r6RCpIqKcyTq1nPyrfaKhZc5ZiQu/hNE/aUhHCAg6+ML3BmDw2vPscFY 0a3kBzMRRmDGvryFtkeSiD8A2b1Ro8ZDxuQj61G3u3xjajDJv/x0aRJnrmoXI8IexJkC 8UNjhZqBl3stfCiCWpyK4mJdAGiA6Uup8RmCtz34T3JO+bvAEZ94XCY4Pr3aJjN1fD5q CyyHDFgumxHCp1VQfmnMwoKR/8IoiKraahUqAzMCwT65qcKKi4+cKNKJoY10mqY8pxZb IFULvkIm6cABzGXcU3OvdGP9SSooux76hdhWSRn4zXTqJY4aDh87aM9+WM+h1Jq34qfa unRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731358503; x=1731963303; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=v87E2FN7teOOU1wWTBhK9gVAN0VjVVh/KdbYNd+fh68=; b=KWQHZJKN+VY8fNCeZxSQBF7whVtSL4PhtEEIRmPDdB5BL5jK2ErlwzH3yNEJ3yOgq2 Uk2kO7wUYW+TeurL4SWODvnUVgckGZQ6rNa3fAP6dFe+7oOwnPCplsasEEiJ4l7T1rec SODJ2YCQ1BgTeSoIeI7tC0bP8yxdn2qN2rf5fnnbUmjexw4iEQujhQk1cKtY0SeACAm/ 6Ec6VqUJTi85pvjtvXTS6rs1ydcwX724/GUwUwEONCvQMtb8eZsz6Dij9uccKGxDscE4 fEZZpxlPsWUUIJZqCJL3jLnybCbDx+7GMDyR1Q5H2d6MIa8ZdKaLZlzb9EzsrDhSWy3X Yb5A== X-Forwarded-Encrypted: i=1; AJvYcCU0NZG2Rl0TNSixlE2xgM0uDbA15me7ru6VljHGRshPVFbHeJi9hhUc1nQGwMxbbNdX6PPT8eSCLA==@kvack.org X-Gm-Message-State: AOJu0Yw8/klBdWp5Te6lUd5gKW+rOmBin/NbqBtoXmqySqIrH208Dlvb LB9jQwx00vYCv7gcvAgOes3LvA+OlAJR5JPWdGJO4cKxhi37Xgd/hcO/k9TSIW4= X-Google-Smtp-Source: AGHT+IE6pHU7K0D6Kovlo0iT4mPH8p4N2kcP8nKM47bgfKvZsvt7nFC76OWezD1by9y3vt8KBs+5Mg== X-Received: by 2002:a17:90b:1a92:b0:2e2:cd22:b092 with SMTP id 98e67ed59e1d1-2e9b171f93amr20303584a91.16.1731358503151; Mon, 11 Nov 2024 12:55:03 -0800 (PST) Received: from debug.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e9a5fd1534sm9059974a91.42.2024.11.11.12.55.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Nov 2024 12:55:02 -0800 (PST) From: Deepak Gupta <debug@rivosinc.com> Date: Mon, 11 Nov 2024 12:54:10 -0800 Subject: [PATCH v8 25/29] riscv: kernel command line option to opt out of user cfi MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20241111-v5_user_cfi_series-v8-25-dce14aa30207@rivosinc.com> References: <20241111-v5_user_cfi_series-v8-0-dce14aa30207@rivosinc.com> In-Reply-To: <20241111-v5_user_cfi_series-v8-0-dce14aa30207@rivosinc.com> To: Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>, Dave Hansen <dave.hansen@linux.intel.com>, x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>, Andrew Morton <akpm@linux-foundation.org>, "Liam R. Howlett" <Liam.Howlett@oracle.com>, Vlastimil Babka <vbabka@suse.cz>, Lorenzo Stoakes <lorenzo.stoakes@oracle.com>, Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu>, Conor Dooley <conor@kernel.org>, Rob Herring <robh@kernel.org>, Krzysztof Kozlowski <krzk+dt@kernel.org>, Arnd Bergmann <arnd@arndb.de>, Christian Brauner <brauner@kernel.org>, Peter Zijlstra <peterz@infradead.org>, Oleg Nesterov <oleg@redhat.com>, Eric Biederman <ebiederm@xmission.com>, Kees Cook <kees@kernel.org>, Jonathan Corbet <corbet@lwn.net>, Shuah Khan <shuah@kernel.org> Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, alistair.francis@wdc.com, richard.henderson@linaro.org, jim.shu@sifive.com, andybnac@gmail.com, kito.cheng@sifive.com, charlie@rivosinc.com, atishp@rivosinc.com, evan@rivosinc.com, cleger@rivosinc.com, alexghiti@rivosinc.com, samitolvanen@google.com, broonie@kernel.org, rick.p.edgecombe@intel.com, Deepak Gupta <debug@rivosinc.com> X-Mailer: b4 0.14.0 X-Rspam-User: X-Rspamd-Queue-Id: EF52C140009 X-Rspamd-Server: rspam01 X-Stat-Signature: m9niau89fdf8bp4wjnaeqj5g8iwsdcwx X-HE-Tag: 1731358475-427242 X-HE-Meta: U2FsdGVkX1/tjyOqDrw+jTRToHirRcZLhqN1NiNfqAYGwLN8hrMSEkaIN35MfqJ9DGKnr1xnm9DOny4kDz/kGjcvizjJVTEVa32y53jZbNMqUozoWb3tGnLLtUm7rwsN1vz+ftgjIrjKrUYs7cCJWPheV4+76ktug9Ns2weXV4RCBTfw0cY4vxCWisrPUYTUZEoKo3kNDFWvIna5epGoIvz532+LqikRywdftKOhZayIrm9m3z3Qm5HByZd2Q127hMKX97tjnRlYeGTUqdOIto72z2cpEvFWN4lXGQ8NSeafq3uJZTYk5xQWQY+i/16dxfJJDesObrNHCf/vd1op6VRoTbGNeRsDVXXnvoakrdp4wmxB4wstSbjvaMY9q5c+slYGvxHvssyIjXhXW3QKGWG6Ash+iUMm3ZLhs69UrBbryAy9Icwo7LmBaXZvHwAcP+oOySMJY6PmzPUOZh+5vwB9KEFPPm/RljQe5gLbhftvPsIFOStH/gG5SwFZH1EyBWP9r0fp+xeyvKr9cTNrLKu5m6roLNJsKDtTgfBZV+q3zTc1qbns7EyBlWojIkLFShuZbxJhu0Rz+D7z6Y2GCrkXXtPPn4JvELPivUCIpAueSywOI1xm+fE4VkVCvZ067FdbXF152+KDhrNYHdXrWKV6Qw3csuQXoOsvoAxFMaJwEHH9WX044L6zG9jBsG55xRiCF9Qrv9Rvl3/QcyiDqroGE6yA6hy4mEJ9All2qFUZiWvGUllIS4X2WMMooyZTJ19oE49dNnalpYNafqzRgfy4xLaeSIp9X51E4GwsH9td/MZg6oDgDIrOusNyBLY6Gglv4l/Oi/AuNbrD+obn7tOh29wHmUcOrZbycwhLfazGVFZM7k171Uv3AIEMAqeBZuC1qzXYdhSElzz9CKK/77uECRLd7KMVD6JOxJmY5dLv3bl1JIf1QG18+XtvLC6/zl4z8QDp/mU3mbyCido JqpodTp1 E5veILaJVPevsR2hZTRrmRzdEUT1hET9hYPHlq+Pw/RkQth28kMlzzdLuFVLTL0Nkqz/jMHeQvPpJ+Hm9nnrPfTK0OKVwoHVQtzmaLoWlXo9qXWcETc1qGHJbGaPdkaKNWal5tk9mW3kzBMW/ivhK/31V1GMtxIExOolB0vereUEWqoXp75yxJxHED8piyvlItGloX8ceLgoNBWTx42lAfht/kwNXm/Xa7FfPwhiXIaZZbMpWYWY6l2y6gV14Ktw9ePRIkQQJQIvbb5IhIyjMMNmiAE0aV0xX7zUQLhbG+I17EbhrXrL5okzLYidN1XMXI6u18cUotkIg6838Rhctkv43syfAb06YY8ynMtJ5PnU58bOxW+Q61QU9qVMoSM7n9d+VMnIxNvJRiu/gKRtguWLlXo8P4qzjUeVxYMgmBOJfAsWoiavqBlvWpw4LKQY0zQWzUgmh+GFAHoSJfXgw7pB4mg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, 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/kernel/usercfi.c b/arch/riscv/kernel/usercfi.c index 04b0305943b1..223dfa482deb 100644 --- a/arch/riscv/kernel/usercfi.c +++ b/arch/riscv/kernel/usercfi.c @@ -17,6 +17,8 @@ #include <asm/csr.h> #include <asm/usercfi.h> +bool disable_riscv_usercfi; + #define SHSTK_ENTRY_SIZE sizeof(void *) bool is_shstk_enabled(struct task_struct *task) @@ -393,6 +395,9 @@ int arch_set_shadow_stack_status(struct task_struct *t, unsigned long status) unsigned long size = 0, addr = 0; bool enable_shstk = false; + if (disable_riscv_usercfi) + return 0; + if (!cpu_supports_shadow_stack()) return -EINVAL; @@ -472,6 +477,9 @@ int arch_set_indir_br_lp_status(struct task_struct *t, unsigned long status) { bool enable_indir_lp = false; + if (disable_riscv_usercfi) + return 0; + if (!cpu_supports_indirect_br_lp_instr()) return -EINVAL; @@ -504,3 +512,15 @@ int arch_lock_indir_br_lp_status(struct task_struct *task, return 0; } + +static int __init setup_global_riscv_enable(char *str) +{ + if (strcmp(str, "true") == 0) + disable_riscv_usercfi = true; + + pr_info("Setting riscv usercfi to be %s\n", (disable_riscv_usercfi ? "disabled" : "enabled")); + + return 1; +} + +__setup("disable_riscv_usercfi=", setup_global_riscv_enable);
This commit adds a kernel command line option using which user cfi can be disabled. Signed-off-by: Deepak Gupta <debug@rivosinc.com> --- arch/riscv/kernel/usercfi.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)