Re: [PATCH] x86/boot/64: Fix crash if kernel images crosses page table boundary
From: Thomas Gleixner
Date: Tue Jun 25 2019 - 15:57:06 EST
On Tue, 25 Jun 2019, Kirill A. Shutemov wrote:
> On Tue, Jun 25, 2019 at 09:04:39PM +0200, Thomas Gleixner wrote:
>
> > > + pmd[idx % PTRS_PER_PMD] = pmd_entry + i * PMD_SIZE;
> >
> > This part is functionally equivivalent. So what's the value of this change?
>
> Precedence of operators were broken
>
> idx = i + (physaddr >> PMD_SHIFT) % PTRS_PER_PMD;
>
> reads by compiler as
>
> idx = i + ((physaddr >> PMD_SHIFT) % PTRS_PER_PMD);
>
> not as
>
> idx = (i + (physaddr >> PMD_SHIFT)) % PTRS_PER_PMD;
>
> Therefore 'idx' can become >= PTRS_PER_PMD.
Indeed. Please mention it in the change log. I did not spot it right away.
Thanks,
tglx