Re: [PATCH] x86/pat: fix W^X violation false-positives when running as Xen PV guest
From: Jason Andryuk
Date: Wed Apr 10 2024 - 18:44:40 EST
Hi Juergen,
On Tue, Apr 9, 2024 at 5:47 AM Juergen Gross <jgross@xxxxxxxx> wrote:
>
> When running as Xen PV guest in some cases W^X violation WARN()s have
> been observed. Those WARN()s are produced by verify_rwx(), which looks
> into the PTE to verify that writable kernel pages have the NX bit set
> in order to avoid code modifications of the kernel by rogue code.
>
> As the NX bits of all levels of translation entries are or-ed and the
> RW bits of all levels are and-ed, looking just into the PTE isn't enough
> for the decision that a writable page is executable, too. When running
> as a Xen PV guest, kernel initialization will set the NX bit in PMD
> entries of the initial page tables covering the .data segment.
I think this is a more accurate description of what I investigated:
"When running as a Xen PV guest, the direct map PMDs and kernel high
map PMDs share the same set of PTEs. Kernel initialization will set
the NX bit in the direct map PMD entries, and not the shared PTEs."
The WARN()s I saw were with direct map addresses.
Thanks,
Jason