[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <b4854b17-e3ba-54d6-488d-0e0bfffe4c71@maciej.szmigiero.name>
Date: Fri, 16 Mar 2018 00:07:42 +0100
From: "Maciej S. Szmigiero" <mail@...iej.szmigiero.name>
To: Borislav Petkov <bp@...en8.de>
Cc: Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
"H. Peter Anvin" <hpa@...or.com>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v4 01/10] x86/microcode/AMD: Subtract SECTION_HDR_SIZE from
file leftover length
verify_patch_size() function verifies whether the microcode container file
remaining size is large enough to contain a patch of the indicated size.
However, the section header length is not included in this indicated size
but it is present in the leftover file length so it should be subtracted
from the leftover file length before passing this value to
verify_patch_size().
Signed-off-by: Maciej S. Szmigiero <mail@...iej.szmigiero.name>
---
arch/x86/kernel/cpu/microcode/amd.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
index a998e1a7d46f..6a93be0f771c 100644
--- a/arch/x86/kernel/cpu/microcode/amd.c
+++ b/arch/x86/kernel/cpu/microcode/amd.c
@@ -613,7 +613,16 @@ static int verify_and_add_patch(u8 family, u8 *fw, unsigned int leftover)
return crnt_size;
}
- ret = verify_patch_size(family, patch_size, leftover);
+ /*
+ * verify_patch_size() checks whether the passed remaining file size
+ * is large enough to contain a patch of the indicated size (and also
+ * whether this size does not exceed the family maximum).
+ *
+ * The section header length is not included in this indicated size
+ * but it is present in the leftover file length so we need to subtract
+ * it before passing this value to that function.
+ */
+ ret = verify_patch_size(family, patch_size, leftover - SECTION_HDR_SIZE);
if (!ret) {
pr_err("Patch-ID 0x%08x: size mismatch.\n", mc_hdr->patch_id);
return crnt_size;
Powered by blists - more mailing lists