From: Dave Martin <Dave.Martin@arm.com>
To: Mark Brown <broonie@kernel.org>
Cc: Will Deacon <will@kernel.org>,
Catalin Marinas <catalin.marinas@arm.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] arm64/signal: Don't assume that TIF_SVE means we saved SVE state
Date: Tue, 30 Jan 2024 15:47:26 +0000 [thread overview]
Message-ID: <ZbkaDjyuYVEct+kl@e133380.arm.com> (raw)
In-Reply-To: <7027bd80-1fea-493a-83d7-ffef4e548f08@sirena.org.uk>
On Tue, Jan 30, 2024 at 02:53:45PM +0000, Mark Brown wrote:
> On Tue, Jan 30, 2024 at 02:44:51PM +0000, Dave Martin wrote:
> > On Tue, Jan 30, 2024 at 02:09:34PM +0000, Mark Brown wrote:
>
> > > That said if this is preempted ptrace *could* come in and rewrite the
> > > data or at worst change the vector length (which could leave us with
> > > sve_state deallocated or a different size, possibly while we're in the
> > > middle of accessing it). This could also happen with the existing check
> > > for TIF_SVE so I don't think there's anything new here - AFAICT this has
> > > always been an issue with the vector code, unless I'm missing some
> > > bigger thing which excludes ptrace. I think any change that's needed
> > > there won't overlap with this one, I'm looking.
>
> > I'm pretty sure that terrible things will happen treewide if ptrace can
> > ever access or manipulate the internal state of a _running_ task.
>
> > I think the logic is that any ptrace call that can access or manipulate
> > the state of a task is gated on the task being ptrace-stopped. Once we
>
> ...
>
> > I haven't tracked down the smokeproof gun in the code yet, though.
>
> Yes, exactly - this feels like something that surely must be handled
> already with exclusion along the lines that you're describing but I
> didn't yet spot exactly what the mechanism is.
I think the critical thing is the task_is_traced() check in
kernel/ptrace.c. This seems to be what gates every ptrace call that
requires a traced task (i.e., stopped under ptrace).
So long as nothing during the delivery of a single signal can trigger a
ptrace-stop itself, I think ptrace can't get in the middle of it. This
would imply calling the signal delivery code recursively (not just
raising one signal while delivering another). I'd be pretty confident
that this is meant to be impossible from a design standpoint.
> > From memory, I think that the above forced flush was there to protect
> > against the context switch code rather than ptrace, and guarantees that
> > any change that ctxsw _might_ spontaneously make to the task state has
> > already been done and dusted before we do the actual signal delivery.
> > This may be a red herring so far as ptrace hazards are concerned.
>
> Indeed, it's all about the current task and won't help at for ptrace.
Agreed
Cheers
---Dave
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2024-01-30 15:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-19 12:29 [PATCH] arm64/signal: Don't assume that TIF_SVE means we saved SVE state Mark Brown
2024-01-19 16:31 ` Dave Martin
2024-01-19 17:47 ` Mark Brown
2024-01-23 15:15 ` Dave Martin
2024-01-23 18:55 ` Mark Brown
2024-01-30 11:51 ` Will Deacon
2024-01-30 14:09 ` Mark Brown
2024-01-30 14:44 ` Dave Martin
2024-01-30 14:53 ` Mark Brown
2024-01-30 15:47 ` Dave Martin [this message]
2024-01-30 15:42 ` Mark Brown
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=ZbkaDjyuYVEct+kl@e133380.arm.com \
--to=dave.martin@arm.com \
--cc=broonie@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=will@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).