mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [GIT PULL] x86, microcode, AMD: 2 small fixlets
@ 2011-06-16 15:32 Borislav Petkov
  2011-06-16 15:32 ` [PATCH 1/2] x86, microcode, AMD: Correct buf references Borislav Petkov
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Borislav Petkov @ 2011-06-16 15:32 UTC (permalink / raw)
  To: Ingo Molnar, H. Peter Anvin, Thomas Gleixner
  Cc: Ben Hutchings, LKML, Borislav Petkov

From: Borislav Petkov <borislav.petkov@amd.com>

Hi Ingo,

please pull the following fixes from the below branch.

They are only minor correctness fixes and can be queued for 3.1.

Thanks.

The following changes since commit 2c53b436a30867eb6b47dd7bab23ba638d1fb0d2:

  Linux 3.0-rc3 (2011-06-13 15:29:59 -0700)

are available in the git repository at:
  git://git.kernel.org/pub/scm/linux/kernel/git/bp/bp.git ucode-fixes

Borislav Petkov (2):
      x86, microcode, AMD: Correct buf references
      x86, microcode, AMD: Fix section header size check

 arch/x86/kernel/microcode_amd.c |   21 +++++++++++----------
 1 files changed, 11 insertions(+), 10 deletions(-)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] x86, microcode, AMD: Correct buf references
  2011-06-16 15:32 [GIT PULL] x86, microcode, AMD: 2 small fixlets Borislav Petkov
@ 2011-06-16 15:32 ` Borislav Petkov
  2011-06-16 15:32 ` [PATCH 2/2] x86, microcode, AMD: Fix section header size check Borislav Petkov
  2011-06-17 12:08 ` [GIT PULL] x86, microcode, AMD: 2 small fixlets Ingo Molnar
  2 siblings, 0 replies; 4+ messages in thread
From: Borislav Petkov @ 2011-06-16 15:32 UTC (permalink / raw)
  To: Ingo Molnar, H. Peter Anvin, Thomas Gleixner
  Cc: Ben Hutchings, LKML, Borislav Petkov

From: Borislav Petkov <borislav.petkov@amd.com>

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>
---
 arch/x86/kernel/microcode_amd.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/microcode_amd.c b/arch/x86/kernel/microcode_amd.c
index c561038..d30d67c 100644
--- a/arch/x86/kernel/microcode_amd.c
+++ b/arch/x86/kernel/microcode_amd.c
@@ -157,7 +157,7 @@ static int apply_microcode_amd(int cpu)
 static unsigned int verify_ucode_size(int cpu, const u8 *buf, unsigned int size)
 {
 	struct cpuinfo_x86 *c = &cpu_data(cpu);
-	unsigned int max_size, actual_size;
+	u32 max_size, actual_size;
 
 #define F1XH_MPB_MAX_SIZE 2048
 #define F14H_MPB_MAX_SIZE 1824
@@ -175,7 +175,7 @@ static unsigned int verify_ucode_size(int cpu, const u8 *buf, unsigned int size)
 		break;
 	}
 
-	actual_size = buf[4] + (buf[5] << 8);
+	actual_size = *(u32 *)(buf + 4);
 
 	if (actual_size > size || actual_size > max_size) {
 		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)
 	struct microcode_header_amd *mc = NULL;
 	unsigned int actual_size = 0;
 
