Skip to contentSkip to conversation

tools/xenstored: Avoid dereferencing a NULL pointer if LiveUpdate is failing

PATCH In review Julien Grall 3 participants 4 messages Feb 26, 2021 – Mar 2, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/xenstored: Avoid dereferencing a NULL pointer if LiveUpdate is failing

From: Julien Grall <[email protected]>

In case of failure in do_lu_start(), XenStored will first free lu_start and then try to dereference it.

This will result to a NULL dereference as the destruction callback will set lu_start to NULL.

The crash can be avoided by freeing lu_start *after* the reply has been set.

Fixes af216a99fb4a ("tools/xenstore: add the basic framework for doing the live update")

---

This is a bug fix candidate for 4.15. The easiest way to trigger it is to have a XTF test that starts a transaction but never terminates it.

In this case, live-updating would fail and trigger a crash.

---
 tools/xenstore/xenstored_control.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tools/xenstore/xenstored_control.c +1 -2
index 653890f2d9e0..766b2438396a 100644
@@ -657,9 +657,8 @@ static bool do_lu_start(struct delayed_request *req)
 
 	/* We will reach this point only in case of failure. */
  out:
-	talloc_free(lu_status);
-
 	send_reply(lu_status->conn, XS_CONTROL, ret, strlen(ret) + 1);
+	talloc_free(lu_status);
 
 	return true;
 }
Signature · 1 line
2.17.1
#1 lore raw

Julien Grall writes ("[PATCH for-4.15] tools/xenstored: Avoid dereferencing a NULL pointer if LiveUpdate is failing"):

Quoted 5 lines

From: Julien Grall <[email protected]>

In case of failure in do_lu_start(), XenStored will first free lu_start and then try to dereference it.

Quoted 8 lines

This will result to a NULL dereference as the destruction callback will set lu_start to NULL.

The crash can be avoided by freeing lu_start *after* the reply has been set.

Fixes af216a99fb4a ("tools/xenstore: add the basic framework for doing the live update")
Reviewed-by on v1 1/1
#2 lore raw
In reply to Julien Grall
Quoted 5 lines · Julien Grall

From: Julien Grall <[email protected]>

In case of failure in do_lu_start(), XenStored will first free lu_start and then try to dereference it.

Quoted 8 lines

This will result to a NULL dereference as the destruction callback will set lu_start to NULL.

The crash can be avoided by freeing lu_start *after* the reply has been set.

Fixes af216a99fb4a ("tools/xenstore: add the basic framework for doing the live update")

Juergen

#3 lore raw

Hi Juergen,

Quoted 9 lines · Jürgen Groß
Quoted 8 lines · Julien Grall

From: Julien Grall <[email protected]>

In case of failure in do_lu_start(), XenStored will first free lu_start and then try to dereference it.

This will result to a NULL dereference as the destruction callback will set lu_start to NULL.

Quoted 7 lines
Quoted 5 lines

The crash can be avoided by freeing lu_start *after* the reply has been set.

Fixes af216a99fb4a ("tools/xenstore: add the basic framework for doing the live update")

Thanks! I have committed the patch.

Cheers,

Signature · 1 line
Julien Grall