Re: [PATCH] x86/microcode: Change checksum to u32

2016-03-16 Thread Pavel Machek
Hi! > Checksum should be unsigned 32-bit otherwise the calculation overflows > resulting in undefined behaviour: > @@ -49,7 +49,7 @@ int microcode_sanity_check(void *mc, int print_err) > unsigned long total_size, data_size, ext_table_size; > struct microcode_header_intel *mc_header =

Re: [PATCH] x86/microcode: Change checksum to u32

2016-02-27 Thread Borislav Petkov
On Sat, Feb 27, 2016 at 06:23:29PM +, Chris Bainbridge wrote: > /* calculate the checksum */ > orig_sum = 0; > i = (MC_HEADER_SIZE + data_size) / DWSIZE; > while (i--) > orig_sum += ((int *)mc)[i]; Ok, since SDM says that all fields should be tre

Re: [PATCH] x86/microcode: Change checksum to u32

2016-02-27 Thread Henrique de Moraes Holschuh
On Sat, 27 Feb 2016, Borislav Petkov wrote: > * 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); Well, orig_sum is always zero, becau

Re: [PATCH] x86/microcode: Change checksum to u32

2016-02-27 Thread Henrique de Moraes Holschuh
On Sat, 27 Feb 2016, Chris Bainbridge wrote: > > So what is ubsan complaining about? > > /* calculate the checksum */ > orig_sum = 0; > i = (MC_HEADER_SIZE + data_size) / DWSIZE; > while (i--) > orig_sum += ((int *)mc)[i]; > > The checksum is the ad

Re: [PATCH] x86/microcode: Change checksum to u32

2016-02-27 Thread Chris Bainbridge
On Sat, Feb 27, 2016 at 06:51:18PM +0100, Borislav Petkov wrote: > On Sat, Feb 27, 2016 at 11:01:47AM +, Chris Bainbridge wrote: > > Checksum should be unsigned 32-bit otherwise the calculation overflows > > resulting in undefined behaviour: > > > > [0.00] > >

Re: [PATCH] x86/microcode: Change checksum to u32

2016-02-27 Thread Borislav Petkov
On Sat, Feb 27, 2016 at 11:01:47AM +, Chris Bainbridge wrote: > Checksum should be unsigned 32-bit otherwise the calculation overflows > resulting in undefined behaviour: > > [0.00] > > [0.00] UBS

[PATCH] x86/microcode: Change checksum to u32

2016-02-27 Thread Chris Bainbridge
Checksum should be unsigned 32-bit otherwise the calculation overflows resulting in undefined behaviour: [0.00] [0.00] UBSAN: Undefined behaviour in arch/x86/kernel/cpu/microcode/intel_lib.c:105:12 [