From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Kevin Tian <kevin.tian@intel.com>,
Jun Nakajima <jun.nakajima@intel.com>,
Jan Beulich <JBeulich@suse.com>
Subject: [PATCH 3/3] x86/microcode: Avoid undefined behaviour from signed integer overflow
Date: Fri, 5 Aug 2016 14:50:13 +0100 [thread overview]
Message-ID: <1470405013-18856-3-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1470405013-18856-1-git-send-email-andrew.cooper3@citrix.com>
The checksum should be calculated using unsigned 32bit integers, as it is
intended to overflow and end at 0.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Kevin Tian <kevin.tian@intel.com>
CC: Jun Nakajima <jun.nakajima@intel.com>
---
xen/arch/x86/microcode_intel.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/xen/arch/x86/microcode_intel.c b/xen/arch/x86/microcode_intel.c
index 6949c25..5b411b4 100644
--- a/xen/arch/x86/microcode_intel.c
+++ b/xen/arch/x86/microcode_intel.c
@@ -143,7 +143,8 @@ static int microcode_sanity_check(void *mc)
struct extended_sigtable *ext_header = NULL;
struct extended_signature *ext_sig;
unsigned long total_size, data_size, ext_table_size;
- int sum, orig_sum, ext_sigcount = 0, i;
+ uint32_t sum, orig_sum;
+ int ext_sigcount = 0, i;
total_size = get_totalsize(mc_header);
data_size = get_datasize(mc_header);
@@ -201,7 +202,7 @@ static int microcode_sanity_check(void *mc)
orig_sum = 0;
i = (MC_HEADER_SIZE + data_size) / DWSIZE;
while ( i-- )
- orig_sum += ((int *)mc)[i];
+ orig_sum += ((uint32_t *)mc)[i];
if ( orig_sum )
{
printk(KERN_ERR "microcode: aborting, bad checksum\n");
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-08-05 13:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-05 13:50 [PATCH 1/3] xen/common: Avoid undefined behaviour by shifting into a sign bit Andrew Cooper
2016-08-05 13:50 ` [PATCH 2/3] xen/x86: " Andrew Cooper
2016-08-05 14:06 ` Jan Beulich
2016-08-05 13:50 ` Andrew Cooper [this message]
2016-08-05 14:09 ` [PATCH 3/3] x86/microcode: Avoid undefined behaviour from signed integer overflow Jan Beulich
2016-08-11 8:42 ` Tian, Kevin
2016-08-05 14:04 ` [PATCH 1/3] xen/common: Avoid undefined behaviour by shifting into a sign bit Jan Beulich
2016-08-05 14:07 ` George Dunlap
2016-08-09 12:48 ` [PATCH] " Andrew Cooper
2016-08-09 12:48 ` [PATCH] xen/x86: " Andrew Cooper
2016-08-09 12:48 ` [PATCH] x86/microcode: Avoid undefined behaviour from signed integer overflow Andrew Cooper
2016-08-09 14:00 ` [PATCH] xen/common: Avoid undefined behaviour by shifting into a sign bit Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1470405013-18856-3-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=jun.nakajima@intel.com \
--cc=kevin.tian@intel.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).