From: Dave Hansen <dave.hansen@intel.com>
To: Andrei Vagin <avagin@google.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
LKML <linux-kernel@vger.kernel.org>
Cc: x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH] x86/fpu: verify xstate buffer size according with requested features
Date: Wed, 17 Jan 2024 11:34:41 -0800 [thread overview]
Message-ID: <30cd0be4-705f-4d63-bdad-fc57301e7eda@intel.com> (raw)
In-Reply-To: <20240116234901.3238852-1-avagin@google.com>
... 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?
next parent reply other threads:[~2024-01-17 19:34 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20240116234901.3238852-1-avagin@google.com>
2024-01-17 19:34 ` Dave Hansen [this message]
2024-01-17 22:30 ` Andrei Vagin
2024-01-17 23:52 ` Dave Hansen
2024-01-18 7:59 ` Andrei Vagin
2024-01-18 18:27 ` Dave Hansen
2024-01-18 19:54 ` Thomas Gleixner
2024-01-18 22:02 ` Dave Hansen
2024-01-18 22:11 ` Thomas Gleixner
2024-01-22 3:58 ` Andrei Vagin
2024-01-22 13:26 ` Thomas Gleixner
2024-01-18 19:07 ` Thomas Gleixner
2024-01-22 6:43 ` Andrei Vagin
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=30cd0be4-705f-4d63-bdad-fc57301e7eda@intel.com \
--to=dave.hansen@intel.com \
--cc=avagin@google.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@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
all inboxes | Powered by JetHome®