[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <30cd0be4-705f-4d63-bdad-fc57301e7eda@intel.com>
Date: Wed, 17 Jan 2024 11:34:41 -0800
From: Dave Hansen <dave.hansen@...el.com>
To: Andrei Vagin <avagin@...gle.com>, Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
LKML <linux-kernel@...r.kernel.org>
Cc: x86@...nel.org, "H. Peter Anvin" <hpa@...or.com>
Subject: Re: [PATCH] x86/fpu: verify xstate buffer size according with
requested features
.. adding LKML. More context here:
https://lore.kernel.org/all/20240116234901.3238852-1-avagin@google.com/
On 1/16/24 15:49, Andrei Vagin wrote:
> + /* xstate_size has to fit all requested components. */
> + if (fx_sw->xstate_size != fpstate->user_size) {
> + int min_xstate_size =
> + xstate_calculate_size(fx_sw->xfeatures, false);
> +
> + if (min_xstate_size < 0 ||
> + fx_sw->xstate_size < min_xstate_size ||
> + fx_sw->xstate_size > fpstate->user_size)
> + goto setfx;
> + }
The bug here is that the buffer from userspace is garbage and the (XSAVE
XSTATE_BV) metadata doesn't match the size of the buffer. Right?
This proposed fix just checks another piece of user-supplied metadata
instead: fx_sw->xstate_size.
Can't userspace just provide more bad data there and end up with the
same problem?
Seems like the real problem here is that the fault_in_readable() doesn't
match the XRSTOR. It's going to continue to be a problem as long as we
don't know what memory XRSTOR tried to access. We can try all day long
to precalculate what XRSTOR _will_ do, but that seems a bit silly
because the CPU knows where the fault happened. It told us in CR2 and
all we have to do is plumb that back to fault_in_readable().
It would take a little XSTATE_OP() munging to pass something back other
than 'err', but that doesn't seem insurmountable.
Anybody have better ideas?
Powered by blists - more mailing lists