[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2e1c24e343fb920e1f8616e083bba625717c384d.camel@intel.com>
Date: Tue, 18 Jul 2023 17:51:54 +0000
From: "Edgecombe, Rick P" <rick.p.edgecombe@...el.com>
To: "corbet@....net" <corbet@....net>,
"ardb@...nel.org" <ardb@...nel.org>,
"maz@...nel.org" <maz@...nel.org>,
"shuah@...nel.org" <shuah@...nel.org>,
"Szabolcs.Nagy@....com" <Szabolcs.Nagy@....com>,
"keescook@...omium.org" <keescook@...omium.org>,
"james.morse@....com" <james.morse@....com>,
"debug@...osinc.com" <debug@...osinc.com>,
"akpm@...ux-foundation.org" <akpm@...ux-foundation.org>,
"catalin.marinas@....com" <catalin.marinas@....com>,
"oleg@...hat.com" <oleg@...hat.com>,
"arnd@...db.de" <arnd@...db.de>,
"ebiederm@...ssion.com" <ebiederm@...ssion.com>,
"will@...nel.org" <will@...nel.org>,
"suzuki.poulose@....com" <suzuki.poulose@....com>,
"oliver.upton@...ux.dev" <oliver.upton@...ux.dev>,
"broonie@...nel.org" <broonie@...nel.org>
CC: "hjl.tools@...il.com" <hjl.tools@...il.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-riscv@...ts.infradead.org" <linux-riscv@...ts.infradead.org>,
"linux-kselftest@...r.kernel.org" <linux-kselftest@...r.kernel.org>,
"linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>,
"linux-mm@...ck.org" <linux-mm@...ck.org>,
"paul.walmsley@...ive.com" <paul.walmsley@...ive.com>,
"aou@...s.berkeley.edu" <aou@...s.berkeley.edu>,
"palmer@...belt.com" <palmer@...belt.com>,
"linux-doc@...r.kernel.org" <linux-doc@...r.kernel.org>,
"kvmarm@...ts.linux.dev" <kvmarm@...ts.linux.dev>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>,
"linux-arch@...r.kernel.org" <linux-arch@...r.kernel.org>
Subject: Re: [PATCH 21/35] arm64/gcs: Implement shadow stack prctl() interface
On Sun, 2023-07-16 at 22:51 +0100, Mark Brown wrote:
> +int arch_set_shadow_stack_status(struct task_struct *task, unsigned
> long arg)
> +{
> + unsigned long gcs, size;
> +
> + if (!system_supports_gcs())
> + return -EINVAL;
> +
> + if (is_compat_thread(task_thread_info(task)))
> + return -EINVAL;
> +
> + /* Reject unknown flags */
> + if (arg & ~PR_SHADOW_STACK_SUPPORTED_STATUS_MASK)
> + return -EINVAL;
> +
> + /* If the task has been locked block any attempted changes */
> + if (task->thread.gcs_el0_mode & PR_SHADOW_STACK_LOCK)
> + return -EBUSY;
> +
> + /* Drop flags other than lock if disabling */
> + if (!(arg & PR_SHADOW_STACK_ENABLE))
> + arg &= ~PR_SHADOW_STACK_LOCK;
> +
> + /* If we are enabling GCS then make sure we have a stack */
> + if (arg & PR_SHADOW_STACK_ENABLE) {
> + if (!task_gcs_el0_enabled(task)) {
> + /* Do not allow GCS to be reenabled */
> + if (task->thread.gcs_base)
> + return -EINVAL;
> +
> + size = gcs_size(0);
> + gcs = alloc_gcs(task->thread.gcspr_el0, size,
> + 0, 0);
> + if (!gcs)
> + return -ENOMEM;
> +
> + task->thread.gcspr_el0 = gcs + size -
> sizeof(u64);
> + task->thread.gcs_base = gcs;
> + task->thread.gcs_size = size;
> + if (task == current)
> + write_sysreg_s(task-
> >thread.gcspr_el0,
> + SYS_GCSPR_EL0);
> +
> + }
> + }
> +
> + task->thread.gcs_el0_mode = arg;
> + if (task == current)
> + gcs_set_el0_mode(task);
> +
Ah! So does this task == current part mean this can be called from
another task via ptrace?
If so, then is the alloc_gcs() part on the wrong mm?
Powered by blists - more mailing lists