All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] x86/hvm: prevent hvm_free_ioreq_gmfn() clobber of arbitrary memory
@ 2015-04-13 16:01 Don Slutz
  2015-04-14 11:47 ` Jan Beulich
  0 siblings, 1 reply; 10+ messages in thread
From: Don Slutz @ 2015-04-13 16:01 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper, Keir Fraser, Don Slutz, Jan Beulich

This will prevent a hard to track down bug.  It is related to

commit ffdb781883abd3215287ba1b1853f3d437d1240c
x86/hvm: prevent gcc uninitialised var warning

Which will preset "gmfn" to ~0UL.

This code will check if there is a path where bufioreq_pfn is passed
to hvm_free_ioreq_gmfn() and it is uninitialised, the BUG_ON will
report it.

Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Don Slutz <dslutz@verizon.com>
---
 xen/arch/x86/hvm/hvm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index ade99c0..0abac7c 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -536,8 +536,9 @@ static int hvm_alloc_ioreq_gmfn(struct domain *d, unsigned long *gmfn)
 
 static void hvm_free_ioreq_gmfn(struct domain *d, unsigned long gmfn)
 {
-    unsigned int i = gmfn - d->arch.hvm_domain.ioreq_gmfn.base;
+    unsigned long i = gmfn - d->arch.hvm_domain.ioreq_gmfn.base;
 
+    BUG_ON(i >= sizeof(d->arch.hvm_domain.ioreq_gmfn.mask) * 8);
     clear_bit(i, &d->arch.hvm_domain.ioreq_gmfn.mask);
 }
 
-- 
1.8.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread
* Re: [PATCH 1/1] x86/hvm: prevent hvm_free_ioreq_gmfn() clobber of arbitrary memory
@ 2015-04-23 13:25 Paul Durrant
  0 siblings, 0 replies; 10+ messages in thread
From: Paul Durrant @ 2015-04-23 13:25 UTC (permalink / raw)
  To: Jan Beulich (JBeulich@suse.com)
  Cc: Andrew Cooper, Keir (Xen.org), Don Slutz (dslutz@verizon.com), xen-devel

Apologies for breaking the threading. The mail server ate the thread and I couldn't manage to get it back...

>[snip]
>> OK, here it is as a proper patch.  I still haven't tested it -- indeed
>> I'm not sure how to test multiple ioreq clients.  Any suggestions?
>
>Paul?
>
>Thanks, Jan

Testing multiple is a bit tricky... Best thing to do, I think, is:

- Configure an HVM guest to use latest upstream QEMU (post my patch 3996e85c1822e05c50250f8d2d1e57b6bea1229d), which will give you one non-default ioreq server.
- Grab my demu repo from xenbits (git://xenbits.xen.org/people/pauldu/demu.git) and build it (master branch should be ok).
- Bring up the guest paused
- Start demu from a dom0 root shell, e.g.:

demu --domain=<domid> --device=31 --function=0

- Unpause the domain

After it comes up you should be able to see device 31 on the PCI bus, and it should appear to be a SCSI controller.

  Paul

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

end of thread, other threads:[~2015-04-23 13:25 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-13 16:01 [PATCH 1/1] x86/hvm: prevent hvm_free_ioreq_gmfn() clobber of arbitrary memory Don Slutz
2015-04-14 11:47 ` Jan Beulich
2015-04-14 13:17   ` Andrew Cooper
2015-04-14 22:54     ` Don Slutz
2015-04-16 10:53     ` Tim Deegan
2015-04-16 11:32       ` Jan Beulich
2015-04-16 16:37         ` Tim Deegan
2015-04-16 18:44           ` Andrew Cooper
2015-04-17  7:45           ` Jan Beulich
2015-04-23 13:25 Paul Durrant

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.