From: Jason Andryuk Subject: [PATCH] libxc: Protect xc_domain_resume from clobbering domain registers Date: Mon, 19 May 2014 14:37:52 -0400 Message-ID: <1400524672-6141-1-git-send-email-andryuk@aero.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: Andrew Cooper , Jason Andryuk , Ian Jackson , Ian Campbell , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org xc_domain_resume() expects the guest to be in state SHUTDOWN_suspend. However, nothing verifies the state before modify_returncode() modifies the domain's registers. This will crash guest processes or the kernel itself. This can be demonstrated with `LIBXL_SAVE_HELPER=/bin/false xl migrate`. Signed-off-by: Jason Andryuk --- Changes since RFC: - Return -1 from modify_returncode - Set errno to EINVAL --- tools/libxc/xc_resume.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/libxc/xc_resume.c b/tools/libxc/xc_resume.c index 18b4818..2163ad9 100644 --- a/tools/libxc/xc_resume.c +++ b/tools/libxc/xc_resume.c @@ -39,6 +39,13 @@ static int modify_returncode(xc_interface *xch, uint32_t domid) return -1; } + if ( !info.shutdown || (info.shutdown_reason != SHUTDOWN_suspend) ) + { + ERROR("Domain not in suspended state"); + errno = EINVAL; + return -1; + } + if ( info.hvm ) { /* HVM guests without PV drivers have no return code to modify. */ -- 1.8.3.1