Message ID | 20241001-v5_user_cfi_series-v1-12-3ba65b6e550f@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 DC236CEACE5 for <linux-mm@archiver.kernel.org>; Tue, 1 Oct 2024 16:07:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 94D3A2800A7; Tue, 1 Oct 2024 12:07:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8D358280068; Tue, 1 Oct 2024 12:07:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 776D32800A7; Tue, 1 Oct 2024 12:07:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 57208280068 for <linux-mm@kvack.org>; Tue, 1 Oct 2024 12:07:36 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 0E7AD141661 for <linux-mm@kvack.org>; Tue, 1 Oct 2024 16:07:36 +0000 (UTC) X-FDA: 82625513712.03.30667DA Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by imf04.hostedemail.com (Postfix) with ESMTP id 0FDBF40026 for <linux-mm@kvack.org>; Tue, 1 Oct 2024 16:07:33 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=jy6nCANC; dmarc=none; spf=pass (imf04.hostedemail.com: domain of debug@rivosinc.com designates 209.85.216.54 as permitted sender) smtp.mailfrom=debug@rivosinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727798833; a=rsa-sha256; cv=none; b=ekYnXT/VOKV6QvnCCO9H5Og6a+jY3Fzh8crSfa/0pnmWMkZxlWaqE1NIXtgioIaHHcZDul C+SvVs0k+SOgUCSJTUQElx6WwaLA/XLO1PFION3xGAto5cAHw//nPdr1+eOW0joEfzdOvt MSCndUkpA3QLLXiLAWefyU9InBkSBeE= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=jy6nCANC; dmarc=none; spf=pass (imf04.hostedemail.com: domain of debug@rivosinc.com designates 209.85.216.54 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=1727798833; 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=HvFaRabdOYgj/FaUxHA5lpjBxuSoaWHPSkkVGjDU8NY=; b=wJNqBD8AeQtsSZ9fS+7YddSeTmZMLC/J608R9im/bcXSDU74sSLjQKVIqtL9wmF6o9DMB4 gYtqmcAvhpG4IzHkF4pKgjWjkC437yvf/idqf/nGJUCrfcwKhvN7mqOmu2IdgRyDJBtyaR bxItDatdH+rHCcLQ78boHXz4Whdxmw0= Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-2e07b031da3so4288364a91.3 for <linux-mm@kvack.org>; Tue, 01 Oct 2024 09:07:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1727798853; x=1728403653; 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=HvFaRabdOYgj/FaUxHA5lpjBxuSoaWHPSkkVGjDU8NY=; b=jy6nCANCFIXHI9vjRFjzoPCZzH3KZDFpblA7p9t5zKKp0tAmfeZoHjq832TKQpgJ/F D3Fp7Bup1YDuOe1Br7Efv0hy+FC43JUPQneM+Qihq1dNPenBXRscZUebdNGGtDdL8XFh 3q6xhuxMZKiBG71c8Jd7o2Rqysv8weTmU0pOOKc1jbvmDsaVJ70bjHJmrnIObiyUZufe h7h5hbccstBW5phmpggFs5xFW0rapooYN6vJysQBjn2zH3g5hnFrqmCrkzYbinMcCag3 vLvrBkHFm+h3m0f9YBvTdC/lLVt59KvHjoU60T29geJn2+KLwIQ2MljJGW4XPb26ugAl 8HBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727798853; x=1728403653; 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=HvFaRabdOYgj/FaUxHA5lpjBxuSoaWHPSkkVGjDU8NY=; b=wneZ9YAp9Wu7etG6IhqzqY1M5mNqIcDHRfmcmf4wp7X4V4xNqtR+G+FY6KFByL6vfK YgNUVYxMF/lw1HV9sTvQ9058xsTebrtsuVwyWv0i8rkibijl/VnSFR5v2+mFCpPZkui4 TTdwSCci5RR3pYSt0Q803NjuRwvgVXQoWvSrbxnMfQ6FLB3Ckps9MYB3zj/65BLxcKe9 7ukhtzZQjGg8s8c1+b3N+moJbzio4sf+qA31ej9ToSLbUTdIvB0VqovWllwqhprtPL9P YOnOddWqA9RnR38dxqQn/41uO9h+dvcpYp4F6Zm0q1XowmCV3xZq9dzPs5old/YShSUi yo+w== X-Forwarded-Encrypted: i=1; AJvYcCUEbn2ffD9KlXtDFXH4xm08yoXTn0ce2C8UE4zkKQWFrkyj3tYaOkWjIDuoJ0A+YXJPwWA5syIE5Q==@kvack.org X-Gm-Message-State: AOJu0Yx7/pOxiX+rZOBV+cVu7iBpr1Kq8mzQgonbrc8xanSsSsZSdcU3 3hqHX2TjdpRMYLKd138Vn5K5ElWK2zil/xzxiJ+RPrTfPMfyaT95drwD3iarpaU= X-Google-Smtp-Source: AGHT+IG9catzJvE6iZhMcet9lnrBEGB4mWrgVfEl6Aw7Bwjo8k2vC5A57va5s4Xp67KUnf9ZyIG6qQ== X-Received: by 2002:a17:90a:ba88:b0:2e0:f81c:731f with SMTP id 98e67ed59e1d1-2e18481a282mr222726a91.24.1727798852879; Tue, 01 Oct 2024 09:07:32 -0700 (PDT) Received: from debug.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e06e1d7d47sm13843973a91.28.2024.10.01.09.07.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 09:07:32 -0700 (PDT) From: Deepak Gupta <debug@rivosinc.com> Date: Tue, 01 Oct 2024 09:06:17 -0700 Subject: [PATCH 12/33] riscv mm: manufacture shadow stack pte MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20241001-v5_user_cfi_series-v1-12-3ba65b6e550f@rivosinc.com> References: <20241001-v5_user_cfi_series-v1-0-3ba65b6e550f@rivosinc.com> In-Reply-To: <20241001-v5_user_cfi_series-v1-0-3ba65b6e550f@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-Stat-Signature: 66zzb5ud8x5367r9g5r9kokr8ndwgqzi X-Rspamd-Queue-Id: 0FDBF40026 X-Rspamd-Server: rspam02 X-HE-Tag: 1727798853-98235 X-HE-Meta: U2FsdGVkX19TJMWMH+uB0R4mqEqJ6Gm67ksY9gYk5Xtb0uJXbTkQ+aAisaOe1ed40cgrFMtvypH/80fj9SGWOkOLB7IKya3ajgjVQ4Id8gFMLYcU6TA3HcrOvO6froVMXYARtT1ew5wemmA9N9F7UqYm5BFk40kYQOr+gDILWvUzX6kGa+B54MR12p3JBVMxV+O9cTxev+MfrNDAPe+2OoCUnHoU+j0zfXJ228c7RoPxSQl1lIOtZmYInfE+4zo23WAst7PhCYB8+ElldKE8qappr01Gpwaj8ZXhHdUroYjH+fkrKumnx4bLPMmtyzTT+tUHdEIOwBgxAN1iByA4rqMaWUBkKk9x3wwXb8/D6wMRnjx0vRtmmrh22yPesafeSzP3UcNmlBRnC5T+EQ3vXHa02o6M0wFG6A+wcEgssNK5+OvtJgqzbV6zngN4WktDvfdXP7+lEBPQRA3/4YXtzwvNzg0VsnpiFwPLWQjcayqySMra2xB+C5bmyGIv440SRE/gpHYeQbvDReHmJhM8jdYLSaEetqYV4J9TFSfeQ6qcE+uWJfeF4R1zr3SPn1Ppqt2w7updz70L3V8y6ufui3hb//qzwGkt9BeO+OUhiKP368kBywrgDKOjPadqZOyOUSDGLM1PBqLv4QHnKAYE5t0J9pqWsCWTyA7InkuurxVrYJJ4NOENnqMWKPuWwmQ9Z3ia0e1ANRsz78XHLc0Mjbo5ja5/Y/5DmdZuVNrqtF34rNQCmSvH5dsmiHXp8fzrN4T4PWrdXruKivRypg6uoC//tRIIB2ZSlhRZzUjbKOFO7SLVcGSTtkR9ce4C6ho76RidIU0vcMp3I1souakPiQDlUoaPoUm1EXbxTENa6lOPEwlI41ZKXJTk8EuAsLdl7WbSpSYsZH7g9V1Hpm+sWulAFggbnkEpAKW8A/lANJtd6hSDqrFK+A/GUMehJPIhPBVnjVB+NHqO1KjgVyU bHVv8OIa OxYwvqZrd/DDuXVID+jwtsJLaWlB/gKbWGeudOeAzxYH8F6i3ZyNfMnnjdJEv6GRUALffqrFPDWhtSkhZmcJsxyVqrez6Br7/884zqSASS2TqO5Sgr4XbFxvP6wCSBJDxklx4ohHMR3D0yx5HTrF6t1QXbXNFNoZ/O0jift4c636gitJYcXEcRBSMV6lSKM2r7TDAF8ZddHDgAOiYqVj8oWa8442cMzpcIOI6p3+OLZvOeV23sdyfu26fQgFedFtLQRUHLbJDpZF50PboXSr264juu48va3ZWoafkAW/D2i8jQ+gWcVbIl7o9B3+W8yK+pcrDmM3TBCLFDUAOVgQR1aX2F3tJNhPn/7SvSoRa96Knex0e8yhBSPpMtpRbi66WP4X5NHPHw1djcge9ysmV600MfxvxCDK/l+H7xe8LrkLdnJvRtf98W4MNdm8lo7jmsY73b+YojWKqo94= 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/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index 4948a1f18ae8..2c6edc8d04a3 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -421,6 +421,11 @@ static inline pte_t pte_mkwrite_novma(pte_t pte) return __pte(pte_val(pte) | _PAGE_WRITE); } +static inline pte_t pte_mkwrite_shstk(pte_t pte) +{ + return __pte((pte_val(pte) & ~(_PAGE_LEAF)) | _PAGE_WRITE); +} + /* static inline pte_t pte_mkexec(pte_t pte) */ static inline pte_t pte_mkdirty(pte_t pte) @@ -738,6 +743,11 @@ static inline pmd_t pmd_mkwrite_novma(pmd_t pmd) return pte_pmd(pte_mkwrite_novma(pmd_pte(pmd))); } +static inline pmd_t pmd_mkwrite_shstk(pmd_t pte) +{ + return __pmd((pmd_val(pte) & ~(_PAGE_LEAF)) | _PAGE_WRITE); +} + static inline pmd_t pmd_wrprotect(pmd_t pmd) { return pte_pmd(pte_wrprotect(pmd_pte(pmd)));