Message ID | 20241008-v5_user_cfi_series-v6-29-60d9fe073f37@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 2B4E0CF0429 for <linux-mm@archiver.kernel.org>; Tue, 8 Oct 2024 22:39:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E224A6B00C7; Tue, 8 Oct 2024 18:39:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DD1206B00CE; Tue, 8 Oct 2024 18:39:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C4BBE6B00CF; Tue, 8 Oct 2024 18:39:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 1BFD36B00C7 for <linux-mm@kvack.org>; Tue, 8 Oct 2024 18:39:12 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 3FC2D1A0C8E for <linux-mm@kvack.org>; Tue, 8 Oct 2024 22:39:09 +0000 (UTC) X-FDA: 82651902102.14.5405652 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by imf09.hostedemail.com (Postfix) with ESMTP id E4F35140004 for <linux-mm@kvack.org>; Tue, 8 Oct 2024 22:39:09 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=PpmoIxwN; spf=pass (imf09.hostedemail.com: domain of debug@rivosinc.com designates 209.85.210.174 as permitted sender) smtp.mailfrom=debug@rivosinc.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728427014; 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=Iv4iGVPETdra3MKQf2NWKMBAajr7s4N4hA6eTIOU8rY=; b=Yjb7DDk0wZMNDEJjgGK4JAQDdYmYWB42XjWCmMEWtRdEmsnDSSZqWlbdynM4nLVrnWYNka PmKTvDjO3fOG5kOIReLEyXqBhUwpneiknvSptL1x2jitx9yaDVXsLZ4aQvOxZwGyjHqjMp RBucv0QdHFttCTcMSVmYhfpUAgAaIHI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728427014; a=rsa-sha256; cv=none; b=7t9PRb+YkRpnxjacXT5jv6AFM27IXueggOWe2UYUS9UslvzYS4vh85f/sIXKgF8yLVUo7f aOrxhFruFd0c5SPM52Men2+kTT2bWmGvdEUB3VrAKEEgECkreuW6Hc+6Z2PfyCFCjPohvo wxlCFdWsTsZZ3GN8JS4TQWKNpfDZUiI= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=PpmoIxwN; spf=pass (imf09.hostedemail.com: domain of debug@rivosinc.com designates 209.85.210.174 as permitted sender) smtp.mailfrom=debug@rivosinc.com; dmarc=none Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-71df2b0a2f7so3055183b3a.3 for <linux-mm@kvack.org>; Tue, 08 Oct 2024 15:39:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1728427149; x=1729031949; 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=Iv4iGVPETdra3MKQf2NWKMBAajr7s4N4hA6eTIOU8rY=; b=PpmoIxwN7A8/K1zzD8PyR943VaWbiOdwk9lfedCp5JLZxK4rI5ruKArKmmpQrde82v ChUsKBZpQkGrS/UrEha5+V2dPb5djJY7I8GFyEtC+rbSSIcpkFiVnb6YJSGietbcXYZQ 4N46V5hMhmkTdvk6dNeWzAo9hTQGUNm6FcC5vd0w7W0sX0iffepwpT23MBbWQAVCgm6c X7TZjcA8I5B0O9IGb2awDyRZMgDKLFM5YjGdZUhgM9aPzILHeRDeNivXWCjBsxsR9Mm5 47EWBuvVYMEbveRZZHahllhFZ0E4ylc2+O19/Ax/VNgnD3k1eyZC/ZO0p5HWpHzjUM1m mHKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728427149; x=1729031949; 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=Iv4iGVPETdra3MKQf2NWKMBAajr7s4N4hA6eTIOU8rY=; b=Q/5h2HINcEX3L6Ft6z01vW0iwtmGe90cJWidtAIh3lO8I6fI/BCZC/y4Xa07Vy7xDO JFSGRm91Lpa8feh3YNrn26sGkm4U5swBUmjhSCpIN896IX2/mATMsZU7UcFxU4cBxeUH 0RaK5ZyEgomuKhuvvmID193abKC8eaHRGR01zXPF1GQaaPiZhsq+8HtMOnw0cc5g+mIL 8mkeLms/g4/A6TeC7eF587Ij+amC/QCJRJ4f2+lkGGdywGR84K2ebWey3D3kMHqdn+zh cTJO9JlXOTVfMF1SkVGC/GMF5ZYnw6mCYitPv7kys9HE++jj4nUfEuACibofgN1uGooS 6Usg== X-Forwarded-Encrypted: i=1; AJvYcCXBZRTEOnIIgMW3ZUdrh1qpkJ2jKP/+eWWF0Txzs0bWZIb6Ip9P6/RHq3WjOMbdZAqIBTT6Dbo9JQ==@kvack.org X-Gm-Message-State: AOJu0YztKObor2rJ48HwgUVikbFYVHdzP+gGwQ7J/kHxvRLPoYU9Pm+6 Zeg38XA1ksypL8snQ+H8YgohzxHOdc3uluvcMBr/GytKPG1JYsspWABTfIBoVDs= X-Google-Smtp-Source: AGHT+IHjoVQEvv2ZL9MtUd0PoitnGhc0oOx8qTU8cQ9IzAvoigYxCtNZAaIOLoagpVlmMdjHekGPKw== X-Received: by 2002:a05:6a00:244d:b0:71d:f423:e6d8 with SMTP id d2e1a72fcca58-71e1db680ecmr668933b3a.6.1728427148723; Tue, 08 Oct 2024 15:39:08 -0700 (PDT) Received: from debug.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71df0ccc4b2sm6591270b3a.45.2024.10.08.15.39.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 15:39:08 -0700 (PDT) From: Deepak Gupta <debug@rivosinc.com> Date: Tue, 08 Oct 2024 15:37:11 -0700 Subject: [PATCH v6 29/33] 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: <20241008-v5_user_cfi_series-v6-29-60d9fe073f37@rivosinc.com> References: <20241008-v5_user_cfi_series-v6-0-60d9fe073f37@rivosinc.com> In-Reply-To: <20241008-v5_user_cfi_series-v6-0-60d9fe073f37@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-Server: rspam04 X-Rspamd-Queue-Id: E4F35140004 X-Stat-Signature: 7f19emsc54q5qp68tuu739figt7cerhb X-HE-Tag: 1728427149-601059 X-HE-Meta: U2FsdGVkX189mDFwnnCyCd9HH8wwcR3uKGvXiE1S44fiUGZxUrzBQVz2fb0z7MOGCchSj/OptabpL+uhJmT67K+oskmVUWdkuf7hyHYar9kPE/DaxhhND3BTTBcQNG9BA+7Itr2RaFrgel6jgsxKEfwFteGfIyEmTvfKDXwZZIEKcPQGrIanOi0tXHoCv9bpx510HTwmz3xqpZv5mTcdyxI0hiuMJPrn1wctFwxvMgCDLubFmkvC5VSzvtQ7JqD2UwHv8I0E8sN73Hxes7uX+heyvILzGvgPRwFvB/BJbCodrmXxh5xWZikS2dYmkWbt9m+X6V69TJmAXlH3Payag1biLjwhVIF5jnEmfNq2He5B/1y244pMSKLJfGy+JcBWZBgcrMXi94gFZB6n6UGNhVcEKhKYvHSP/6ZI3aCq8p3rGDqxJ5rsb6Dv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CU2cET6wKP3Jhvcw4tKsTRIFwspXlNBBOqe6rdXRekr/1PxblChztZ8tb3JCzfhku8A= 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 92d03eb76c03..fb17a67568a8 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(+)