Messages in this thread | | | Date | Mon, 14 Nov 2022 17:44:00 +0300 | Subject | Re: [PATCH v2 5/5] x86/kasan: Populate shadow for shared chunk of the CPU entry area | From | Andrey Ryabinin <> |
| |
On 11/10/22 23:35, Sean Christopherson wrote:
> > + /* > + * Populate the shadow for the shared portion of the CPU entry area. > + * Shadows for the per-CPU areas are mapped on-demand, as each CPU's > + * area is randomly placed somewhere in the 512GiB range and mapping > + * the entire 512GiB range is prohibitively expensive. > + */ > + kasan_populate_early_shadow((void *)shadow_cea_begin, > + (void *)shadow_cea_per_cpu_begin); > +
I know I suggested to use "early" here, but I just realized that this might be a problem. This will actually map shadow page for the 8 pages (KASAN_SHADOW_SCALE_SHIFT) of the original memory. In case there is some per-cpu entry area starting right at CPU_ENTRY_AREA_PER_CPU the shadow for it will be covered with kasan_early_shadow_page instead of the usual one.
So we need to go back to your v1 PATCH, or alternatively we can round up CPU_ENTRY_AREA_PER_CPU #define CPU_ENTRY_AREA_PER_CPU (CPU_ENTRY_AREA_RO_IDT + PAGE_SIZE << KASAN_SHADOW_SCALE_SHIFT)
Such change will also require fixing up max_cea calculation in init_cea_offsets()
Going back kasan_populate_shadow() seems like safer and easier choice. The only disadvantage of it that we might waste 1 page, which is not much compared to the KASAN memory overhead.
> kasan_populate_early_shadow((void *)shadow_cea_end, > kasan_mem_to_shadow((void *)__START_KERNEL_map)); >
| |