From: Catalin Marinas <catalin.marinas@arm.com>
To: Will Deacon <will@kernel.org>
Cc: Mark Brown <broonie@kernel.org>,
Shuah Khan <skhan@linuxfoundation.org>,
Shuah Khan <shuah@kernel.org>,
Szabolcs Nagy <szabolcs.nagy@arm.com>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 2/4] arm64/signal: Include TPIDR2 in the signal context
Date: Fri, 18 Nov 2022 19:10:16 +0000 [thread overview]
Message-ID: <Y3fYmC3XRWkKtyV5@arm.com> (raw)
In-Reply-To: <20221118135552.GD4046@willie-the-truck>
On Fri, Nov 18, 2022 at 01:55:53PM +0000, Will Deacon wrote:
> On Tue, Nov 15, 2022 at 04:42:14PM +0000, Mark Brown wrote:
> > On Tue, Nov 15, 2022 at 12:22:26PM +0000, Will Deacon wrote:
> > > On Tue, Nov 15, 2022 at 12:08:44PM +0000, Mark Brown wrote:
> > > > On Mon, Nov 14, 2022 at 04:10:06PM +0000, Will Deacon wrote:
> > > > > On Mon, Oct 31, 2022 at 08:17:34PM +0000, Mark Brown wrote:
> >
> > > > > > + if (user->tpidr2)
> > > > > > + goto invalid;
> >
> > > > > > + if (size != sizeof(*user->tpidr2))
> >
> > > > > Why are you requiring an exact match here? Won't that hinder any future
> > > > > extension of the structure?
> >
> > > > It will but since the structure is explicitly for a single sysreg
> > > > that's intentional - the thinking was to just continue to model
> > > > any more sysregs we want to report in the signal context in the
> > > > same format with their own contexts. It felt like it fit better
> > > > into how everything else in the signal context is extended.
> >
> > > I see, but having the usual '<' check wouldn't preclude us from doing
> > > what you suggest above, whilst also giving us some flexibility in case
> > > things turn out differently from how we expected.
> >
> > This actually also how we validate the base fpsimd_context -
> > while there is a < check in the switch statement in
> > parse_user_sigframe() but we also have an exact size check
> > near the top of restore_fpsimd_context() which gets called from
> > there, meaning that the check in parse_user_sigframe() is a bit
> > redundant. We do however allow the varibly sized frames to have
> > an oversized allocation, though those have internal sizing
> > information whereas fpsimd_context doesn't. My take was that we
> > were erroring out here because if userspace thinks it's supplying
> > some state that we're ignoring and not restoring then things
> > might go badly. I'm not super wedded to this approach but it is
> > consistent with the fpsimd_context handling and I can see some
> > justificaton for it being done the way it is.
>
> Hmm, good point about fpsimd, it looks at magic/size twice which is
> definitely wrong (userspace could even change those values in between!).
>
> So I'd vote for removing the checks from restore_fpsimd_context() which
> raises the same question we were discussing initially: should the check
> in parse_user_sigframe() require an exact size match or instead truncate
> the structure on the stack by only copying a prefix into the kernel?
>
> I'm actually warming more towards an exact check now that we've spoken
> about it a bit... What do you think?
I'd go for an exact match as well. I don't think we can expand these
structures in the future safely without an additional magic number.
I tend to agree with Mark here that parse_user_sigframe() should only
check the magic numbers and set the corresponding user_ctxs members. We
leave the exact size check to the restore_fpsimd_context() etc. (can
skip the magic check here). Well, not a strong view either way but we
should definitely remove the duplicate checks.
--
Catalin
_______________________________________________
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:[~2022-11-18 19:22 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-31 20:17 [PATCH v2 0/4] arm64/signal: Support TPIDR2 Mark Brown
2022-10-31 20:17 ` [PATCH v2 1/4] arm64/sme: Document ABI for TPIDR2 signal information Mark Brown
2022-10-31 20:17 ` [PATCH v2 2/4] arm64/signal: Include TPIDR2 in the signal context Mark Brown
2022-11-14 16:10 ` Will Deacon
2022-11-15 12:08 ` Mark Brown
2022-11-15 12:22 ` Will Deacon
2022-11-15 16:42 ` Mark Brown
2022-11-18 13:55 ` Will Deacon
2022-11-18 15:10 ` Mark Brown
2022-11-18 19:10 ` Catalin Marinas [this message]
2022-11-23 16:53 ` Mark Brown
2022-11-15 17:13 ` Mark Brown
2022-11-18 13:53 ` Will Deacon
2022-11-18 14:04 ` Mark Brown
2022-10-31 20:17 ` [PATCH v2 3/4] kselftest/arm64: Add TPIDR2 to the set of known signal context records Mark Brown
2022-10-31 20:17 ` [PATCH v2 4/4] kselftest/arm64: Add test case for TPIDR2 signal frame records 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=Y3fYmC3XRWkKtyV5@arm.com \
--to=catalin.marinas@arm.com \
--cc=broonie@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=shuah@kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=szabolcs.nagy@arm.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.