All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] xen/arm: try to get stack in any case
@ 2014-10-17 15:22 Frediano Ziglio
  2014-10-17 15:46 ` Julien Grall
  0 siblings, 1 reply; 4+ messages in thread
From: Frediano Ziglio @ 2014-10-17 15:22 UTC (permalink / raw)
  To: Ian Campbell, Tim Deegan, Stefano Stabellini, Julien Grall; +Cc: xen-devel

Well,
  this is more an experiment than a patch but in my case was really
useful. Basically I was trying to get dom0 raw stack hitting '0' key
on Xen console. The problem is that when you hit such key you are Xen
domain, not domain 0 (code is called from Xen console). While Xen is
handling '0' command (dump dom0 state) show_guest_stack (in
xen/arch/arm/traps.c) try to get page from stack pointer failing as is
not current domain. In my case I had only domain0 so EL1 TTBR0/TTBR1
was domain0 and this patch work but obviously this can lead on real
cases to dump pages not from the wanted domain.

Possible solution is to get manually TTBR0/TTBR1 from the proper
domain and manually parse page tables. Now some question
- did somebody else have same issue?
- is there any helper function to get the proper page?

Regards,
   Frediano


---
 xen/arch/arm/mm.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
index 46b6d98..c76c811 100644
--- a/xen/arch/arm/mm.c
+++ b/xen/arch/arm/mm.c
@@ -1195,11 +1195,10 @@ int get_page(struct page_info *page, struct
domain *domain)
 {
     struct domain *owner = page_get_owner_and_reference(page);

-    if ( likely(owner == domain) )
+    if ( likely(owner == domain) || owner != NULL )
         return 1;

-    if ( owner != NULL )
-        put_page(page);
+    put_page(page);

     return 0;
 }
-- 
1.9.1

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

* Re: [RFC PATCH] xen/arm: try to get stack in any case
  2014-10-17 15:22 [RFC PATCH] xen/arm: try to get stack in any case Frediano Ziglio
@ 2014-10-17 15:46 ` Julien Grall
  2014-10-20  8:30   ` Ian Campbell
  0 siblings, 1 reply; 4+ messages in thread
From: Julien Grall @ 2014-10-17 15:46 UTC (permalink / raw)
  To: Frediano Ziglio, Ian Campbell, Tim Deegan, Stefano Stabellini; +Cc: xen-devel

Hi Frediano,

On 10/17/2014 04:22 PM, Frediano Ziglio wrote:
> Well,
>   this is more an experiment than a patch but in my case was really
> useful. Basically I was trying to get dom0 raw stack hitting '0' key
> on Xen console. The problem is that when you hit such key you are Xen
> domain, not domain 0 (code is called from Xen console). While Xen is
> handling '0' command (dump dom0 state) show_guest_stack (in
> xen/arch/arm/traps.c) try to get page from stack pointer failing as is
> not current domain. In my case I had only domain0 so EL1 TTBR0/TTBR1
> was domain0 and this patch work but obviously this can lead on real
> cases to dump pages not from the wanted domain.

I guess you see "Failed to convert stack to physical address"?

> Possible solution is to get manually TTBR0/TTBR1 from the proper
> domain and manually parse page tables. Now some question
> - did somebody else have same issue?
> - is there any helper function to get the proper page?

The function get_page is used in many different place to get a reference
to the page and check if the page belongs to the domain.

This patch would lead to a security issue on most of the hypercalls that
deal with memory.

The proper solution would be to switch temporally on the p2m of the v we
want to dump (see an example with flush_tlb_domain());

Regards,

-- 
Julien Grall

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

* Re: [RFC PATCH] xen/arm: try to get stack in any case
  2014-10-17 15:46 ` Julien Grall
@ 2014-10-20  8:30   ` Ian Campbell
  2014-10-20  8:34     ` Frediano Ziglio
  0 siblings, 1 reply; 4+ messages in thread
From: Ian Campbell @ 2014-10-20  8:30 UTC (permalink / raw)
  To: Julien Grall; +Cc: Stefano Stabellini, Tim Deegan, Frediano Ziglio, xen-devel

On Fri, 2014-10-17 at 16:46 +0100, Julien Grall wrote:
> The proper solution would be to switch temporally on the p2m of the v we
> want to dump (see an example with flush_tlb_domain());

Yes, certainly the proper fix would be either in get_page_from_gva or in
the caller, certainly not as far down the stack as get_page.

Ian.

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

* Re: [RFC PATCH] xen/arm: try to get stack in any case
  2014-10-20  8:30   ` Ian Campbell
@ 2014-10-20  8:34     ` Frediano Ziglio
  0 siblings, 0 replies; 4+ messages in thread
From: Frediano Ziglio @ 2014-10-20  8:34 UTC (permalink / raw)
  To: Ian Campbell; +Cc: Stefano Stabellini, Julien Grall, Tim Deegan, xen-devel

2014-10-20 9:30 GMT+01:00 Ian Campbell <Ian.Campbell@citrix.com>:
> On Fri, 2014-10-17 at 16:46 +0100, Julien Grall wrote:
>> The proper solution would be to switch temporally on the p2m of the v we
>> want to dump (see an example with flush_tlb_domain());
>
> Yes, certainly the proper fix would be either in get_page_from_gva or in
> the caller, certainly not as far down the stack as get_page.
>
> Ian.
>

Thanks you guys, I'll try to write and test a proper patch.

Frediano

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

end of thread, other threads:[~2014-10-20  8:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-17 15:22 [RFC PATCH] xen/arm: try to get stack in any case Frediano Ziglio
2014-10-17 15:46 ` Julien Grall
2014-10-20  8:30   ` Ian Campbell
2014-10-20  8:34     ` Frediano Ziglio

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.