[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7a9aa9dd-8c9b-d0c2-9b13-d8fe06f48722@virtuozzo.com>
Date: Fri, 24 Nov 2017 20:26:06 +0300
From: Andrey Ryabinin <aryabinin@...tuozzo.com>
To: Andy Lutomirski <luto@...nel.org>
Cc: X86 ML <x86@...nel.org>, Borislav Petkov <bpetkov@...e.de>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Brian Gerst <brgerst@...il.com>,
Dave Hansen <dave.hansen@...el.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Josh Poimboeuf <jpoimboe@...hat.com>,
Alexander Potapenko <glider@...gle.com>,
Dmitry Vyukov <dvyukov@...gle.com>,
kasan-dev <kasan-dev@...glegroups.com>
Subject: Re: [PATCH v3 05/19] x86/kasan/64: Teach KASAN about the
cpu_entry_area
On 11/24/2017 07:27 PM, Andy Lutomirski wrote:
>>> + cpu_entry_area_begin = (void *)(__fix_to_virt(FIX_CPU_ENTRY_AREA_BOTTOM));
>>> + cpu_entry_area_end = (void *)(__fix_to_virt(FIX_CPU_ENTRY_AREA_TOP) + PAGE_SIZE);
>>> +
>>> kasan_populate_zero_shadow(kasan_mem_to_shadow((void *)MODULES_END),
>>> - (void *)KASAN_SHADOW_END);
>>> + kasan_mem_to_shadow(cpu_entry_area_begin));
>>> +
>>> + kasan_populate_shadow((unsigned long)kasan_mem_to_shadow(cpu_entry_area_begin),
>>> + (unsigned long)kasan_mem_to_shadow(cpu_entry_area_end),
>>> + 0);
>>> +
>>> + kasan_populate_zero_shadow(kasan_mem_to_shadow(cpu_entry_area_end),
>>
>> Seems we need to round_up kasan_mem_to_shadow(cpu_entry_area_end) to the next page
>> (or alternatively - round_up(cpu_entry_area_end, KASAN_SHADOW_SCALE_SIZE*PAGE_SIZE)).
>> Otherwise, kasan_populate_zero_shadow() will overpopulate the last shadow page of cpu_entry area with kasan_zero_page.
>>
>> We don't necessarily need to round_down(kasan_mem_to_shadow(cpu_entry_area_begin), PAGE_SIZE) because
>> kasan_populate_zero_shadow() will not populate the last 'incomplete' page and kasan_populate_shadow()
>> does round_down() internally, which is exactly what we want here. But it might be better to round_down()
>> explicitly anyway, to avoid relying on such subtle implementation details.
>
> Any chance you could send a fixup patch or a replacement patch? You
> obviously understand this code *way* better than I do.
>
> Or you could do my table-based approach and fix it permanently... :)
>
Perhaps I'll look at table-based approach later. I've send you a fixed patch for now, to not slow you down.
Powered by blists - more mailing lists