Re: [PATCH] x86/fpu: verify xstate buffer size according with requested features

From: Andrei Vagin
Date: Mon Jan 22 2024 - 01:44:19 EST


On Thu, Jan 18, 2024 at 11:07 AM Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:
>
> On Wed, Jan 17 2024 at 23:59, Andrei Vagin wrote:
> > On Wed, Jan 17, 2024 at 3:52 PM Dave Hansen <dave.hansen@xxxxxxxxx> wrote:
> >> I'm not really following the logic there. What's the downside of taking
> >> the fault?
> >
> > Let's consider a scenario where someone messed up with an fpu state on a
> > signal frame.
>
> Then he can rightfully keep the pieces...
>
> > With my approach, a mistake can be promptly detected.
>
> How so? Everything which ends up at the 'setfx:' label will just
> silently fall back to FX only and init all other components.

and it will trigger the x86_fpu_xstate_check_failed tracing event.

Usually, when I want to check that our code generates sigframe fpu states
properly, I enable this event type, run tests and check that no event
has been triggered.

Plus, we have tests that check fpu register values, so they will fail if
registers are changed in unexpected values.


Thanks,
Andrei