From patchwork Thu Sep 12 23:16:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepak Gupta X-Patchwork-Id: 13802824 Return-Path: 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 D7576EEE271 for ; Thu, 12 Sep 2024 23:17:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3A4D56B0089; Thu, 12 Sep 2024 19:17:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 355DE6B008A; Thu, 12 Sep 2024 19:17:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 181486B008C; Thu, 12 Sep 2024 19:17:15 -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 ECAF96B0089 for ; Thu, 12 Sep 2024 19:17:14 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 7024EA0E32 for ; Thu, 12 Sep 2024 23:17:14 +0000 (UTC) X-FDA: 82557649188.27.C377B49 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by imf10.hostedemail.com (Postfix) with ESMTP id 826FBC000D for ; Thu, 12 Sep 2024 23:17:11 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=e7fWWBMM; spf=pass (imf10.hostedemail.com: domain of debug@rivosinc.com designates 209.85.214.170 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=1726182926; 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=Nw1dKcVSLCCt5un4d6VomXZplHXDD/4tgdiLE024NX8=; b=B4pz+6eFKyJJHKoykhAaNQwcUY3bGDvNQkX+Qy0CVsC+cEIenUtSfrDkWeIE7A0y7ojHw3 DjrAr9zhyTBuJh4uGRCEIEWjKzLR0FtY3awZ3ayywLa/veY6Wxe/+hp7y1TbuuC1W0lt3A aSM0pkc6AqwbVsCcB/C1UZ5gXeMiqMU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726182926; a=rsa-sha256; cv=none; b=4MlZX6xncuZK9iUotw15Y4+MEoy+cIeysPJMINFfGw4NMpQeRAYYdVLPAOvpUSq/Alcy+g LDnLVxRA3Q2eKynARXyhBP/15gZswuQx4PdgqsRLk65lVlidhIh/enoo4GoFF+qAMUbqSU xvGC1M3bNA8+NWfwELtt0xzD50ORoLk= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=e7fWWBMM; spf=pass (imf10.hostedemail.com: domain of debug@rivosinc.com designates 209.85.214.170 as permitted sender) smtp.mailfrom=debug@rivosinc.com; dmarc=none Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-2068bee21d8so17142125ad.2 for ; Thu, 12 Sep 2024 16:17:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1726183030; x=1726787830; 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=Nw1dKcVSLCCt5un4d6VomXZplHXDD/4tgdiLE024NX8=; b=e7fWWBMMsU9i31Pe6tHEEFgmJooIae+gDrg69RTc3YCt7opR00Tq21qJke1hp4Ktjv lcD3Me0E4hv7vT1mD5AuRLBhEwMRhNeZ8kHKrRLL+sOHaVZf+drsnfEEjxkEWLeFi8+Q MVIjX09NIShNBPts4rXl32THvS+vMLEFJjun7MEq/VdCcTyZ4z4/1AV3rhdzYzYWWlH0 +Eiy/IaMpw0eYjNW3c5I301YnUbiCXRmmsZ9bq2aMXcPx+VPf6oSF1JblfBRmAAnUPCb WaSRs8GvYf8OR1np+DWIHuw2vfOB0194uvg30NvotSpCnczdqSmc7wcdIzKiFzFA4RHK T7CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726183030; x=1726787830; 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=Nw1dKcVSLCCt5un4d6VomXZplHXDD/4tgdiLE024NX8=; b=Ufj6eNf6SXGGKbd0YqTYAIu2pXjUPTlW4qq5K6wApnpKhFv4h/jXPXlAMB6Pb2LUMW sRG0gOIr8YhkqSm6sSVpOymJlflqmPlRpjHJbhV4zeUs6RYhhgDcWVIJ0rpaoLP42VH/ yhWoa3BKu1REN/3fKbXZUhlZ9ak7c7mQlG7fu8A8yjdfNJlTG5MPUjU5O9MpMdqhM//5 YbheRi8J+1MjZxwCApltWGoNIHWKZ+rlJVTLOytBwodSCBbmInqCpgPDED3DWBDTE8dY YjrPA9jhgEKJ6181OI/sVKXa9j+818Yjels6DgiDFrTXT4v9Jj1ax5U3Zi9+Zp/W0Wq9 qQqA== X-Forwarded-Encrypted: i=1; AJvYcCWJsc9/pRJx5xiG/k/wPbNjMd35CcEwwd8vwMSCFy2HzY61oFJ3ICwjqds1V6V5mI0D2u8exRl0aA==@kvack.org X-Gm-Message-State: AOJu0YzUFqbQtZ1I+sabqak/czKosqLLFc32m3e4qqPRj1xiay+sMDk/ OR6LOixFfDRndzEg2sRuYKA5rgKild+oWPPRJbHQYIkl9cxGn++pklLpqMfdHjg= X-Google-Smtp-Source: AGHT+IHV0R4LSdRMN0UeGhZXF9FypysCDDOC5LIEh5xrA8oVwZ2edglc2TZ3k8QjvVsKUPvcjGWQgQ== X-Received: by 2002:a17:90b:17cb:b0:2d8:e7db:9996 with SMTP id 98e67ed59e1d1-2db9ff93f7amr4718623a91.13.1726183029966; Thu, 12 Sep 2024 16:17:09 -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.17.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 16:17:09 -0700 (PDT) From: Deepak Gupta 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, Rick Edgecombe Subject: [PATCH v4 01/30] mm: Introduce ARCH_HAS_USER_SHADOW_STACK Date: Thu, 12 Sep 2024 16:16:20 -0700 Message-ID: <20240912231650.3740732-2-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 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 826FBC000D X-Stat-Signature: 498rrkri4q3r6yce7acqhc3xkqipqxx7 X-HE-Tag: 1726183031-271540 X-HE-Meta: U2FsdGVkX1/mL8dtedgOYm/eNblN8xxQ8DF4Zh2Xz9irsi2uOlB9WjYy1//2BlQ9asnJqFNq9ejE+3xo3+X5Q62NQWBrCIPhIghDrTJUPhnM2WzozsQCGJhQN9OGu1M7ONIy8YjQDrYJZoewt1w29r41trOUIOD3woFVBCllCcV7l2c39Lf4uFRW/EOVyBFwG2XDGvr+00r2ZkbGB3wY5bX6IHYef+pVlj0Z8x90c0n+ZfA1NLjHmsleiQO1ZNGa53vkWSdPSuEE+DDaqOrJ3OFbFl9ZGZH5GuNlqy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DU2HPoAHQDFU44VzcQ+k08oTN1TWraIt6D0/Z5kC3OGZ5UWB4UiYC52mHiSdIDNgIVOZGUo+5HI22u8/ud+RUNRCj+LoNyRVJj2ZLCfLLVchWFd0OJ6heAgmSxcI1kxkxD1Yuu8zrXKRaOEs5zLIktbBXpTJ239QxF/xfR9MgGbwMzCcV4OPCoNnJPZ4cYzrUJSxw+V4Rsb8gecZuw 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: List-Subscribe: List-Unsubscribe: From: Mark Brown Since multiple architectures have support for shadow stacks and we need to select support for this feature in several places in the generic code provide a generic config option that the architectures can select. Suggested-by: David Hildenbrand Acked-by: David Hildenbrand Signed-off-by: Mark Brown Reviewed-by: Rick Edgecombe Reviewed-by: Deepak Gupta Signed-off-by: Deepak Gupta Reviewed-by: Carlos Bilbao --- arch/x86/Kconfig | 1 + fs/proc/task_mmu.c | 2 +- include/linux/mm.h | 2 +- mm/Kconfig | 6 ++++++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 007bab9f2a0e..320e1f411163 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1957,6 +1957,7 @@ config X86_USER_SHADOW_STACK depends on AS_WRUSS depends on X86_64 select ARCH_USES_HIGH_VMA_FLAGS + select ARCH_HAS_USER_SHADOW_STACK select X86_CET help Shadow stack protection is a hardware feature that detects function diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 5f171ad7b436..0ea49725f524 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -984,7 +984,7 @@ static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma) #ifdef CONFIG_HAVE_ARCH_USERFAULTFD_MINOR [ilog2(VM_UFFD_MINOR)] = "ui", #endif /* CONFIG_HAVE_ARCH_USERFAULTFD_MINOR */ -#ifdef CONFIG_X86_USER_SHADOW_STACK +#ifdef CONFIG_ARCH_HAS_USER_SHADOW_STACK [ilog2(VM_SHADOW_STACK)] = "ss", #endif #ifdef CONFIG_64BIT diff --git a/include/linux/mm.h b/include/linux/mm.h index 147073601716..e39796ea17db 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -346,7 +346,7 @@ extern unsigned int kobjsize(const void *objp); #endif #endif /* CONFIG_ARCH_HAS_PKEYS */ -#ifdef CONFIG_X86_USER_SHADOW_STACK +#ifdef CONFIG_ARCH_HAS_USER_SHADOW_STACK /* * VM_SHADOW_STACK should not be set with VM_SHARED because of lack of * support core mm. diff --git a/mm/Kconfig b/mm/Kconfig index b72e7d040f78..3167be663bca 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -1263,6 +1263,12 @@ config IOMMU_MM_DATA config EXECMEM bool +config ARCH_HAS_USER_SHADOW_STACK + bool + help + The architecture has hardware support for userspace shadow call + stacks (eg, x86 CET, arm64 GCS or RISC-V Zicfiss). + source "mm/damon/Kconfig" endmenu