-	if (buf[0] != UCODE_UCODE_TYPE) {
+	if (*(u32 *)buf != UCODE_UCODE_TYPE) {
 		pr_err("invalid type field in container file section header\n");
 		goto out;
 	}
-- 
1.7.4.rc2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] x86, microcode, AMD: Fix section header size check
  2011-06-16 15:32 [GIT PULL] x86, microcode, AMD: 2 small fixlets Borislav Petkov
  2011-06-16 15:32 ` [PATCH 1/2] x86, microcode, AMD: Correct buf references Borislav Petkov
@ 2011-06-16 15:32 ` Borislav Petkov
  2011-06-17 12:08 ` [GIT PULL] x86, microcode, AMD: 2 small fixlets Ingo Molnar
  2 siblings, 0 replies; 4+ messages in thread
From: Borislav Petkov @ 2011-06-16 15:32 UTC (permalink / raw)
  To: Ingo Molnar, H. Peter Anvin, Thomas Gleixner
  Cc: Ben Hutchings, LKML, Borislav Petkov

From: Borislav Petkov <borislav.petkov@amd.com>

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>
---
 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 d30d67c..591be0e 100644
--- a/arch/x86/kernel/microcode_amd.c
+++ b/arch/x86/kernel/microcode_amd.c
@@ -66,8 +66,8 @@ struct microcode_amd {
 	unsigned int			mpb[0];
 };
 
-#define UCODE_CONTAINER_SECTION_HDR	8
-#define UCODE_CONTAINER_HEADER_SIZE	12
+#define SECTION_HDR_SIZE	8
+#define CONTAINER_HDR_SZ	12
 
 static struct equiv_cpu_entry *equiv_cpu_table;
 
@@ -177,7 +177,7 @@ static unsigned int verify_ucode_size(int cpu, const u8 *buf, unsigned int size)
 
 	actual_size = *(u32 *)(buf + 4);
 
-	if (actual_size > size || actual_size > max_size) {
+	if (actual_size + SECTION_HDR_SIZE > size || actual_size > max_size) {
 		pr_err("section size mismatch\n");
 		return 0;
 	}
@@ -204,8 +204,8 @@ get_next_ucode(int cpu, const u8 *buf, unsigned int size, unsigned int *mc_size)
 	if (!mc)
 		goto out;
 
-	get_ucode_data(mc, buf + UCODE_CONTAINER_SECTION_HDR, actual_size);
-	*mc_size = actual_size + UCODE_CONTAINER_SECTION_HDR;
+	get_ucode_data(mc, buf + SECTION_HDR_SIZE, actual_size);
+	*mc_size = actual_size + SECTION_HDR_SIZE;
 
 out:
 	return mc;
@@ -229,9 +229,10 @@ static int install_equiv_cpu_table(const u8 *buf)
 		return -ENOMEM;
 	}
 
-	get_ucode_data(equiv_cpu_table, buf + UCODE_CONTAINER_HEADER_SIZE, size);
+	get_ucode_data(equiv_cpu_table, buf + CONTAINER_HDR_SZ, size);
 
-	return size + UCODE_CONTAINER_HEADER_SIZE; /* add header length */
+	/* add header length */
+	return size + CONTAINER_HDR_SZ;
 }
 
 static void free_equiv_cpu_table(void)
-- 
1.7.4.rc2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [GIT PULL] x86, microcode, AMD: 2 small fixlets
  2011-06-16 15:32 [GIT PULL] x86, microcode, AMD: 2 small fixlets Borislav Petkov
  2011-06-16 15:32 ` [PATCH 1/2] x86, microcode, AMD: Correct buf references Borislav Petkov
  2011-06-16 15:32 ` [PATCH 2/2] x86, microcode, AMD: Fix section header size check Borislav Petkov
@ 2011-06-17 12:08 ` Ingo Molnar
  2 siblings, 0 replies; 4+ messages in thread
From: Ingo Molnar @ 2011-06-17 12:08 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: H. Peter Anvin, Thomas Gleixner, Ben Hutchings, LKML, Borislav Petkov


* Borislav Petkov <bp@amd64.org> wrote:

> From: Borislav Petkov <borislav.petkov@amd.com>
> 
> Hi Ingo,
> 
> please pull the following fixes from the below branch.
> 
> They are only minor correctness fixes and can be queued for 3.1.
> 
> Thanks.
> 
> The following changes since commit 2c53b436a30867eb6b47dd7bab23ba638d1fb0d2:
> 
>   Linux 3.0-rc3 (2011-06-13 15:29:59 -0700)
> 
> are available in the git repository at:
>   git://git.kernel.org/pub/scm/linux/kernel/git/bp/bp.git ucode-fixes
> 
> Borislav Petkov (2):
>       x86, microcode, AMD: Correct buf references
>       x86, microcode, AMD: Fix section header size check
> 
>  arch/x86/kernel/microcode_amd.c |   21 +++++++++++----------
>  1 files changed, 11 insertions(+), 10 deletions(-)

Pulled, thanks Boris!

	Ingo

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-06-17 12:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-16 15:32 [GIT PULL] x86, microcode, AMD: 2 small fixlets Borislav Petkov
2011-06-16 15:32 ` [PATCH 1/2] x86, microcode, AMD: Correct buf references Borislav Petkov
2011-06-16 15:32 ` [PATCH 2/2] x86, microcode, AMD: Fix section header size check Borislav Petkov
2011-06-17 12:08 ` [GIT PULL] x86, microcode, AMD: 2 small fixlets Ingo Molnar

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®