From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Keir Fraser <keir@xen.org>,
Ian Campbell <Ian.Campbell@citrix.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Ian Jackson <Ian.Jackson@eu.citrix.com>, Tim Deegan <tim@xen.org>,
Jan Beulich <JBeulich@suse.com>
Subject: [PATCH 3/3] xen/gdbsx: Security audit of {, un}pausevcpu and domstatus hypercalls
Date: Thu, 24 Jul 2014 11:56:50 +0100 [thread overview]
Message-ID: <1406199410-15823-4-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1406199410-15823-1-git-send-email-andrew.cooper3@citrix.com>
XEN_DOMCTL_gdbsx_domstatus is already safe. It loops at most over every vcpu
in a domain and breaks at the first vcpu with an event pending, marking it as
not-pending.
XEN_DOMCTL_gdbsx_pausevcpu had an incorrect bounds check against the vcpu id,
allowing an overflow of d->vcpu[] with an id between d->max_vcpus and
MAX_VIRT_CPUS. It was also able to overflow a vcpus pause count by many
repeated hypercalls.
The bounds check is fixed, and vcpu_pause() has been replaced with
vcpu_pause_by_systemcontroller() which cuts out at 255 uses.
XEN_DOMCTL_gdbsx_unpausevcpu suffered from the same bounds problems as its
pause counterpart, and is fixed in exactly the same way. Despite the
atomic_read(&v->pause_count), this code didn't successfully prevent against an
underflow of the vcpu pause count.
The vcpu_unpause() has been replaced with vcpu_pause_by_systemcontroller()
which correctly prevents against underflow. The printk() is updated to have a
proper guest logging level, and provide more useful information in the XSM
case of one domain having debugger privileges over another.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Keir Fraser <keir@xen.org>
CC: Jan Beulich <JBeulich@suse.com>
CC: Tim Deegan <tim@xen.org>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Mukesh Rathor <mukesh.rathor@oracle.com>
---
docs/misc/xsm-flask.txt | 3 ---
xen/arch/x86/domctl.c | 16 ++++++++--------
2 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/docs/misc/xsm-flask.txt b/docs/misc/xsm-flask.txt
index 31b9d27..9559028 100644
--- a/docs/misc/xsm-flask.txt
+++ b/docs/misc/xsm-flask.txt
@@ -96,9 +96,6 @@ __HYPERVISOR_domctl (xen/include/public/domctl.h)
* XEN_DOMCTL_set_broken_page_p2m
* XEN_DOMCTL_setnodeaffinity
* XEN_DOMCTL_gdbsx_guestmemio
- * XEN_DOMCTL_gdbsx_pausevcpu
- * XEN_DOMCTL_gdbsx_unpausevcpu
- * XEN_DOMCTL_gdbsx_domstatus
__HYPERVISOR_sysctl (xen/include/public/sysctl.h)
diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index 243f42f..6b2479e 100644
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -1030,11 +1030,10 @@ long arch_do_domctl(
if ( !d->controller_pause_count )
break;
ret = -EINVAL;
- if ( domctl->u.gdbsx_pauseunp_vcpu.vcpu >= MAX_VIRT_CPUS ||
+ if ( domctl->u.gdbsx_pauseunp_vcpu.vcpu > d->max_vcpus ||
(v = d->vcpu[domctl->u.gdbsx_pauseunp_vcpu.vcpu]) == NULL )
break;
- vcpu_pause(v);
- ret = 0;
+ ret = vcpu_pause_by_systemcontroller(v);
}
break;
@@ -1046,13 +1045,14 @@ long arch_do_domctl(
if ( !d->controller_pause_count )
break;
ret = -EINVAL;
- if ( domctl->u.gdbsx_pauseunp_vcpu.vcpu >= MAX_VIRT_CPUS ||
+ if ( domctl->u.gdbsx_pauseunp_vcpu.vcpu > d->max_vcpus ||
(v = d->vcpu[domctl->u.gdbsx_pauseunp_vcpu.vcpu]) == NULL )
break;
- if ( !atomic_read(&v->pause_count) )
- printk("WARN: Unpausing vcpu:%d which is not paused\n", v->vcpu_id);
- vcpu_unpause(v);
- ret = 0;
+ ret = vcpu_unpause_by_systemcontroller(v);
+ if ( ret == -EINVAL )
+ printk(XENLOG_G_WARNING
+ "WARN: d%d attempting to unpause %pv which is not paused\n",
+ current->domain->domain_id, v);
}
break;
--
1.7.10.4
next prev parent reply other threads:[~2014-07-24 10:56 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-24 10:56 [PATCH 0/3] GDBSX fixes Andrew Cooper
2014-07-24 10:56 ` [PATCH 1/3] xen/common: Introduce vcpu_{, un}pause_by_systemcontroller() helpers Andrew Cooper
2014-07-24 10:56 ` [PATCH 2/3] x86/gdbsx: Invert preconditions for XEN_DOMCTL_gdbsx_{, un}pausevcpu hypercalls Andrew Cooper
2014-07-24 10:56 ` Andrew Cooper [this message]
2014-07-24 11:07 ` [PATCH 3/3] xen/gdbsx: Security audit of {, un}pausevcpu and domstatus hypercalls Tim Deegan
2014-07-24 11:11 ` Andrew Cooper
2014-07-24 11:16 ` [Patch v2 " Andrew Cooper
2014-07-24 11:41 ` Tim Deegan
2014-07-24 12:58 ` Jan Beulich
2014-07-24 13:02 ` Andrew Cooper
2014-07-25 1:20 ` Mukesh Rathor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1406199410-15823-4-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=Ian.Campbell@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=JBeulich@suse.com \
--cc=keir@xen.org \
--cc=tim@xen.org \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).