mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
x86/ucode/amd: Fix potential buffer overrun with equiv table handling
find_equiv_cpu_id() loops until it finds a 0 installed_cpu entry. Well formed
AMD microcode containers have this property.
Extend the checking in install_equiv_cpu_table() to reject tables which don't
have a sentinal at the end.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
master commit: 1f97b6b9f1
master date: 2020-03-27 13:13:26 +0000
This commit is contained in:
1 parent
18d9129f44
commit
c7a1e588d8
1 file changed
+4
-1
@@ -321,6 +321,7 @@ static int install_equiv_cpu_table(
|
||||
size_t *offset)
|
||||
{
|
||||
const struct mpbhdr *mpbuf = data + *offset + 4;
|
||||
const struct equiv_cpu_entry *eq;
|
||||
|
||||
*offset += mpbuf->len + CONT_HDR_SIZE; /* add header length */
|
||||
|
||||
@@ -330,7 +331,9 @@ static int install_equiv_cpu_table(
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if ( mpbuf->len == 0 )
|
||||
if ( mpbuf->len == 0 || mpbuf->len % sizeof(*eq) ||
|
||||
(eq = (const void *)mpbuf->data,
|
||||
eq[(mpbuf->len / sizeof(*eq)) - 1].installed_cpu) )
|
||||
{
|
||||
printk(KERN_ERR "microcode: Wrong microcode equivalent cpu table length\n");
|
||||
return -EINVAL;
|
||||
|
||||