Skip to content

Commit 86b4456

Browse files
author
Borislav Petkov
committed
x86, microcode, AMD: Correct buf references
Both the equivalence table and the microcode patch types are u32. Access them properly through the buf-ptr. Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
1 parent 2c53b43 commit 86b4456

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎arch/x86/kernel/microcode_amd.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ static int apply_microcode_amd(int cpu)
157157
static unsigned int verify_ucode_size(int cpu, const u8 *buf, unsigned int size)
158158
{
159159
struct cpuinfo_x86 *c = &cpu_data(cpu);
160-
unsigned int max_size, actual_size;
160+
u32 max_size, actual_size;
161161

162162
#define F1XH_MPB_MAX_SIZE 2048
163163
#define F14H_MPB_MAX_SIZE 1824
@@ -175,7 +175,7 @@ static unsigned int verify_ucode_size(int cpu, const u8 *buf, unsigned int size)
175175
break;
176176
}
177177

178-
actual_size = buf[4] + (buf[5] << 8);
178+
actual_size = *(u32 *)(buf + 4);
179179

180180
if (actual_size > size || actual_size > max_size) {
181181
pr_err("section size mismatch\n");
@@ -191,7 +191,7 @@ get_next_ucode(int cpu, const u8 *buf, unsigned int size, unsigned int *mc_size)
191191
struct microcode_header_amd *mc = NULL;
192192
unsigned int actual_size = 0;
193193

194-
if (buf[0] != UCODE_UCODE_TYPE) {
194+
if (*(u32 *)buf != UCODE_UCODE_TYPE) {
195195
pr_err("invalid type field in container file section header\n");
196196
goto out;
197197
}

0 commit comments

Comments
 (0)