From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: "Demi Marie Obenour" <demi@invisiblethingslab.com>,
"Roger Pau Monné" <roger.pau@citrix.com>,
Xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH] xen/ucode: Fix buffer under-run when parsing AMD containers
Date: Fri, 13 Sep 2024 13:56:59 +0100 [thread overview]
Message-ID: <7b9e7d1a-41be-4564-b115-59d482a7a916@citrix.com> (raw)
In-Reply-To: <db2d6779-2dbb-4e0b-94f5-c6843aa09b54@suse.com>
On 13/09/2024 1:45 pm, Jan Beulich wrote:
> On 13.09.2024 13:09, Andrew Cooper wrote:
>> From: Demi Marie Obenour <demi@invisiblethingslab.com>
>>
>> The AMD container format has no formal spec. It is, at best, precision
>> guesswork based on AMD's prior contributions to open source projects. The
>> Equivalence Table has both an explicit length, and an expectation of having a
>> NULL entry at the end.
>>
>> Xen was sanity checking the NULL entry, but without confirming that an entry
>> was present, resulting in a read off the front of the buffer. With some
>> manual debugging/annotations this manifests as:
>>
>> (XEN) *** Buf ffff83204c00b19c, eq ffff83204c00b194
>> (XEN) *** eq: 0c 00 00 00 44 4d 41 00 00 00 00 00 00 00 00 00 aa aa aa aa
>> ^-Actual buffer-------------------^
>> (XEN) *** installed_cpu: 000c
>> (XEN) microcode: Bad equivalent cpu table
>> (XEN) Parsing microcode blob error -22
>>
>> When loaded by hypercall, the 4 bytes interpreted as installed_cpu happen to
>> be the containing struct ucode_buf's len field, and luckily will be nonzero.
>>
>> When loaded at boot, it's possible for the access to #PF if the module happens
>> to have been placed on a 2M boundary by the bootloader. Under Linux, it will
>> commonly be the end of the CPIO header.
>>
>> Drop the probe of the NULL entry; Nothing else cares. A container without one
>> is well formed, insofar that we can still parse it correctly. With this
>> dropped, the same container results in:
>>
>> (XEN) microcode: couldn't find any matching ucode in the provided blob!
>>
>> Fixes: 4de936a38aa9 ("x86/ucode/amd: Rework parsing logic in cpu_request_microcode()")
>> Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>
>> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
Thanks.
> I wonder though about scan_equiv_cpu_table(): Should it perhaps complain
> if it doesn't find a null entry? And when it find ones, but that's not
> last?
I'm erring on the "be liberal on what you accept" side of things.
scan_equiv_cpu_table() is a relic of Fam10h systems (the last time that
two different CPU steppings shared a ucode blob), and recent changes to
Linux suggest that AMD have retired the concept.
The only thing we do in scan_equiv_cpu_table() is see if there's a
mapping for the current system, and we loop over all entries, even if
that happens to be 0.
~Andrew
next prev parent reply other threads:[~2024-09-13 12:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-13 11:09 [PATCH] xen/ucode: Fix buffer under-run when parsing AMD containers Andrew Cooper
2024-09-13 12:45 ` Jan Beulich
2024-09-13 12:56 ` Andrew Cooper [this message]
2024-09-13 18:19 ` Demi Marie Obenour
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=7b9e7d1a-41be-4564-b115-59d482a7a916@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=demi@invisiblethingslab.com \
--cc=jbeulich@suse.com \
--cc=roger.pau@citrix.com \
--cc=xen-devel@lists.xenproject.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.