public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH v3 0/4] Tests for CR0.WP=0/1 r/o write access
@ 2023-04-03 10:56 Mathias Krause
  2023-04-03 10:56 ` [kvm-unit-tests PATCH v3 1/4] x86: Use existing CR0.WP / CR4.SMEP bit definitions Mathias Krause
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Mathias Krause @ 2023-04-03 10:56 UTC (permalink / raw)
  To: kvm; +Cc: Sean Christopherson, Mathias Krause

v2: https://lore.kernel.org/kvm/20230331135709.132713-1-minipli@grsecurity.net/

This series adds explicit tests that verify a page fault will occur for
attempts to write to an r/o page while CR0.WP is 1 as well as access is
granted when CR0.WP is 0.

There are existing tests already, e.g. in pks.c, pku.c, smap.c or even
access.c that implicitly test this. However, they all either explicitly
(via INVLPG) or implicitly (via CR3 reload) flush the TLB before doing
the access which might lead to false positives if the access succeeded
before, e.g. because CR0.WP was 0 before.

Better to have an explicit test, especially to back up the changes of
[1] which were missing the emulator case, initially.

Changes from v2 to v3 integrate Sean's feedback, especially the
changelogs were rewritten to avoid pronouns and the guts of the CR0.WP
toggling test were moved to a helper function.

Please apply!

Thanks,
Mathias

[1] https://lore.kernel.org/kvm/20230322013731.102955-1-minipli@grsecurity.net/

Mathias Krause (4):
  x86: Use existing CR0.WP / CR4.SMEP bit definitions
  x86/access: CR0.WP toggling write to r/o data test
  x86/access: Forced emulation support
  x86/access: Try emulation for CR0.WP test as well

 x86/access.c | 114 ++++++++++++++++++++++++++++++++++++++++++++-------
 x86/pks.c    |   5 +--
 x86/pku.c    |   5 +--
 3 files changed, 104 insertions(+), 20 deletions(-)

-- 
2.39.2


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2023-04-05  8:01 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-03 10:56 [kvm-unit-tests PATCH v3 0/4] Tests for CR0.WP=0/1 r/o write access Mathias Krause
2023-04-03 10:56 ` [kvm-unit-tests PATCH v3 1/4] x86: Use existing CR0.WP / CR4.SMEP bit definitions Mathias Krause
2023-04-03 10:56 ` [kvm-unit-tests PATCH v3 2/4] x86/access: CR0.WP toggling write to r/o data test Mathias Krause
2023-04-03 10:56 ` [kvm-unit-tests PATCH v3 3/4] x86/access: Forced emulation support Mathias Krause
2023-04-03 11:28   ` Mathias Krause
2023-04-03 19:06     ` Sean Christopherson
2023-04-03 20:06       ` Mathias Krause
2023-04-04  0:08         ` Sean Christopherson
2023-04-04  0:04   ` Sean Christopherson
2023-04-04  7:27     ` Mathias Krause
2023-04-04 16:36       ` Sean Christopherson
2023-04-05  8:01         ` Mathias Krause
2023-04-03 10:56 ` [kvm-unit-tests PATCH v3 4/4] x86/access: Try emulation for CR0.WP test as well Mathias Krause

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox