[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <12868d4c-2c03-4193-83d5-56fbe5584950@roeck-us.net>
Date: Wed, 31 Jul 2024 09:50:15 -0700
From: Guenter Roeck <linux@...ck-us.net>
To: Peter Zijlstra <peterz@...radead.org>,
Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Thomas Gleixner <tglx@...utronix.de>, Jens Axboe <axboe@...nel.dk>,
Andy Lutomirski <luto@...nel.org>, Ingo Molnar <mingo@...hat.com>,
Peter Anvin <hpa@...or.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
the arch/x86 maintainers <x86@...nel.org>
Subject: Re: Linux 6.11-rc1
On 7/31/24 09:31, Peter Zijlstra wrote:
> On Wed, Jul 31, 2024 at 09:17:44AM -0700, Linus Torvalds wrote:
>> On Wed, 31 Jul 2024 at 08:55, Peter Zijlstra <peterz@...radead.org> wrote:
>>>
>>> Right, so Thomas found that i386-pti fails to map the entire entry text.
>>> Specifically pti_clone_pgtable() hard relies -- and does not verify --
>>> that the start address is aligned to the given granularity.
>>>
>>> Now, i386 does not align __entry_text_start, and so the termination
>>> condition goes sideways and pte_clone_entry() does not always work right
>>> and it becomes a games of code layout roulette.
>>
>> Lovely.
>
> :-)
>
> This fixes the alignment assumptions and makes it all go again.
>
Confirmed.
Tested-by: Guenter Roeck <linux@...ck-us.net>
Thanks,
Guenter
> diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
> index 2e69abf4f852..bfdf5f45b137 100644
> --- a/arch/x86/mm/pti.c
> +++ b/arch/x86/mm/pti.c
> @@ -374,14 +374,14 @@ pti_clone_pgtable(unsigned long start, unsigned long end,
> */
> *target_pmd = *pmd;
>
> - addr += PMD_SIZE;
> + addr = round_up(addr + 1, PMD_SIZE);
>
> } else if (level == PTI_CLONE_PTE) {
>
> /* Walk the page-table down to the pte level */
> pte = pte_offset_kernel(pmd, addr);
> if (pte_none(*pte)) {
> - addr += PAGE_SIZE;
> + addr = round_up(addr + 1, PAGE_SIZE);
> continue;
> }
>
> @@ -401,7 +401,7 @@ pti_clone_pgtable(unsigned long start, unsigned long end,
> /* Clone the PTE */
> *target_pte = *pte;
>
> - addr += PAGE_SIZE;
> + addr = round_up(addr + 1, PAGE_SIZE);
>
> } else {
> BUG();
Powered by blists - more mailing lists