public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Chris Bainbridge <chris.bainbridge@gmail.com>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86/microcode: Change checksum to u32
Date: Sat, 27 Feb 2016 18:51:18 +0100	[thread overview]
Message-ID: <20160227175118.GC5261@pd.tnic> (raw)
In-Reply-To: <1456570907-5344-1-git-send-email-chris.bainbridge@gmail.com>

On Sat, Feb 27, 2016 at 11:01:47AM +0000, Chris Bainbridge wrote:
> Checksum should be unsigned 32-bit otherwise the calculation overflows
> resulting in undefined behaviour:
> 
> [    0.000000] ================================================================================
> [    0.000000] UBSAN: Undefined behaviour in arch/x86/kernel/cpu/microcode/intel_lib.c:105:12
> [    0.000000] signed integer overflow:
> [    0.000000] -1500151068 + -2125470173 cannot be represented in type 'int'

So I've been staring at this error message for a while now and I'm
having hard time understanding what it is telling me. Let's look at all
three ints:

* sum is computed here:

                sum = orig_sum
                        - (mc_header->sig + mc_header->pf + mc_header->cksum)
                        + (ext_sig->sig + ext_sig->pf + ext_sig->cksum);

and checks mc_header against each extended signature. If it overflows, we abort:

                if (sum) {
                        if (print_err)
                                pr_err("aborting, bad checksum\n");


* orig_sum in the above sum can only be 0:

        if (orig_sum) {
                if (print_err)
                        pr_err("aborting, bad checksum\n");
                return -EINVAL;

and it adds a bunch of integers which can overflow, sure, but if it
overflows, we exit early.

* and

	ext_sigcount = ext_header->count;

so it is some count of extended signatures.

So what is ubsan complaining about?

/me is confused.

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.

  reply	other threads:[~2016-02-27 17:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-27 11:01 [PATCH] x86/microcode: Change checksum to u32 Chris Bainbridge
2016-02-27 17:51 ` Borislav Petkov [this message]
2016-02-27 18:23   ` Chris Bainbridge
2016-02-27 19:44     ` Henrique de Moraes Holschuh
2016-02-27 22:29     ` Borislav Petkov
2016-02-27 20:12   ` Henrique de Moraes Holschuh
2016-03-16 10:52 ` Pavel Machek

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=20160227175118.GC5261@pd.tnic \
    --to=bp@alien8.de \
    --cc=chris.bainbridge@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=x86@kernel.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