xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-4.9] x86/pagewalk: Fix determination of Protection Key access rights
@ 2017-05-16 16:51 Andrew Cooper
  2017-05-16 17:06 ` Tim Deegan
  2017-05-17  9:31 ` Jan Beulich
  0 siblings, 2 replies; 5+ messages in thread
From: Andrew Cooper @ 2017-05-16 16:51 UTC (permalink / raw)
  To: Xen-devel
  Cc: George Dunlap, Andrew Cooper, Julien Grall, Tim Deegan,
	Jan Beulich

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.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Tim Deegan <tim@xen.org>
CC: George Dunlap <george.dunlap@eu.citrix.com>
CC: Julien Grall <julien.grall@arm.com>

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(-)

diff --git a/xen/arch/x86/mm/guest_walk.c b/xen/arch/x86/mm/guest_walk.c
index 32d818e..ba72432 100644
--- a/xen/arch/x86/mm/guest_walk.c
+++ b/xen/arch/x86/mm/guest_walk.c
@@ -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);
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* Re: [PATCH for-4.9] x86/pagewalk: Fix determination of Protection Key access rights
  2017-05-16 16:51 [PATCH for-4.9] x86/pagewalk: Fix determination of Protection Key access rights Andrew Cooper
@ 2017-05-16 17:06 ` Tim Deegan
  2017-05-16 17:12   ` Andrew Cooper
  2017-05-17  9:31 ` Jan Beulich
  1 sibling, 1 reply; 5+ messages in thread
From: Tim Deegan @ 2017-05-16 17:06 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: George Dunlap, Julien Grall, Jan Beulich, Xen-devel

At 17:51 +0100 on 16 May (1494957116), Andrew Cooper wrote:
> 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.

Reviewed-by: Tim Deegan <tim@xen.org>

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.

> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> CC: Jan Beulich <JBeulich@suse.com>
> CC: Tim Deegan <tim@xen.org>
> CC: George Dunlap <george.dunlap@eu.citrix.com>
> CC: Julien Grall <julien.grall@arm.com>
> 
> 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(-)
> 
> diff --git a/xen/arch/x86/mm/guest_walk.c b/xen/arch/x86/mm/guest_walk.c
> index 32d818e..ba72432 100644
> --- a/xen/arch/x86/mm/guest_walk.c
> +++ b/xen/arch/x86/mm/guest_walk.c
> @@ -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);
> -- 
> 2.1.4
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* Re: [PATCH for-4.9] x86/pagewalk: Fix determination of Protection Key access rights
  2017-05-16 17:06 ` Tim Deegan
@ 2017-05-16 17:12   ` Andrew Cooper
  2017-05-17 18:50     ` Julien Grall
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Cooper @ 2017-05-16 17:12 UTC (permalink / raw)
  To: Tim Deegan; +Cc: George Dunlap, Julien Grall, Jan Beulich, Xen-devel

On 16/05/17 18:06, Tim Deegan wrote:
> At 17:51 +0100 on 16 May (1494957116), Andrew Cooper wrote:
>> 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.
> Reviewed-by: Tim Deegan <tim@xen.org>
>
> 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
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* Re: [PATCH for-4.9] x86/pagewalk: Fix determination of Protection Key access rights
  2017-05-16 16:51 [PATCH for-4.9] x86/pagewalk: Fix determination of Protection Key access rights Andrew Cooper
  2017-05-16 17:06 ` Tim Deegan
@ 2017-05-17  9:31 ` Jan Beulich
  1 sibling, 0 replies; 5+ messages in thread
From: Jan Beulich @ 2017-05-17  9:31 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: George Dunlap, Julien Grall, Tim Deegan, Xen-devel

>>> On 16.05.17 at 18:51, <andrew.cooper3@citrix.com> wrote:
> --- a/xen/arch/x86/mm/guest_walk.c
> +++ b/xen/arch/x86/mm/guest_walk.c
> @@ -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
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* Re: [PATCH for-4.9] x86/pagewalk: Fix determination of Protection Key access rights
  2017-05-16 17:12   ` Andrew Cooper
@ 2017-05-17 18:50     ` Julien Grall
  0 siblings, 0 replies; 5+ messages in thread
From: Julien Grall @ 2017-05-17 18:50 UTC (permalink / raw)
  To: Andrew Cooper, Tim Deegan; +Cc: George Dunlap, Jan Beulich, Xen-devel

Hi Andrew,

On 16/05/17 18:12, Andrew Cooper wrote:
> On 16/05/17 18:06, Tim Deegan wrote:
>> At 17:51 +0100 on 16 May (1494957116), Andrew Cooper wrote:
>>> 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.
>> Reviewed-by: Tim Deegan <tim@xen.org>
>>
>> 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,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

end of thread, other threads:[~2017-05-17 18:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-16 16:51 [PATCH for-4.9] x86/pagewalk: Fix determination of Protection Key access rights Andrew Cooper
2017-05-16 17:06 ` Tim Deegan
2017-05-16 17:12   ` Andrew Cooper
2017-05-17 18:50     ` Julien Grall
2017-05-17  9:31 ` Jan Beulich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).