From: Jeremy Linton <jeremy.linton@arm.com>
To: Mark Brown <broonie@kernel.org>
Cc: linux-trace-kernel@vger.kernel.org,
linux-perf-users@vger.kernel.org, mhiramat@kernel.org,
oleg@redhat.com, peterz@infradead.org, acme@kernel.org,
namhyung@kernel.org, mark.rutland@arm.com,
alexander.shishkin@linux.intel.com, jolsa@kernel.org,
irogers@google.com, adrian.hunter@intel.com,
kan.liang@linux.intel.com, thiago.bauermann@linaro.org,
yury.khrustalev@arm.com, kristina.martsenko@arm.com,
liaochang1@huawei.com, catalin.marinas@arm.com, will@kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/7] arm64: uaccess: Add additional userspace GCS accessors
Date: Fri, 21 Mar 2025 18:43:23 -0500 [thread overview]
Message-ID: <e8ada81d-0e10-412b-8792-035bc63113a6@arm.com> (raw)
In-Reply-To: <50a0920d-3e3d-4e96-b68a-a7a0d78c3695@sirena.org.uk>
Hi,
On 3/19/25 8:24 AM, Mark Brown wrote:
> On Tue, Mar 18, 2025 at 03:48:37PM -0500, Jeremy Linton wrote:
>
>> +static inline u64 load_user_gcs(unsigned long __user *addr, int *err)
>> +{
>> + unsigned long ret;
>> + u64 load;
>> +
>> + if (!access_ok((char __user *)addr, sizeof(load))) {
>> + *err = -EFAULT;
>> + return 0;
>> + }
>> +
>> + gcsb_dsync();
>> + ret = copy_from_user(&load, addr, sizeof(load));
>> + if (ret != 0)
>> + *err = ret;
>> + return load;
>> +}
>
> A GCS load done by the hardware will verify that we are loading from GCS
> memory (the accesses are marked as AccessType_GCS in the pseudocode
> which is then validated in for example S1CheckPermissions()). Sadly
> there's no equivalent of GCSSTR so we'd need to do the permission check
> ourselves to match this behaviour.
Right, except that if I grab the VMA as a placeholder for the page,
check to see if its a VM_SHADOW_STACK under any of
map_read_lock()/lock_vma_under_rcu()/etc and then perform the access,
the resulting possible fault will have problems with vma locking.
Otherwise there ends up being a few different races that at the moment
I've not yet figured out how to fix without making a big mess. For
example, we can reduce that possible window, by reading the
value/locking and checking shadow stack state/dropping the
lock/rereading the value, or some other construct but it seems pointless
because the suggested problem is that we might be creating a way to
bypass some of the shadow stack security. In which case, leaving a
little race is likely the same as leaving it wide open.
Otherwise, maybe we can ignore the problem, or just refuse to allow
probes on 'RET' instructions which seems to be the main problematic
case. Although, given we don't really know if GCS is enabled until the
probe is hit, SIGSEG'ing the target process is a big hammer.
Ignoring it might be a valid option. I guess it could to be one of those
"if the user puts a uprobe on a RET some of the shadow stack security is
reduced" footguns. If an attacker can also manipulate the address space
in a way to exploit it then its probably game over anyway. Ideally, the
kernel would warn on this, but per the conversation around patch 6/7
that seems to be off the table.
next prev parent reply other threads:[~2025-03-21 23:43 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-18 20:48 [PATCH 0/7] arm64: Enable UPROBES with GCS Jeremy Linton
2025-03-18 20:48 ` [PATCH 1/7] arm64/gcs: task_gcs_el0_enable() should use passed task Jeremy Linton
2025-03-19 13:12 ` Mark Brown
2025-03-19 14:26 ` Mark Rutland
2025-03-19 15:03 ` Mark Brown
2025-03-18 20:48 ` [PATCH 2/7] arm64: probes: Break ret out from bl/blr Jeremy Linton
2025-03-18 20:48 ` [PATCH 3/7] arm64: uaccess: Add additional userspace GCS accessors Jeremy Linton
2025-03-19 13:24 ` Mark Brown
2025-03-21 23:43 ` Jeremy Linton [this message]
2025-03-25 18:23 ` Mark Brown
2025-03-18 20:48 ` [PATCH 4/7] arm64: probes: Add GCS support to bl/blr/ret Jeremy Linton
2025-03-18 20:48 ` [PATCH 5/7] arm64: uprobes: Add GCS support to uretprobes Jeremy Linton
2025-03-18 20:48 ` [PATCH 6/7] uprobes: Allow the use of uprobe_warn() in arch code Jeremy Linton
2025-03-19 13:32 ` Mark Brown
2025-03-19 14:34 ` Mark Rutland
2025-03-19 14:51 ` Oleg Nesterov
2025-03-19 16:40 ` Jeremy Linton
2025-03-18 20:48 ` [PATCH 7/7] arm64: Kconfig: Remove GCS restrictions on UPROBES Jeremy Linton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e8ada81d-0e10-412b-8792-035bc63113a6@arm.com \
--to=jeremy.linton@arm.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=broonie@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=kristina.martsenko@arm.com \
--cc=liaochang1@huawei.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mhiramat@kernel.org \
--cc=namhyung@kernel.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=thiago.bauermann@linaro.org \
--cc=will@kernel.org \
--cc=yury.khrustalev@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox