diff options
author | Borislav Petkov <borislav.petkov@amd.com> | 2011-06-15 09:34:57 -0400 |
---|---|---|
committer | Borislav Petkov <borislav.petkov@amd.com> | 2011-06-16 11:23:54 -0400 |
commit | 40b7f3dfcc5ab211a0b8d916751bb22ac2290806 (patch) | |
tree | 352f5d8d18e52149d3048981aaba11e0263251cf /arch | |
parent | 86b445676d13f520ef9ab7aebe933aa6684ce84c (diff) |
x86, microcode, AMD: Fix section header size check
The ucode size check has to take the section header size into account
too when sanity checking the section length. Shorten and clarify define
names, while at it.
Caught-by: Ben Hutchings <ben@decadent.org.uk>
Link: http://lkml.kernel.org/r/1302752223.5282.674.camel@localhost
Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/kernel/microcode_amd.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/arch/x86/kernel/microcode_amd.c b/arch/x86/kernel/microcode_amd.c index d30d67cd33ad..591be0ee1934 100644 --- a/arch/x86/kernel/microcode_amd.c +++ b/arch/x86/kernel/microcode_amd.c | |||
@@ -66,8 +66,8 @@ struct microcode_amd { | |||
66 | unsigned int mpb[0]; | 66 | unsigned int mpb[0]; |
67 | }; | 67 | }; |
68 | 68 | ||
69 | #define UCODE_CONTAINER_SECTION_HDR 8 | 69 | #define SECTION_HDR_SIZE 8 |
70 | #define UCODE_CONTAINER_HEADER_SIZE 12 | 70 | #define CONTAINER_HDR_SZ 12 |
71 | 71 | ||
72 | static struct equiv_cpu_entry *equiv_cpu_table; | 72 | static struct equiv_cpu_entry *equiv_cpu_table; |
73 | 73 | ||
@@ -177,7 +177,7 @@ static unsigned int verify_ucode_size(int cpu, const u8 *buf, unsigned int size) | |||
177 | 177 | ||
178 | actual_size = *(u32 *)(buf + 4); | 178 | actual_size = *(u32 *)(buf + 4); |
179 | 179 | ||
180 | if (actual_size > size || actual_size > max_size) { | 180 | if (actual_size + SECTION_HDR_SIZE > size || actual_size > max_size) { |
181 | pr_err("section size mismatch\n"); | 181 | pr_err("section size mismatch\n"); |
182 | return 0; | 182 | return 0; |
183 | } | 183 | } |
@@ -204,8 +204,8 @@ get_next_ucode(int cpu, const u8 *buf, unsigned int size, unsigned int *mc_size) | |||
204 | if (!mc) | 204 | if (!mc) |
205 | goto out; | 205 | goto out; |
206 | 206 | ||
207 | get_ucode_data(mc, buf + UCODE_CONTAINER_SECTION_HDR, actual_size); | 207 | get_ucode_data(mc, buf + SECTION_HDR_SIZE, actual_size); |
208 | *mc_size = actual_size + UCODE_CONTAINER_SECTION_HDR; | 208 | *mc_size = actual_size + SECTION_HDR_SIZE; |
209 | 209 | ||
210 | out: | 210 | out: |
211 | return mc; | 211 | return mc; |
@@ -229,9 +229,10 @@ static int install_equiv_cpu_table(const u8 *buf) | |||
229 | return -ENOMEM; | 229 | return -ENOMEM; |
230 | } | 230 | } |
231 | 231 | ||
232 | get_ucode_data(equiv_cpu_table, buf + UCODE_CONTAINER_HEADER_SIZE, size); | 232 | get_ucode_data(equiv_cpu_table, buf + CONTAINER_HDR_SZ, size); |
233 | 233 | ||
234 | return size + UCODE_CONTAINER_HEADER_SIZE; /* add header length */ | 234 | /* add header length */ |
235 | return size + CONTAINER_HDR_SZ; | ||
235 | } | 236 | } |
236 | 237 | ||
237 | static void free_equiv_cpu_table(void) | 238 | static void free_equiv_cpu_table(void) |