[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH] x86/boot: Restrict directmap permissions for .text/.rodata
On 06.12.2021 16:11, Andrew Cooper wrote: > On 06/12/2021 13:58, Jan Beulich wrote: >> On 06.12.2021 14:08, Andrew Cooper wrote: >>> While we've been diligent to ensure that the main text/data/rodata mappings >>> have suitable restrictions, their aliases via the directmap were left fully >>> RW. Worse, we even had pieces of code making use of this as a feature. >>> >>> Restrict the permissions, as we have no legitimate need for writeability of >>> these areas via the directmap alias. >> Where do we end up reading .text and/or .rodata through the directmap? Can't >> we zap the mappings altogether? > > I felt it was safer to keep readability via the directmap. > > I'm not aware of any logic we have which reads the directmap in order, > but it ought to be possible. Could you add a sentence to this effect to this description, please? >> As to superpage shattering - I understand this is not deemed to be an issue >> in the common case since, with Xen moved as high up below 4G as possible, >> it wouldn't normally live inside a 1G mapping anyway? This may want calling >> out here. Plus, in non-EFI, non-XEN_ALIGN_2M builds isn't this going to >> shatter a 2M page at the tail of .rodata? > > cpu0_stack has already shattered down to 4k, which is likely in the same > superpage as rodata in a non-2M build. > > But at the end of the day, it is a security/performance tradeoff. > > memcpy(__va(__pa(divide_error)), "\x0f\x0b", 2); > asm ("div %ecx" :: "c" (0)); > > is an especially low barrier for an attacker who has a partial write gadget. > > The security benefits are substantial, and the perf downsides are a > handful of extra pagetables, and a handful of pagewalks taking extra > steps, in non-fast paths (i.e. distinctly marginal). How do you easily know what paths there are accessing data on the same (potential) superpage? However, thinking about it, with the directmap mapping presumably not getting used at all, how the mapping is arranged doesn't really matter (except for the extra memory needed, but as you say that's probably marginal). Jan
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |