x86/pagewalk: Fix determination of Protection Key access rights
PATCH 1/1 x86/pagewalk: Fix determination of Protection Key access rights
c/s 4c5d78a10 was accidentally buggy when handling Protection Keys. Protection keys applies to all user translations, not just accesses which originate from user mode.
---
CC: Jan Beulich <[email protected]>
CC: Tim Deegan <[email protected]>
CC: George Dunlap <[email protected]>
CC: Julien Grall <[email protected]>
This regression was introducing during the 4.9 timeframe, so really should be fixed before 4.9 ships.
--- xen/arch/x86/mm/guest_walk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/mm/guest_walk.c +1 -1
@@ -408,7 +408,7 @@ guest_walk_tables(struct vcpu *v, struct p2m_domain *p2m,* N.B. In the case that the walk ended with a superpage, the fabricated * gw->l1e contains the appropriate leaf pkey. */ -if ( (walk & PFEC_user_mode) && !(walk & PFEC_insn_fetch) && +if ( (ar & _PAGE_USER) && !(walk & PFEC_insn_fetch) &&guest_pku_enabled (v) ) {unsigned int pkey =guest_l1e_get_pkey (gw->l1e);
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 3 lines · Andrew Cooper
c/s
4c5d78a10was accidentally buggy when handling Protection Keys. Protection keys applies to all user translations, not just accesses which originate from user mode.
Does the test for write-protection just below have the opposite bug? It seems to check whether the page is writable, when AFAICS it should be checking whether the action is a write (modulo CR0.WP).
Tim.
Quoted 29 lines
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Tim Deegan <[email protected]>
CC: George Dunlap <[email protected]>
CC: Julien Grall <[email protected]>This regression was introducing during the 4.9 timeframe, so really should be fixed before 4.9 ships.
--- xen/arch/x86/mm/guest_walk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/arch/x86/mm/guest_walk.c +1
-1@@ -408,7 +408,7 @@ guest_walk_tables(struct vcpu *v, struct p2m_domain *p2m,* N.B. In the case that the walk ended with a superpage, the fabricated * gw->l1e contains the appropriate leaf pkey. */ -if ( (walk & PFEC_user_mode) && !(walk & PFEC_insn_fetch) && +if ( (ar & _PAGE_USER) && !(walk & PFEC_insn_fetch) &&guest_pku_enabled (v) ) {unsigned int pkey =guest_l1e_get_pkey (gw->l1e);Signature · 1 line
2.1.4
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 9 lines · Tim Deegan
Quoted 3 lines · Andrew Cooper
c/s
4c5d78a10was accidentally buggy when handling Protection Keys. Protection keys applies to all user translations, not just accesses which originate from user mode.Reviewed-by Tim Deegan <[email protected]>Does the test for write-protection just below have the opposite bug? It seems to check whether the page is writable, when AFAICS it should be checking whether the action is a write (modulo CR0.WP).
Very good point. Let me draft a v2.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Hi Andrew,
Quoted 5 lines · Andrew Cooper
Quoted 4 lines · Tim Deegan
Quoted 3 lines · Andrew Cooper
c/s
4c5d78a10was accidentally buggy when handling Protection Keys. Protection keys applies to all user translations, not just accesses which originate from user mode.
Quoted 7 lines
Quoted 5 lines
Reviewed-by Tim Deegan <[email protected]>Does the test for write-protection just below have the opposite bug? It seems to check whether the page is writable, when AFAICS it should be checking whether the action is a write (modulo CR0.WP).
Very good point. Let me draft a v2.
FIY, I will wait the v2 before considering it for the release.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
xen/arch/x86/mm/guest_walk.c guest_walk_tables(struct vcpu *v, struct p2m_domain *p2m, · line 414
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 16.05.17 at 18:51, <[email protected]> wrote:
xen/arch/x86/mm/guest_walk.c +1
-1@@ -408,7 +408,7 @@ guest_walk_tables(struct vcpu *v, struct p2m_domain *p2m,* N.B. In the case that the walk ended with a superpage, the fabricated * gw->l1e contains the appropriate leaf pkey. */ -if ( (walk & PFEC_user_mode) && !(walk & PFEC_insn_fetch) && +if ( (ar & _PAGE_USER) && !(walk & PFEC_insn_fetch) &&guest_pku_enabled (v) ) {unsigned int pkey =guest_l1e_get_pkey (gw->l1e);
Perhaps the comment ahead of this could then also do with some improvement ("user data accesses" -> "accesses to user data")?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel