[Xen-devel] [XEN PATCH for-4.13] libxl: Fix libxl_retrieve_domain_configuration error path

Anthony PERARD posted 1 patch 4 years, 5 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/xen tags/patchew/20191112141943.245215-1-anthony.perard@citrix.com
tools/libxl/libxl_domain.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[Xen-devel] [XEN PATCH for-4.13] libxl: Fix libxl_retrieve_domain_configuration error path
Posted by Anthony PERARD 4 years, 5 months ago
From: Anthony PERARD <anthony.perard@gmail.com>

If an error were to happen before the last step, for example the
domain_configuration is missing, the error wouldn't be check by the
_end callback.

Fix that, also initialise `lock' to NULL because the exit path checks
it.

The issue shows up when there's a stubdom, and running `xl list -l`
aborts. Instead, with this patch, `xl list -l` will not list stubdom,
probably like before.

Reported-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Fixes: 61563419257ed40278938db2cce7d697aed44f5d
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/libxl/libxl_domain.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/libxl/libxl_domain.c b/tools/libxl/libxl_domain.c
index 9d0eb5aed11d..33f9d9eaa481 100644
--- a/tools/libxl/libxl_domain.c
+++ b/tools/libxl/libxl_domain.c
@@ -1998,12 +1998,14 @@ static void retrieve_domain_configuration_end(libxl__egc *egc,
     retrieve_domain_configuration_state *rdcs, int rc)
 {
     STATE_AO_GC(rdcs->qmp.ao);
-    libxl__domain_userdata_lock *lock;
+    libxl__domain_userdata_lock *lock = NULL;
 
     /* Convenience aliases */
     libxl_domain_config *const d_config = rdcs->d_config;
     libxl_domid domid = rdcs->qmp.domid;
 
+    if (rc) goto out;
+
     lock = libxl__lock_domain_userdata(gc, domid);
     if (!lock) {
         rc = ERROR_LOCK_FAIL;
-- 
Anthony PERARD


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [XEN PATCH for-4.13] libxl: Fix libxl_retrieve_domain_configuration error path
Posted by Marek Marczykowski-Górecki 4 years, 5 months ago
On Tue, Nov 12, 2019 at 02:19:43PM +0000, Anthony PERARD wrote:
> From: Anthony PERARD <anthony.perard@gmail.com>
> 
> If an error were to happen before the last step, for example the
> domain_configuration is missing, the error wouldn't be check by the
> _end callback.
> 
> Fix that, also initialise `lock' to NULL because the exit path checks
> it.
> 
> The issue shows up when there's a stubdom, and running `xl list -l`
> aborts. Instead, with this patch, `xl list -l` will not list stubdom,
> probably like before.
> 
> Reported-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
> Fixes: 61563419257ed40278938db2cce7d697aed44f5d
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>

With this patch applied, `xl list -l` no longer crashes and only prints
this error for a stubdomain:
libxl: error: libxl_domain.c:1937:retrieve_domain_configuration_lock_acquired: Domain 11:Fail to get domain configuration

The actual HVM is listed correctly. This was the previous behavior on
Xen 4.8 too.

Tested-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>

Thanks!

-- 
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [XEN PATCH for-4.13] libxl: Fix libxl_retrieve_domain_configuration error path
Posted by Wei Liu 4 years, 5 months ago
On Tue, Nov 12, 2019 at 02:19:43PM +0000, Anthony PERARD wrote:
> From: Anthony PERARD <anthony.perard@gmail.com>
> 
> If an error were to happen before the last step, for example the
> domain_configuration is missing, the error wouldn't be check by the

check -> checked

> _end callback.
> 
> Fix that, also initialise `lock' to NULL because the exit path checks
> it.
> 
> The issue shows up when there's a stubdom, and running `xl list -l`
> aborts. Instead, with this patch, `xl list -l` will not list stubdom,
> probably like before.
> 
> Reported-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
> Fixes: 61563419257ed40278938db2cce7d697aed44f5d
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>

Acked-by: Wei Liu <wl@xen.org>

I also have a look at other callbacks. The _end one is the only one that
missed this early exit path.

Juergen, this should definitively be in 4.13 since it fixes a bug
introduced in this cycle.

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [XEN PATCH for-4.13] libxl: Fix libxl_retrieve_domain_configuration error path
Posted by Jürgen Groß 4 years, 5 months ago
On 12.11.19 15:19, Anthony PERARD wrote:
> From: Anthony PERARD <anthony.perard@gmail.com>
> 
> If an error were to happen before the last step, for example the
> domain_configuration is missing, the error wouldn't be check by the
> _end callback.
> 
> Fix that, also initialise `lock' to NULL because the exit path checks
> it.
> 
> The issue shows up when there's a stubdom, and running `xl list -l`
> aborts. Instead, with this patch, `xl list -l` will not list stubdom,
> probably like before.
> 
> Reported-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
> Fixes: 61563419257ed40278938db2cce7d697aed44f5d
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>

Release-acked-by: Juergen Gross <jgross@suse.com>


Juergen

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